Skip to content

Commit 6d64e70

Browse files
chore: restructure src/features/ directory (#1820)
Co-authored-by: marcustyphoon <[email protected]>
1 parent 42a5212 commit 6d64e70

File tree

91 files changed

+214
-216
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+214
-216
lines changed

docs/Chapter 3 - Repository structure.md

Lines changed: 7 additions & 7 deletions

docs/Chapter 4.0 - Feature framework.md

Lines changed: 10 additions & 12 deletions

docs/Chapter 4.1 - Feature manifests.md renamed to docs/Chapter 4.1 - Feature metadata.md

Lines changed: 1 addition & 1 deletion

src/action/render_scripts.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const configSectionLink = document.querySelector('a[href="#configuration"]');
33
const scriptsDiv = configSection.querySelector('.scripts');
44

55
const getInstalledScripts = async function () {
6-
const url = browser.runtime.getURL('/features/_index.json');
6+
const url = browser.runtime.getURL('/features/index.json');
77
const file = await fetch(url);
88
const installedScripts = await file.json();
99

@@ -135,7 +135,7 @@ const renderScripts = async function () {
135135
const disabledScripts = installedScripts.filter(scriptName => enabledScripts.includes(scriptName) === false);
136136

137137
for (const scriptName of [...orderedEnabledScripts, ...disabledScripts]) {
138-
const url = browser.runtime.getURL(`/features/${scriptName}.json`);
138+
const url = browser.runtime.getURL(`/features/${scriptName}/feature.json`);
139139
const file = await fetch(url);
140140
const {
141141
title = scriptName,

src/content_scripts/main.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515
stylesheet,
1616
styleElement,
1717
onStorageChanged
18-
} = await import(browser.runtime.getURL(`/features/${name}.js`));
18+
} = await import(browser.runtime.getURL(`/features/${name}/index.js`));
1919

2020
if (main) {
2121
main().catch(console.error);
2222
}
2323
if (stylesheet) {
2424
const link = Object.assign(document.createElement('link'), {
2525
rel: 'stylesheet',
26-
href: browser.runtime.getURL(`/features/${name}.css?t=${timestamp}`)
26+
href: browser.runtime.getURL(`/features/${name}/index.css?t=${timestamp}`)
2727
});
2828
link.className = 'xkit';
2929
document.documentElement.appendChild(link);
@@ -55,13 +55,13 @@
5555
clean,
5656
stylesheet,
5757
styleElement
58-
} = await import(browser.runtime.getURL(`/features/${name}.js`));
58+
} = await import(browser.runtime.getURL(`/features/${name}/index.js`));
5959

6060
if (clean) {
6161
clean().catch(console.error);
6262
}
6363
if (stylesheet) {
64-
document.querySelector(`link[href^="${browser.runtime.getURL(`/features/${name}.css`)}"]`)?.remove();
64+
document.querySelector(`link[href^="${browser.runtime.getURL(`/features/${name}/index.css`)}"]`)?.remove();
6565
}
6666
if (styleElement) {
6767
styleElement.remove();
@@ -90,7 +90,7 @@
9090
};
9191

9292
const getInstalledScripts = async function () {
93-
const url = browser.runtime.getURL('/features/_index.json');
93+
const url = browser.runtime.getURL('/features/index.json');
9494
const file = await fetch(url);
9595
const installedScripts = await file.json();
9696

File renamed without changes.
File renamed without changes.

src/features/accesskit.js renamed to src/features/accesskit/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { getPreferences } from '../utils/preferences.js';
1+
import { getPreferences } from '../../utils/preferences.js';
22

33
let enabledOptions;
44

55
const runOption = async function (name) {
6-
const { main: run, styleElement } = await import(`./accesskit/${name}.js`);
6+
const { main: run, styleElement } = await import(`./${name}.js`);
77
if (run) {
88
run().catch(console.error);
99
}
@@ -14,7 +14,7 @@ const runOption = async function (name) {
1414
};
1515

1616
const destroyOption = async function (name) {
17-
const { clean: destroy, styleElement } = await import(`./accesskit/${name}.js`);
17+
const { clean: destroy, styleElement } = await import(`./${name}.js`);
1818
if (destroy) {
1919
destroy().catch(console.error);
2020
}
File renamed without changes.

src/features/anti_capitalism.js renamed to src/features/anti_capitalism/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { keyToCss } from '../utils/css_map.js';
2-
import { buildStyle, getTimelineItemWrapper } from '../utils/interface.js';
3-
import { pageModifications } from '../utils/mutations.js';
4-
import { getPreferences } from '../utils/preferences.js';
1+
import { keyToCss } from '../../utils/css_map.js';
2+
import { buildStyle, getTimelineItemWrapper } from '../../utils/interface.js';
3+
import { pageModifications } from '../../utils/mutations.js';
4+
import { getPreferences } from '../../utils/preferences.js';
55

66
const hiddenAttribute = 'data-anti-capitalism-hidden';
77

0 commit comments

Comments
 (0)