Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get gmx running on Franz #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Gmail for Franz
This is the official Franz recipe for Gmail
# GMX for Franz
This is a Franz recipe for GMX. It was contributed by Oliver Gramberg (github:oliver-gramberg).

### Status
* Works except for the new messages indicator.

### How to create your own Franz recipes:
* [Read the documentation](https://github.com/meetfranz/plugins)
Binary file modified icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
76 changes: 20 additions & 56 deletions icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"id": "gmail",
"name": "Gmail",
"id": "gmx",
"name": "GMX",
"version": "1.0.0",
"description": "Gmail",
"description": "GMX web mail",
"main": "index.js",
"author": "Stefan Malzner <[email protected]>",
"author": "Oliver Gramberg <[email protected]>",
"license": "MIT",
"config": {
"serviceURL": "https://mail.google.com"
"serviceURL": "https://gmx.net"
}
}
32 changes: 11 additions & 21 deletions webview.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,19 @@
module.exports = (Franz) => {
const getMessages = function getMessages() {

// Get count of unread messages; must manually navigate to the "E-Mail" tab.
let count = 0;

// Each test is done in order of least accurate (but most robust)
// -> most accurate (but least robust)
// for reliability of at least getting a result

// 3rd best test (basic, less accurate but OK if nothing else works)
if (document.getElementsByClassName('zA zE').length > 0) {
count = document.getElementsByClassName('zA zE').length;
}

if (document.getElementsByClassName('J-Ke n0').length > 0) {
// 2nd best (more detailed check, much more accurate if available)
if (document.getElementsByClassName('J-Ke n0')[0].getAttribute('aria-label') != null) {
count = parseInt(document.getElementsByClassName('J-Ke n0')[0].getAttribute('aria-label').replace(/[^0-9.]/g, ''), 10);
}

// 1st best
if (document.getElementsByClassName('J-Ke n0')[0].getAttribute('title') != null) {
count = parseInt(document.getElementsByClassName('J-Ke n0')[0].getAttribute('title').replace(/[^0-9.]/g, ''), 10);
}
// getElementsByClassName returns an empty array; don't know why: that class
// name is clearly present several times in the DOM. Long line split for debugging.
let els = document.getElementsByClassName('badge');
count = els.length;
let el = els[1];
let val = el.getAttribute('value');
if (document.getElementsByClassName('badge')[1].getAttribute('value') != null) {
count = parseInt(document.getElementsByClassName('badge')[1].innerHTML.replace(/[^0-9.]/g, ''), 10);
}

// Just incase we don't end up with a number, set it back to zero (parseInt can return NaN)
// Just in case we don't end up with a number, set it back to zero (parseInt can return NaN)
if (isNaN(count)) {
count = 0;
}
Expand Down