Manifest version CSS rules (#1126)

* Add CSS rules for hiding content based on manifest version

* Organize other rules
This commit is contained in:
toasted-nutbread 2020-12-18 17:00:34 -05:00 committed by GitHub
parent 0d0728fac0
commit 9beb659b17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 26 additions and 5 deletions

View File

@ -2439,17 +2439,20 @@ code.anki-field-marker {
:root[data-browser=chrome] [data-show-for-browser]:not([data-show-for-browser~=chrome]), :root[data-browser=chrome] [data-show-for-browser]:not([data-show-for-browser~=chrome]),
:root[data-browser=firefox] [data-show-for-browser]:not([data-show-for-browser~=firefox]), :root[data-browser=firefox] [data-show-for-browser]:not([data-show-for-browser~=firefox]),
:root[data-browser=firefox-mobile] [data-show-for-browser]:not([data-show-for-browser~=firefox-mobile]), :root[data-browser=firefox-mobile] [data-show-for-browser]:not([data-show-for-browser~=firefox-mobile]),
:root[data-browser=edge] [data-hide-for-browser~=edge],
:root[data-browser=edge-legacy] [data-hide-for-browser~=edge-legacy],
:root[data-browser=chrome] [data-hide-for-browser~=chrome],
:root[data-browser=firefox] [data-hide-for-browser~=firefox],
:root[data-browser=firefox-mobile] [data-hide-for-browser~=firefox-mobile] {
display: none;
}
:root[data-os=mac] [data-show-for-os]:not([data-show-for-os~=mac]), :root[data-os=mac] [data-show-for-os]:not([data-show-for-os~=mac]),
:root[data-os=win] [data-show-for-os]:not([data-show-for-os~=win]), :root[data-os=win] [data-show-for-os]:not([data-show-for-os~=win]),
:root[data-os=android] [data-show-for-os]:not([data-show-for-os~=android]), :root[data-os=android] [data-show-for-os]:not([data-show-for-os~=android]),
:root[data-os=cros] [data-show-for-os]:not([data-show-for-os~=cros]), :root[data-os=cros] [data-show-for-os]:not([data-show-for-os~=cros]),
:root[data-os=linux] [data-show-for-os]:not([data-show-for-os~=linux]), :root[data-os=linux] [data-show-for-os]:not([data-show-for-os~=linux]),
:root[data-os=openbsd] [data-show-for-os]:not([data-show-for-os~=openbsd]), :root[data-os=openbsd] [data-show-for-os]:not([data-show-for-os~=openbsd]),
:root[data-browser=edge] [data-hide-for-browser~=edge],
:root[data-browser=edge-legacy] [data-hide-for-browser~=edge-legacy],
:root[data-browser=chrome] [data-hide-for-browser~=chrome],
:root[data-browser=firefox] [data-hide-for-browser~=firefox],
:root[data-browser=firefox-mobile] [data-hide-for-browser~=firefox-mobile],
:root[data-os=mac] [data-hide-for-os~=mac], :root[data-os=mac] [data-hide-for-os~=mac],
:root[data-os=win] [data-hide-for-os~=win], :root[data-os=win] [data-hide-for-os~=win],
:root[data-os=android] [data-hide-for-os~=android], :root[data-os=android] [data-hide-for-os~=android],
@ -2459,6 +2462,12 @@ code.anki-field-marker {
display: none; display: none;
} }
:root[data-manifest-version='2'] [data-show-for-manifest-version]:not([data-show-for-manifest-version~='2']),
:root[data-manifest-version='3'] [data-show-for-manifest-version]:not([data-show-for-manifest-version~='3']),
:root[data-manifest-version='2'] [data-hide-for-manifest-version~='2'],
:root[data-manifest-version='3'] [data-hide-for-manifest-version~='3'] {
display: none;
}
/* Media-specific styles */ /* Media-specific styles */
@media (max-width: 800px), (hover: none) and (max-width: 1100px) { @media (max-width: 800px), (hover: none) and (max-width: 1100px) {

View File

@ -15,7 +15,13 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
function setupEnvironmentInfo() {
const {manifest_version: manifestVersion} = chrome.runtime.getManifest();
document.documentElement.dataset.manifestVersion = `${manifestVersion}`;
}
(() => { (() => {
document.querySelector('#content-scroll-focus').focus(); document.querySelector('#content-scroll-focus').focus();
document.documentElement.dataset.loaded = 'true'; document.documentElement.dataset.loaded = 'true';
setupEnvironmentInfo();
})(); })();

View File

@ -20,9 +20,11 @@
*/ */
async function setupEnvironmentInfo() { async function setupEnvironmentInfo() {
const {manifest_version: manifestVersion} = chrome.runtime.getManifest();
const {browser, platform} = await api.getEnvironmentInfo(); const {browser, platform} = await api.getEnvironmentInfo();
document.documentElement.dataset.browser = browser; document.documentElement.dataset.browser = browser;
document.documentElement.dataset.os = platform.os; document.documentElement.dataset.os = platform.os;
document.documentElement.dataset.manifestVersion = `${manifestVersion}`;
} }
async function isAllowedIncognitoAccess() { async function isAllowedIncognitoAccess() {

View File

@ -39,9 +39,11 @@
*/ */
async function setupEnvironmentInfo() { async function setupEnvironmentInfo() {
const {manifest_version: manifestVersion} = chrome.runtime.getManifest();
const {browser, platform} = await api.getEnvironmentInfo(); const {browser, platform} = await api.getEnvironmentInfo();
document.documentElement.dataset.browser = browser; document.documentElement.dataset.browser = browser;
document.documentElement.dataset.os = platform.os; document.documentElement.dataset.os = platform.os;
document.documentElement.dataset.manifestVersion = `${manifestVersion}`;
} }
async function setupGenericSettingsController(genericSettingController) { async function setupGenericSettingsController(genericSettingController) {

View File

@ -28,9 +28,11 @@
*/ */
async function setupEnvironmentInfo() { async function setupEnvironmentInfo() {
const {manifest_version: manifestVersion} = chrome.runtime.getManifest();
const {browser, platform} = await api.getEnvironmentInfo(); const {browser, platform} = await api.getEnvironmentInfo();
document.documentElement.dataset.browser = browser; document.documentElement.dataset.browser = browser;
document.documentElement.dataset.os = platform.os; document.documentElement.dataset.os = platform.os;
document.documentElement.dataset.manifestVersion = `${manifestVersion}`;
} }
async function setupGenericSettingsController(genericSettingController) { async function setupGenericSettingsController(genericSettingController) {