diff options
author | 2023-07-26 06:29:03 -0600 | |
---|---|---|
committer | 2023-07-26 17:59:03 +0530 | |
commit | 9b8f01716774a960073e944823ab727cc867a8f6 (patch) | |
tree | 732b83770baa78f5cf12776aaa33ce65bebfa418 /recipes/instagram | |
parent | Add Excalidraw recipe (#393) (diff) | |
download | ferdium-recipes-9b8f01716774a960073e944823ab727cc867a8f6.tar.gz ferdium-recipes-9b8f01716774a960073e944823ab727cc867a8f6.tar.zst ferdium-recipes-9b8f01716774a960073e944823ab727cc867a8f6.zip |
chore: improve lint setup (#397)
- update eslint config to closely mirror the ones from ferdium-app
- add .eslintignore
- opt in to eslint `reportUnusedDisableDirectives` config option
- remove `trailingComma: all` from `prettier` config which is default in `prettier` v3
- autofix or disable a lot of lint issues throughout codebase
- add `volta` configuration to `package.json` to autoload correct `node` and `pnpm` versions
- upgrade all `eslint` and `prettier` related dependencies to latest
- update lint:fix npm script
- reformat touched files with prettier
- bumped up minor version for all recipes that have changes
- introduced injection of 'service.css' where it was missing in many recipes
---------
Co-authored-by: Vijay A <vraravam@users.noreply.github.com>
Diffstat (limited to 'recipes/instagram')
-rw-r--r-- | recipes/instagram/index.js | 13 | ||||
-rw-r--r-- | recipes/instagram/package.json | 2 | ||||
-rw-r--r-- | recipes/instagram/webview.js | 47 |
3 files changed, 29 insertions, 33 deletions
diff --git a/recipes/instagram/index.js b/recipes/instagram/index.js index d8beaa5..17de727 100644 --- a/recipes/instagram/index.js +++ b/recipes/instagram/index.js | |||
@@ -1,5 +1,8 @@ | |||
1 | module.exports = Ferdium => class Instagram extends Ferdium { | 1 | module.exports = Ferdium => |
2 | overrideUserAgent() { | 2 | class Instagram extends Ferdium { |
3 | return window.navigator.userAgent.replace(/(Ferdium|Electron)\/\S+ \([^)]+\)/g, '').trim(); | 3 | overrideUserAgent() { |
4 | } | 4 | return window.navigator.userAgent |
5 | }; | 5 | .replaceAll(/(Ferdium|Electron)\/\S+ \([^)]+\)/g, '') |
6 | .trim(); | ||
7 | } | ||
8 | }; | ||
diff --git a/recipes/instagram/package.json b/recipes/instagram/package.json index beb7ce0..5c798f3 100644 --- a/recipes/instagram/package.json +++ b/recipes/instagram/package.json | |||
@@ -1,7 +1,7 @@ | |||
1 | { | 1 | { |
2 | "id": "instagram", | 2 | "id": "instagram", |
3 | "name": "Instagram", | 3 | "name": "Instagram", |
4 | "version": "2.4.2", | 4 | "version": "2.5.0", |
5 | "license": "MIT", | 5 | "license": "MIT", |
6 | "config": { | 6 | "config": { |
7 | "serviceURL": "https://instagram.com/direct/inbox", | 7 | "serviceURL": "https://instagram.com/direct/inbox", |
diff --git a/recipes/instagram/webview.js b/recipes/instagram/webview.js index c2a8433..a4a5a8a 100644 --- a/recipes/instagram/webview.js +++ b/recipes/instagram/webview.js | |||
@@ -1,48 +1,41 @@ | |||
1 | const _path = _interopRequireDefault(require('path')); | ||
2 | |||
3 | function _interopRequireDefault(obj) { | 1 | function _interopRequireDefault(obj) { |
4 | return obj && obj.__esModule ? obj : { default: obj }; | 2 | return obj && obj.__esModule ? obj : { default: obj }; |
5 | } | 3 | } |
6 | 4 | ||
5 | const _path = _interopRequireDefault(require('path')); | ||
6 | |||
7 | module.exports = Ferdium => { | 7 | module.exports = Ferdium => { |
8 | const getMessages = () => { | 8 | const getMessages = () => { |
9 | const element = document.querySelector('a[href^="/direct/inbox"]'); | 9 | const element = document.querySelector('a[href^="/direct/inbox"]'); |
10 | Ferdium.setBadge(element.textContent ? Ferdium.safeParseInt(element.textContent) : 0); | 10 | Ferdium.setBadge( |
11 | element.textContent ? Ferdium.safeParseInt(element.textContent) : 0, | ||
12 | ); | ||
11 | }; | 13 | }; |
12 | 14 | ||
13 | Ferdium.loop(getMessages); | 15 | Ferdium.loop(getMessages); |
14 | 16 | ||
15 | // https://github.com/ferdium/ferdium-recipes/blob/9d715597a600710c20f75412d3dcd8cdb7b3c39e/docs/frontend_api.md#usage-4 | 17 | // https://github.com/ferdium/ferdium-recipes/blob/9d715597a600710c20f75412d3dcd8cdb7b3c39e/docs/frontend_api.md#usage-4 |
16 | // Helper that activates DarkReader and injects your darkmode.css at the same time | 18 | // Helper that activates DarkReader and injects your darkmode.css at the same time |
17 | Ferdium.handleDarkMode((isEnabled) => { | 19 | Ferdium.handleDarkMode(isEnabled => { |
18 | 20 | const url = new URL(window.location.href); | |
19 | var url = new URL(window.location.href); | 21 | const { searchParams } = url; |
20 | var searchParams = url.searchParams; | 22 | const isDarkModeParam = searchParams.get('theme'); |
21 | var isDarkModeParam = searchParams.get('theme'); | 23 | let changedParams = false; |
22 | var changedParams = false; | ||
23 | 24 | ||
24 | if (isEnabled) { | 25 | if (isEnabled) { |
25 | isDarkModeParam ? null : | 26 | isDarkModeParam |
26 | ( | 27 | ? null |
27 | searchParams.set('theme', 'dark'), | 28 | : (searchParams.set('theme', 'dark'), (changedParams = true)); |
28 | changedParams = true | ||
29 | ); | ||
30 | } else { | 29 | } else { |
31 | isDarkModeParam ? | 30 | isDarkModeParam |
32 | ( | 31 | ? (searchParams.delete('theme', 'dark'), (changedParams = true)) |
33 | searchParams.delete('theme', 'dark'), | 32 | : null; |
34 | changedParams = true | ||
35 | ) | ||
36 | : null; | ||
37 | } | 33 | } |
38 | 34 | ||
39 | changedParams ? | 35 | changedParams |
40 | ( | 36 | ? ((url.search = searchParams.toString()), |
41 | url.search = searchParams.toString(), | 37 | (window.location.href = url.toString())) |
42 | window.location.href = url.toString() | 38 | : null; |
43 | ) | ||
44 | : null; | ||
45 | |||
46 | }); | 39 | }); |
47 | 40 | ||
48 | Ferdium.injectCSS(_path.default.join(__dirname, 'service.css')); | 41 | Ferdium.injectCSS(_path.default.join(__dirname, 'service.css')); |