Skip to content

Commit

Permalink
Add pageAction, specifically for Android: see #30
Browse files Browse the repository at this point in the history
Android does not have browserAction, so we need pageAction. However I
could not figure out a way to fully disable pageAction on desktop
firefox. If it only shows up in the manifest, it still appears as greyed
out in the page action list, and the manifest does not seem to be
adjustable on a per-platform basis.

Hence, we enable it in all platforms. Users may hide or display it.

Also add a title to the browser action popup.

TODO: The browser popup needs to be adapted in Android, as it opens in a
new tab. It either needs to figure out from which tab it was opened and
show that tab's history, or needs to show all the tabs histories
together (possibly with some hint/filtering as to in which tab this
cleaning happened).
  • Loading branch information
Cimbali committed Aug 19, 2018
1 parent f633fa9 commit 98a4a83
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
4 changes: 4 additions & 0 deletions addon/_locales/en_US/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"message": "Converts obfuscated/nested links to genuine clean links",
"description": ""
},
"popup_description": {
"message": "Open cleaned links history",
"description": ""
},
"browser_status": {
"message": "Status:\u0020",
"description": ""
Expand Down
16 changes: 13 additions & 3 deletions addon/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ loadOptions().then(() =>
lastRightClick.reply(cleanLink(link, tab.url))
});

browser.tabs.query({}).then(tablist => tablist.forEach(tab => browser.pageAction.show(tab.id)));

if (!prefValues.enabled)
{
setIcon(icon_disabled);
Expand All @@ -313,9 +315,17 @@ loadOptions().then(() =>
});

// Auto update badge text for pages when loading is complete
browser.tabs.onUpdated.addListener((id, changeInfo, tab) => {
if (cleanedPerTab.getCount(tab.id))
browser.browserAction.setBadgeText({tabId: id, text: '' + cleanedPerTab.getCount(tab.id)});
browser.tabs.onUpdated.addListener((id, changeInfo, tab) =>
{
browser.pageAction.show(id);

var ncleaned = cleanedPerTab.getCount(tab.id);
if (!ncleaned)
return;

browser.pageAction.setTitle({tabId: id, title: _('popup_description') + ' (' + ncleaned + ')'});
else
browser.browserAction.setBadgeText({tabId: id, text: '' + ncleaned});
});

browser.tabs.onRemoved.addListener((id, removeInfo) => {
Expand Down
9 changes: 9 additions & 0 deletions addon/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@
{
"browser_style": false,
"default_icon": "icons/32.png",
"default_title": "__MSG_popup_description__",
"default_popup": "popup.html"
},

"page_action":
{
"browser_style": false,
"default_icon": "icons/32.png",
"default_title": "__MSG_popup_description__",
"default_popup": "popup.html"
},

Expand Down

0 comments on commit 98a4a83

Please sign in to comment.