diff options
author | İsmail Karslı <17887754+ismailkarsli@users.noreply.github.com> | 2024-06-08 04:21:22 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-08 06:51:22 +0530 |
commit | a8b66c0f916d1ee32a63b4e2aa32f55bf04a0061 (patch) | |
tree | 2a4aed8ed3b7b7eb2f0f2323aaedca3df6506ea5 /recipes/icloud-mail | |
parent | feat(productive): add new recipe (diff) | |
download | ferdium-recipes-a8b66c0f916d1ee32a63b4e2aa32f55bf04a0061.tar.gz ferdium-recipes-a8b66c0f916d1ee32a63b4e2aa32f55bf04a0061.tar.zst ferdium-recipes-a8b66c0f916d1ee32a63b4e2aa32f55bf04a0061.zip |
Add iCloud Mail recipe (#561)
Diffstat (limited to 'recipes/icloud-mail')
-rw-r--r-- | recipes/icloud-mail/icon.svg | 51 | ||||
-rw-r--r-- | recipes/icloud-mail/index.js | 1 | ||||
-rw-r--r-- | recipes/icloud-mail/package.json | 9 | ||||
-rw-r--r-- | recipes/icloud-mail/webview.js | 49 |
4 files changed, 110 insertions, 0 deletions
diff --git a/recipes/icloud-mail/icon.svg b/recipes/icloud-mail/icon.svg new file mode 100644 index 0000000..5ce67f3 --- /dev/null +++ b/recipes/icloud-mail/icon.svg | |||
@@ -0,0 +1,51 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
2 | <!-- Created with Inkscape (http://www.inkscape.org/) --> | ||
3 | <svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" width="602" height="602" id="svg2" version="1.1" inkscape:version="0.48.2 r9819" sodipodi:docname="Airdrop - Copie.svg"> | ||
4 | <defs id="defs4"> | ||
5 | <linearGradient inkscape:collect="always" id="linearGradient3068"> | ||
6 | <stop style="stop-color:#70efff;stop-opacity:1" offset="0" id="stop3070"/> | ||
7 | <stop style="stop-color:#5770ff;stop-opacity:1" offset="1" id="stop3072"/> | ||
8 | </linearGradient> | ||
9 | <linearGradient id="linearGradient3013" inkscape:collect="always"> | ||
10 | <stop id="stop3015" offset="0" style="stop-color:#0255fb;stop-opacity:1"/> | ||
11 | <stop id="stop3017" offset="1" style="stop-color:#13ddf5;stop-opacity:1"/> | ||
12 | </linearGradient> | ||
13 | <linearGradient inkscape:collect="always" id="linearGradient3915"> | ||
14 | <stop style="stop-color:#0081f8;stop-opacity:1;" offset="0" id="stop3917"/> | ||
15 | <stop style="stop-color:#01ddff;stop-opacity:1" offset="1" id="stop3919"/> | ||
16 | </linearGradient> | ||
17 | <linearGradient id="linearGradient3883"> | ||
18 | <stop style="stop-color:#0081f8;stop-opacity:1;" offset="0" id="stop3885"/> | ||
19 | <stop style="stop-color:#0081f8;stop-opacity:0;" offset="1" id="stop3887"/> | ||
20 | </linearGradient> | ||
21 | <linearGradient id="linearGradient3843"> | ||
22 | <stop id="stop3851" offset="0" style="stop-color:#3d73c3;stop-opacity:1;"/> | ||
23 | <stop style="stop-color:#0064f5;stop-opacity:0.37254902;" offset="0.25" id="stop3857"/> | ||
24 | <stop style="stop-color:#0064f5;stop-opacity:0.24705882;" offset="0.5" id="stop3855"/> | ||
25 | <stop style="stop-color:#0064f5;stop-opacity:0;" offset="1" id="stop3847"/> | ||
26 | </linearGradient> | ||
27 | <linearGradient id="linearGradient3835"> | ||
28 | <stop style="stop-color:#ffffff;stop-opacity:1;" offset="0" id="stop3837"/> | ||
29 | <stop style="stop-color:#ffffff;stop-opacity:0;" offset="1" id="stop3839"/> | ||
30 | </linearGradient> | ||
31 | <linearGradient inkscape:collect="always" xlink:href="#linearGradient3915" id="linearGradient3921" x1="377.88785" y1="512.68927" x2="378.47192" y2="338.63889" gradientUnits="userSpaceOnUse"/> | ||
32 | <linearGradient inkscape:collect="always" xlink:href="#linearGradient3013" id="linearGradient3025" gradientUnits="userSpaceOnUse" gradientTransform="translate(1.523435e-5,450.362)" x1="305.20093" y1="598.59198" x2="305.785" y2="8.2437592"/> | ||
33 | <linearGradient inkscape:collect="always" xlink:href="#linearGradient3068" id="linearGradient3066" gradientUnits="userSpaceOnUse" gradientTransform="matrix(0.15,0,0,0.15,0.85002387,961.21217)" x1="305.20093" y1="598.59198" x2="305.785" y2="8.2437592"/> | ||
34 | </defs> | ||
35 | <sodipodi:namedview id="base" pagecolor="#ffffff" bordercolor="#666666" borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="0.37410882" inkscape:cx="-298.61733" inkscape:cy="36.893627" inkscape:document-units="px" inkscape:current-layer="layer1" showgrid="false" inkscape:window-width="1366" inkscape:window-height="706" inkscape:window-x="-8" inkscape:window-y="-8" inkscape:window-maximized="1"/> | ||
36 | <metadata id="metadata7"> | ||
37 | <rdf:RDF> | ||
38 | <cc:Work rdf:about=""> | ||
39 | <dc:format>image/svg+xml</dc:format> | ||
40 | <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/> | ||
41 | <dc:title/> | ||
42 | </cc:Work> | ||
43 | </rdf:RDF> | ||
44 | </metadata> | ||
45 | <g inkscape:label="Calque 1" inkscape:groupmode="layer" id="layer1" transform="translate(0,-450.36218)"> | ||
46 | <g id="g3062" transform="matrix(6.6666666,0,0,6.6666666,-5.6668106,-5957.7191)"> | ||
47 | <path inkscape:connector-curvature="0" style="color:#000000;fill:url(#linearGradient3066);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" d="m 21.652659,961.36222 48.694734,0 c 11.441552,0 20.652633,9.21108 20.652633,20.65264 l 0,48.69474 c 0,11.4416 -9.211081,20.6526 -20.652633,20.6526 l -48.694734,0 c -11.441563,0 -20.6526336,-9.211 -20.6526336,-20.6526 l 0,-48.69474 c 0,-11.44156 9.2110706,-20.65264 20.6526336,-20.65264 z" id="rect2996"/> | ||
48 | <path transform="translate(0,450.36218)" sodipodi:nodetypes="sccccccccaaaccccsscsscccccccccccccccsscccccsscccccaaacc" inkscape:connector-curvature="0" id="rect3027" d="m 20.71875,536.59375 c -0.474202,0 -0.920938,0.0818 -1.34375,0.25 l 8.46875,8.71875 8.5625,8.875 0.15625,0.1875 0.25,0.25 0.25,0.25 0.5,0.53125 7.34375,7.53125 c 0.122269,0.076 0.476602,0.4042 0.753434,0.54258 0.356583,0.17824 0.743089,0.34255 1.141484,0.3568 0.42992,0.0154 0.869334,-0.10782 1.256181,-0.29601 0.289732,-0.14096 0.418572,-0.34294 0.755151,-0.60337 l 8.5,-8.78125 8.59375,-8.84375 8.28125,-8.53125 c -0.531643,-0.28806 -1.120466,-0.4375 -1.75,-0.4375 z m -2.59375,1.0625 c -0.903115,0.85572 -1.46875,2.14217 -1.46875,3.59375 l 0,28.625 c 0,1.17535 0.377499,2.24307 1,3.0625 l 1.1875,-1.125 8.84375,-8.59375 7.84375,-7.59375 -0.15625,-0.1875 -8.59375,-8.84375 -8.59375,-8.875 z m 57.1875,0.28125 -8.375,8.65625 -8.5625,8.84375 -0.15625,0.15625 8.15625,7.90625 8.84375,8.59375 0.53125,0.5 c 0.476164,-0.76402 0.75,-1.70518 0.75,-2.71875 l 0,-28.625 c 0,-1.29428 -0.448516,-2.46795 -1.1875,-3.3125 z m -38.78125,18.71875 -7.8125,7.59375 -8.875,8.59375 -1.125,1.09375 c 0.593096,0.38196 1.268042,0.625 2,0.625 l 51.71875,0 c 0.879957,0 1.678116,-0.33853 2.34375,-0.875 l -0.5625,-0.5625 -8.875,-8.59375 -8.15625,-7.875 -7.34375,7.5625 c -0.397465,0.2635 -0.663064,0.55576 -1.051168,0.73523 -0.624615,0.28885 -1.309163,0.53321 -1.997252,0.52267 -0.689922,-0.0106 -1.366428,-0.28061 -1.985577,-0.58517 -0.310792,-0.15288 -0.476438,-0.30481 -0.841003,-0.61023 z" style="color:#000000;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:6.19999981;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"/> | ||
49 | </g> | ||
50 | </g> | ||
51 | </svg> \ No newline at end of file | ||
diff --git a/recipes/icloud-mail/index.js b/recipes/icloud-mail/index.js new file mode 100644 index 0000000..dd41f72 --- /dev/null +++ b/recipes/icloud-mail/index.js | |||
@@ -0,0 +1 @@ | |||
module.exports = Ferdium => Ferdium; | |||
diff --git a/recipes/icloud-mail/package.json b/recipes/icloud-mail/package.json new file mode 100644 index 0000000..4a4fe01 --- /dev/null +++ b/recipes/icloud-mail/package.json | |||
@@ -0,0 +1,9 @@ | |||
1 | { | ||
2 | "id": "icloud-mail", | ||
3 | "name": "iCloud Mail", | ||
4 | "version": "1.0.0", | ||
5 | "license": "MIT", | ||
6 | "config": { | ||
7 | "serviceURL": "https://www.icloud.com/mail/" | ||
8 | } | ||
9 | } | ||
diff --git a/recipes/icloud-mail/webview.js b/recipes/icloud-mail/webview.js new file mode 100644 index 0000000..526a205 --- /dev/null +++ b/recipes/icloud-mail/webview.js | |||
@@ -0,0 +1,49 @@ | |||
1 | function _interopRequireDefault(obj) { | ||
2 | return obj && obj.__esModule ? obj : { default: obj }; | ||
3 | } | ||
4 | |||
5 | const _path = _interopRequireDefault(require('path')); | ||
6 | |||
7 | module.exports = Ferdium => { | ||
8 | const getMessages = root => { | ||
9 | // it's either localised "Inbox" name or unread count. | ||
10 | const unread = root.querySelector( | ||
11 | `.mailbox-list-pane .mailbox-list .mailbox-list-item:first-child p:last-child`, | ||
12 | ); | ||
13 | if (!unread) return; | ||
14 | const count = Ferdium.safePerseInt(unread.textContent) ?? 0; | ||
15 | Ferdium.setBadge(count); | ||
16 | }; | ||
17 | |||
18 | const getActiveDialogTitle = root => { | ||
19 | const activeThread = root.querySelector( | ||
20 | `.thread-list .thread-list-item[aria-selected="true"]`, | ||
21 | ); | ||
22 | // if there's a active thread, use partipicant names. if not, use mailbox name (inbox, junk, trash etc.) | ||
23 | if (activeThread) { | ||
24 | const sender = activeThread.querySelector( | ||
25 | '.thread-header .thread-participants', | ||
26 | ); | ||
27 | Ferdium.setDialogTitle(sender.textContent); | ||
28 | return; | ||
29 | } | ||
30 | |||
31 | const activeMailbox = root.querySelector( | ||
32 | `.mailbox-list-pane .mailbox-list .mailbox-list-item[aria-selected="true"] p`, | ||
33 | ); | ||
34 | Ferdium.setDialogTitle(activeMailbox.textContent); | ||
35 | }; | ||
36 | |||
37 | const loopFunc = () => { | ||
38 | // they put the mail root in an iframe for some reason | ||
39 | const childDocument = document.querySelector( | ||
40 | 'iframe.child-application#early-child', | ||
41 | )?.contentDocument; | ||
42 | getMessages(childDocument); | ||
43 | getActiveDialogTitle(childDocument); | ||
44 | }; | ||
45 | |||
46 | Ferdium.loop(loopFunc); | ||
47 | |||
48 | Ferdium.injectCSS(_path.default.join(__dirname, 'service.css')); | ||
49 | }; | ||