-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
421f6cd
commit 4423e04
Showing
4 changed files
with
110 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = Ferdium => Ferdium; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"id": "icloud-mail", | ||
"name": "iCloud Mail", | ||
"version": "1.0.0", | ||
"license": "MIT", | ||
"config": { | ||
"serviceURL": "https://www.icloud.com/mail/" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
function _interopRequireDefault(obj) { | ||
return obj && obj.__esModule ? obj : { default: obj }; | ||
} | ||
|
||
const _path = _interopRequireDefault(require('path')); | ||
|
||
module.exports = Ferdium => { | ||
const getMessages = root => { | ||
// it's either localised "Inbox" name or unread count. | ||
const unread = root.querySelector( | ||
`.mailbox-list-pane .mailbox-list .mailbox-list-item:first-child p:last-child`, | ||
); | ||
if (!unread) return; | ||
const count = Number.parseInt(unread.textContent) ?? 0; | ||
Ferdium.setBadge(count); | ||
}; | ||
|
||
const getActiveDialogTitle = root => { | ||
const activeThread = root.querySelector( | ||
`.thread-list .thread-list-item[aria-selected="true"]`, | ||
); | ||
// if there's a active thread, use partipicant names. if not, use mailbox name (inbox, junk, trash etc.) | ||
if (activeThread) { | ||
const sender = activeThread.querySelector( | ||
'.thread-header .thread-participants', | ||
); | ||
Ferdium.setDialogTitle(sender.textContent); | ||
return; | ||
} | ||
|
||
const activeMailbox = root.querySelector( | ||
`.mailbox-list-pane .mailbox-list .mailbox-list-item[aria-selected="true"] p`, | ||
); | ||
Ferdium.setDialogTitle(activeMailbox.textContent); | ||
}; | ||
|
||
const loopFunc = () => { | ||
// they put the mail root in an iframe for some reason | ||
const childDocument = document.querySelector( | ||
'iframe.child-application#early-child', | ||
)?.contentDocument; | ||
getMessages(childDocument); | ||
getActiveDialogTitle(childDocument); | ||
}; | ||
|
||
Ferdium.loop(loopFunc); | ||
|
||
Ferdium.injectCSS(_path.default.join(__dirname, 'service.css')); | ||
}; |