Skip to content

Commit 849b5d4

Browse files
committed
fix(pageaction): reverted as Firefox still support it
1 parent d817ac2 commit 849b5d4

File tree

4 files changed

+67
-1
lines changed

4 files changed

+67
-1
lines changed

background.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,55 @@ function urlChangeStrategy(tabId, sbPrevUrl) {
7474
}
7575
});
7676
}
77+
78+
// call function which get the address bar color (toolbar_field)
79+
setPageActionIcon();
80+
81+
async function setPageActionIcon() {
82+
var themeInfo = await browser.theme.getCurrent();
83+
let color = 'light';
84+
var rgb_list = ['rgb(71, 71, 73)', 'rgb(50, 50, 52)']; // list of RGB where icon_theme should be light
85+
if (themeInfo.colors && themeInfo.colors.toolbar_field) {
86+
if (!rgb_list.includes(themeInfo.colors.toolbar_field.toString())) {
87+
color = 'dark';
88+
}
89+
}
90+
setPageAction(color);
91+
}
92+
93+
function setPageAction(color) {
94+
var ext_icon = 'icon-' + color + '.svg';
95+
browser.tabs.onUpdated.addListener(function (tabId, changeInfo, tab) {
96+
var getting = browser.storage.local.get('pageaction');
97+
getting.then(
98+
function (result) {
99+
var pageaction = result.pageaction;
100+
if (!pageaction) {
101+
if (
102+
tab.url.indexOf('about:') !== 0 &&
103+
tab.url.indexOf('moz-extension:') !== 0
104+
) {
105+
browser.pageAction.setIcon({
106+
tabId: tab.id,
107+
path: ext_icon
108+
});
109+
110+
browser.pageAction.setTitle({
111+
tabId: tab.id,
112+
title: 'Share'
113+
});
114+
115+
browser.pageAction.show(tab.id);
116+
browser.pageAction.setPopup({
117+
tabId,
118+
popup: '/modal/modal.html'
119+
});
120+
}
121+
}
122+
},
123+
function (error) {
124+
console.log(`Error: ${error}`);
125+
}
126+
);
127+
});
128+
}

manifest.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "This extension reimplement the share feature with Container support and over 14+ social networks",
44
"manifest_version": 2,
55
"name": "Share Backported",
6-
"version": "2.1.3",
6+
"version": "2.1.4",
77
"icons": {
88
"16": "icon-dark.svg",
99
"24": "icon-dark.svg",
@@ -45,6 +45,10 @@
4545
}
4646
}
4747
},
48+
"page_action": {
49+
"default_icon": "icon-dark.svg",
50+
"browser_style": true
51+
},
4852
"background": {
4953
"scripts": [
5054
"background.js"

options/options.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,13 @@ <h4>Follow the placeholder and change only <i>instance_url</i>.</h4>
477477
<label>Mastodon: https://instance_url/share?text<br> <input type="url" id="mastodon" style="width:100%" placeholder="https://instance_url?post&title"></label><br>
478478
</div>
479479
</div>
480+
<div class="row hr">
481+
<div class="col-12">
482+
<h1>PageAction</h1>
483+
<h4>You can hide the <i>PageAction</i> icon (so the shortcut shown in the address bar) - just put a check in the following field, and the press "Save"</h4>
484+
<label class="browser-style"><input type="checkbox" id="pageaction">Disable</label>
485+
</div>
486+
</div>
480487
<div class="row hr">
481488
<div class="col-12">
482489
<h1>Share format</h1>

readme.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ You can hide some services/icons just put a check in the relevant field in the
1919

2020
In the same section, you can also change width and height of the share window (for every service), so the windows opened when you click on the relevant icon, and you can change the position/order of services too.
2121

22+
#### PageAction
23+
You can hide the <i>PageAction</i> icon (so the shortcut shown in the address bar) - just put a check in the field contained in the “PageAction” section.
24+
2225
#### Keyboard shortcut
2326
The PageAction can be triggered via <kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>y</kbd> (resp. <kbd>Cmd</kbd> on macOS) from keyboard.
2427
Think of the share icon. The modifier keys prevent collisions.

0 commit comments

Comments
 (0)