diff options
-rw-r--r-- | recipes/magic-level/icon.svg | 19 | ||||
-rw-r--r-- | recipes/magic-level/index.js | 1 | ||||
-rw-r--r-- | recipes/magic-level/package.json | 9 | ||||
-rw-r--r-- | recipes/magic-level/service.css | 3 | ||||
-rw-r--r-- | recipes/magic-level/webview.js | 42 |
5 files changed, 74 insertions, 0 deletions
diff --git a/recipes/magic-level/icon.svg b/recipes/magic-level/icon.svg new file mode 100644 index 0000000..79b5752 --- /dev/null +++ b/recipes/magic-level/icon.svg | |||
@@ -0,0 +1,19 @@ | |||
1 | <?xml version="1.0" standalone="no"?> | ||
2 | <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" | ||
3 | "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"> | ||
4 | <svg version="1.0" xmlns="http://www.w3.org/2000/svg" | ||
5 | width="16.000000pt" height="16.000000pt" viewBox="0 0 16.000000 16.000000" | ||
6 | preserveAspectRatio="xMidYMid meet"> | ||
7 | |||
8 | <g transform="translate(0.000000,16.000000) scale(0.100000,-0.100000)" | ||
9 | fill="#000000" stroke="none"> | ||
10 | <path d="M62 115 c-11 -24 -10 -25 18 -25 28 0 29 1 18 25 -6 14 -14 25 -18 | ||
11 | 25 -4 0 -12 -11 -18 -25z"/> | ||
12 | <path d="M25 80 c-3 -5 -1 -10 4 -10 6 0 11 5 11 10 0 6 -2 10 -4 10 -3 0 -8 | ||
13 | -4 -11 -10z"/> | ||
14 | <path d="M120 80 c0 -5 5 -10 11 -10 5 0 7 5 4 10 -3 6 -8 10 -11 10 -2 0 -4 | ||
15 | -4 -4 -10z"/> | ||
16 | <path d="M35 20 c-8 -13 -1 -24 14 -19 6 3 7 10 2 18 -6 10 -10 10 -16 1z"/> | ||
17 | <path d="M107 15 c-5 -10 0 -15 14 -15 12 0 19 5 17 12 -6 18 -25 20 -31 3z"/> | ||
18 | </g> | ||
19 | </svg> | ||
diff --git a/recipes/magic-level/index.js b/recipes/magic-level/index.js new file mode 100644 index 0000000..dd41f72 --- /dev/null +++ b/recipes/magic-level/index.js | |||
@@ -0,0 +1 @@ | |||
module.exports = Ferdium => Ferdium; | |||
diff --git a/recipes/magic-level/package.json b/recipes/magic-level/package.json new file mode 100644 index 0000000..e36c097 --- /dev/null +++ b/recipes/magic-level/package.json | |||
@@ -0,0 +1,9 @@ | |||
1 | { | ||
2 | "id": "magic-level", | ||
3 | "name": "Magic Level", | ||
4 | "version": "1.0.0", | ||
5 | "license": "MIT", | ||
6 | "config": { | ||
7 | "serviceURL": "https://magiclevel.ml" | ||
8 | } | ||
9 | } | ||
diff --git a/recipes/magic-level/service.css b/recipes/magic-level/service.css new file mode 100644 index 0000000..c07277e --- /dev/null +++ b/recipes/magic-level/service.css | |||
@@ -0,0 +1,3 @@ | |||
1 | .aiw .cd .vh { | ||
2 | display: none !important; | ||
3 | } \ No newline at end of file | ||
diff --git a/recipes/magic-level/webview.js b/recipes/magic-level/webview.js new file mode 100644 index 0000000..d39c90d --- /dev/null +++ b/recipes/magic-level/webview.js | |||
@@ -0,0 +1,42 @@ | |||
1 | const _path = _interopRequireDefault(require('path')); | ||
2 | |||
3 | function _interopRequireDefault(obj) { | ||
4 | return obj && obj.__esModule ? obj : { default: obj }; | ||
5 | } | ||
6 | |||
7 | module.exports = Ferdium => { | ||
8 | |||
9 | const getMessages = () => { | ||
10 | let countImportant = 0; | ||
11 | let countNonImportant = 0; | ||
12 | const inboxLinks = document.querySelectorAll('.J-Ke.n0'); | ||
13 | if (inboxLinks.length > 0) { | ||
14 | let parentNode = inboxLinks[0].parentNode; | ||
15 | if (parentNode) { | ||
16 | let parentNodeOfParentNode = parentNode.parentNode; | ||
17 | if (parentNodeOfParentNode) { | ||
18 | const unreadCounts = parentNodeOfParentNode.querySelectorAll('.bsU'); | ||
19 | if (unreadCounts.length > 0) { | ||
20 | let unreadCount = unreadCounts[0].textContent; | ||
21 | if (unreadCount.includes(':')) { | ||
22 | let counts = unreadCount | ||
23 | .split(':') | ||
24 | .map(s => Ferdium.safeParseInt(s.replace(/[^\p{N}]/gu, ''))); | ||
25 | countImportant = counts[0]; | ||
26 | countNonImportant = counts[1] - counts[0]; | ||
27 | } else { | ||
28 | countImportant = Ferdium.safeParseInt( | ||
29 | unreadCount.replace(/[^\p{N}]/gu, ''), | ||
30 | ); | ||
31 | } | ||
32 | } | ||
33 | } | ||
34 | } | ||
35 | } | ||
36 | Ferdium.setBadge(countImportant, countNonImportant); | ||
37 | }; | ||
38 | |||
39 | Ferdium.loop(getMessages); | ||
40 | |||
41 | Ferdium.injectCSS(_path.default.join(__dirname, 'service.css')); | ||
42 | }; | ||