Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indicate and disable currently-outdated features #1660

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/action/configuration.css
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,16 @@ label[for="filter"] {
font-weight: normal;
}

.script:not(.disabled)[data-outdated="true"] .title::after {
content: "(outdated)";
margin-left: 0.5ch;
font-weight: normal;
}

.script[data-outdated="true"] .meta {
opacity: 0.6;
}

.script .note {
padding: 1ch 2ch;
margin: 0;
Expand Down
2 changes: 2 additions & 0 deletions src/action/render_scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ const renderScripts = async function () {
title = scriptName,
description = '',
note = '',
outdated = false,
icon = {},
help = '',
relatedTerms = [],
Expand All @@ -153,6 +154,7 @@ const renderScripts = async function () {
const detailsElement = scriptTemplateClone.querySelector('details.script');
detailsElement.dataset.relatedTerms = relatedTerms;
detailsElement.dataset.deprecated = deprecated;
detailsElement.dataset.outdated = outdated;

if (enabledScripts.includes(scriptName) === false) {
detailsElement.classList.add('disabled');
Expand Down
29 changes: 16 additions & 13 deletions src/content_scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,19 @@
}
};

const getInstalledScripts = async function () {
const url = browser.runtime.getURL('/features/_index.json');
const file = await fetch(url);
const installedScripts = await file.json();

return installedScripts;
const getInstalledEnabledScripts = async () => {
const { enabledScripts = [] } = await browser.storage.local.get('enabledScripts');

return (
await Promise.all(
enabledScripts.map(scriptName =>
fetch(browser.runtime.getURL(`/features/${scriptName}.json`))
.then(response => response.json())
.then(scriptManifest => scriptManifest.outdated ? false : scriptName)
.catch(() => false)
)
)
).filter(Boolean);
};

const initMainWorld = () => new Promise(resolve => {
Expand All @@ -113,11 +120,9 @@
browser.storage.onChanged.addListener(onStorageChanged);

const [
installedScripts,
{ enabledScripts = [] }
installedEnabledScripts
] = await Promise.all([
getInstalledScripts(),
browser.storage.local.get('enabledScripts'),
getInstalledEnabledScripts(),
initMainWorld()
]);

Expand All @@ -127,9 +132,7 @@
*/
await Promise.all(['css_map', 'language_data', 'user'].map(name => import(browser.runtime.getURL(`/utils/${name}.js`))));

installedScripts
.filter(scriptName => enabledScripts.includes(scriptName))
.forEach(runScript);
installedEnabledScripts.forEach(runScript);
};

const waitForReactLoaded = () => new Promise(resolve => {
Expand Down
1 change: 1 addition & 0 deletions src/features/panorama.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"title": "Panorama",
"description": "Widescreen dashboard",
"note": "This feature is not currently functional.",
"outdated": true,
"icon": {
"class_name": "ri-align-justify",
"color": "white",
Expand Down
2 changes: 2 additions & 0 deletions src/features/quote_replies.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
"color": "white",
"background_color": "#00b8ff"
},
"note": "This feature is not currently functional.",
"outdated": true,
"help": "https://github.com/AprilSylph/XKit-Rewritten/wiki/Features#quote-replies",
"preferences": {
"tagReplyingBlog": {
Expand Down
Loading