Skip to content

Commit 7eb6d96

Browse files
committed
Implement fix for gmail.get.unread_emails() and friends.
As implemented by @hzb on Github in KartikTalwar#570. TODO: Returns NaN instead of 0. Should be fixed.
1 parent 628c2d9 commit 7eb6d96

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/gmail.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -581,8 +581,8 @@ var Gmail = function(localJQuery) {
581581
var dom = $("div[role=navigation]").find("[title*='" + api.tools.i18n("inbox") + "']");
582582

583583
if(dom.length > 0) {
584-
if(dom[0].title.indexOf("(") !== -1) {
585-
return parseInt(dom[0].title.split(":")[0].replace(/[^0-9]/g, ""));
584+
if(dom[0].title.indexOf(api.tools.i18n("inbox")) !== -1) {
585+
return parseInt(dom[0].attributes['aria-label'].value.replace(/[^0-9]/g, ""));
586586
}
587587
}
588588

@@ -594,8 +594,8 @@ var Gmail = function(localJQuery) {
594594
var dom = $("div[role=navigation]").find("[title*='" + api.tools.i18n("drafts") + "']");
595595

596596
if(dom.length > 0) {
597-
if(dom[0].title.indexOf("(") !== -1) {
598-
return parseInt(dom[0].title.replace(/[^0-9]/g, ""));
597+
if(dom[0].title.indexOf(api.tools.i18n("drafts")) !== -1) {
598+
return parseInt(dom[0].attributes['aria-label'].value.replace(/[^0-9]/g, ""));
599599
}
600600
}
601601

@@ -607,8 +607,8 @@ var Gmail = function(localJQuery) {
607607
var dom = $("div[role=navigation]").find("[title*='" + api.tools.i18n("spam") + "']");
608608

609609
if(dom.length > 0) {
610-
if(dom[0].title.indexOf("(") !== -1) {
611-
return parseInt(dom[0].title.replace(/[^0-9]/g, ""));
610+
if(dom[0].title.indexOf(api.tools.i18n("spam")) !== -1) {
611+
return parseInt(dom[0].attributes['aria-label'].value.replace(/[^0-9]/g, ""));
612612
}
613613
}
614614

@@ -620,8 +620,8 @@ var Gmail = function(localJQuery) {
620620
var dom = $("div[role=navigation]").find("[title*='" + api.tools.i18n("forums") + "']");
621621

622622
if(dom.length > 0) {
623-
if(dom[0].title.indexOf("(") !== -1) {
624-
return parseInt(dom[0].title.replace(/[^0-9]/g, ""));
623+
if(dom[0].title.indexOf(api.tools.i18n("forums")) !== -1) {
624+
return parseInt(dom[0].attributes['aria-label'].value.replace(/[^0-9]/g, ""));
625625
}
626626
}
627627

@@ -633,8 +633,8 @@ var Gmail = function(localJQuery) {
633633
var dom = $("div[role=navigation]").find("[title*='" + api.tools.i18n("updates") + "']");
634634

635635
if(dom.length > 0) {
636-
if(dom[0].title.indexOf("(") !== -1) {
637-
return parseInt(dom[0].title.replace(/[^0-9]/g, ""));
636+
if(dom[0].title.indexOf(api.tools.i18n("updates")) !== -1) {
637+
return parseInt(dom[0].attributes['aria-label'].value.replace(/[^0-9]/g, ""));
638638
}
639639
}
640640

@@ -646,8 +646,8 @@ var Gmail = function(localJQuery) {
646646
var dom = $("div[role=navigation]").find("[title*='" + api.tools.i18n("promotions") + "']");
647647

648648
if(dom.length > 0) {
649-
if(dom[0].title.indexOf("(") !== -1) {
650-
return parseInt(dom[0].title.replace(/[^0-9]/g, ""));
649+
if(dom[0].title.indexOf(api.tools.i18n("promotions")) !== -1) {
650+
return parseInt(dom[0].attributes['aria-label'].value.replace(/[^0-9]/g, ""));
651651
}
652652
}
653653

@@ -659,8 +659,8 @@ var Gmail = function(localJQuery) {
659659
var dom = $("div[role=navigation]").find("[title*='" + api.tools.i18n("social_updates") + "']");
660660

661661
if(dom.length > 0) {
662-
if(dom[0].title.indexOf("(") !== -1) {
663-
return parseInt(dom[0].title.replace(/[^0-9]/g, ""));
662+
if(dom[0].title.indexOf(api.tools.i18n("social_updates")) !== -1) {
663+
return parseInt(dom[0].attributes['aria-label'].value.replace(/[^0-9]/g, ""));
664664
}
665665
}
666666

0 commit comments

Comments
 (0)