Refactoring & renaming
46
src/background.js
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
function completeInitialization() {
|
||||||
|
// Set the default background color of the action icon badge.
|
||||||
|
chrome.browserAction.setBadgeBackgroundColor({
|
||||||
|
color: "#0071b3"
|
||||||
|
});
|
||||||
|
|
||||||
|
/* Toggle the toolbar icon based on whether stickies are, or are not, set to
|
||||||
|
be killed on the current tab, or update the badge with # of stickies killed.
|
||||||
|
|
||||||
|
This listener receives a message from the content script (contentScript.js);
|
||||||
|
the content script actually determines what the settings for the current
|
||||||
|
tab are.
|
||||||
|
*/
|
||||||
|
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
|
||||||
|
if (typeof request.killingStickies != "undefined") {
|
||||||
|
let icons = request.killingStickies ?
|
||||||
|
AKS.actionIcons.on :
|
||||||
|
AKS.actionIcons.off;
|
||||||
|
chrome.browserAction.setIcon({
|
||||||
|
path: icons,
|
||||||
|
tabId: request.tabID || sender.tab.id
|
||||||
|
});
|
||||||
|
} else if (typeof request.newBadgeText != "undefined") {
|
||||||
|
chrome.browserAction.setBadgeText({
|
||||||
|
tabId: sender.tab.id,
|
||||||
|
text: request.newBadgeText
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function initialize() {
|
||||||
|
window.AKS = { };
|
||||||
|
|
||||||
|
var xhr = new XMLHttpRequest();
|
||||||
|
xhr.onload = () => {
|
||||||
|
AKS.actionIcons = JSON.parse(this.response);
|
||||||
|
completeInitialization();
|
||||||
|
};
|
||||||
|
xhr.open('GET', chrome.extension.getURL('/action_icons.json'), true);
|
||||||
|
xhr.send();
|
||||||
|
}
|
||||||
|
|
||||||
|
initialize;
|
||||||
|
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
@ -6,7 +6,7 @@
|
|||||||
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
|
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
|
||||||
<link rel='stylesheet' type='text/css' href='options.css' />
|
<link rel='stylesheet' type='text/css' href='options.css' />
|
||||||
<link rel='stylesheet' type='text/css' href='fonts.css' />
|
<link rel='stylesheet' type='text/css' href='fonts.css' />
|
||||||
<link rel="shortcut icon" type="image/png" href="images/ASK_on_32.png" />
|
<link rel="shortcut icon" type="image/png" href="images/AKS_on_32.png" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>AlwaysKillSticky</h1>
|
<h1>AlwaysKillSticky</h1>
|
||||||
|
|||||||
14
src/platform/chrome/action_icons.json
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"on": {
|
||||||
|
"16": "images/AKS_on_16.png",
|
||||||
|
"32": "images/AKS_on_32.png",
|
||||||
|
"48": "images/AKS_on_48.png",
|
||||||
|
"128": "images/AKS_on_128.png"
|
||||||
|
},
|
||||||
|
"off": {
|
||||||
|
"16": "images/AKS_off_16.png",
|
||||||
|
"32": "images/AKS_off_32.png",
|
||||||
|
"48": "images/AKS_off_48.png",
|
||||||
|
"128": "images/AKS_off_128.png"
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,35 +0,0 @@
|
|||||||
/* Toggle the toolbar icon based on whether stickies are, or are not, set to
|
|
||||||
be killed on the current tab.
|
|
||||||
|
|
||||||
This listener receives a message from the content script (contentScript.js);
|
|
||||||
the content script actually determines what the settings for the current
|
|
||||||
tab are.
|
|
||||||
*/
|
|
||||||
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
|
|
||||||
if (typeof request.killingStickies != "undefined") {
|
|
||||||
let icons = request.killingStickies ? {
|
|
||||||
"16": "images/ASK_on_16.png",
|
|
||||||
"32": "images/ASK_on_32.png",
|
|
||||||
"48": "images/ASK_on_48.png",
|
|
||||||
"128": "images/ASK_on_128.png"
|
|
||||||
} : {
|
|
||||||
"16": "images/ASK_off_16.png",
|
|
||||||
"32": "images/ASK_off_32.png",
|
|
||||||
"48": "images/ASK_off_48.png",
|
|
||||||
"128": "images/ASK_off_128.png"
|
|
||||||
};
|
|
||||||
chrome.browserAction.setIcon({
|
|
||||||
path: icons,
|
|
||||||
tabId: request.tabID || sender.tab.id
|
|
||||||
});
|
|
||||||
} else if (typeof request.newBadgeText != "undefined") {
|
|
||||||
chrome.browserAction.setBadgeText({
|
|
||||||
tabId: sender.tab.id,
|
|
||||||
text: request.newBadgeText
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
chrome.browserAction.setBadgeBackgroundColor({
|
|
||||||
color: "#0071b3"
|
|
||||||
});
|
|
||||||
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 206 B After Width: | Height: | Size: 206 B |
|
Before Width: | Height: | Size: 338 B After Width: | Height: | Size: 338 B |
|
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
@ -20,17 +20,17 @@
|
|||||||
"default_popup": "popup.html",
|
"default_popup": "popup.html",
|
||||||
"default_title": "AlwaysKillSticky - Click the icon to control sticky-killing on this site!",
|
"default_title": "AlwaysKillSticky - Click the icon to control sticky-killing on this site!",
|
||||||
"default_icon": {
|
"default_icon": {
|
||||||
"16": "images/ASK_on_16.png",
|
"16": "images/AKS_on_16.png",
|
||||||
"32": "images/ASK_on_32.png",
|
"32": "images/AKS_on_32.png",
|
||||||
"48": "images/ASK_on_48.png",
|
"48": "images/AKS_on_48.png",
|
||||||
"128": "images/ASK_on_128.png"
|
"128": "images/AKS_on_128.png"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"icons": {
|
"icons": {
|
||||||
"16": "images/ASK_on_16.png",
|
"16": "images/AKS_on_16.png",
|
||||||
"32": "images/ASK_on_32.png",
|
"32": "images/AKS_on_32.png",
|
||||||
"48": "images/ASK_on_48.png",
|
"48": "images/AKS_on_48.png",
|
||||||
"128": "images/ASK_on_128.png"
|
"128": "images/AKS_on_128.png"
|
||||||
},
|
},
|
||||||
"options_page": "options.html"
|
"options_page": "options.html"
|
||||||
}
|
}
|
||||||
10
src/platform/firefox/action_icons.json
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"on": {
|
||||||
|
"19": "images/AKS_on_19.png",
|
||||||
|
"38": "images/AKS_on_38.png"
|
||||||
|
},
|
||||||
|
"off": {
|
||||||
|
"19": "images/AKS_off_19.png",
|
||||||
|
"38": "images/AKS_off_38.png"
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,31 +0,0 @@
|
|||||||
/* Toggle the toolbar icon based on whether stickies are, or are not, set to
|
|
||||||
be killed on the current tab.
|
|
||||||
|
|
||||||
This listener receives a message from the content script (contentScript.js);
|
|
||||||
the content script actually determines what the settings for the current
|
|
||||||
tab are.
|
|
||||||
*/
|
|
||||||
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
|
|
||||||
if (typeof request.killingStickies != "undefined") {
|
|
||||||
let icons = request.killingStickies ? {
|
|
||||||
"19": "images/ASK_on_19.png",
|
|
||||||
"38": "images/ASK_on_38.png",
|
|
||||||
} : {
|
|
||||||
"19": "images/ASK_off_19.png",
|
|
||||||
"38": "images/ASK_off_38.png",
|
|
||||||
};
|
|
||||||
chrome.browserAction.setIcon({
|
|
||||||
path: icons,
|
|
||||||
tabId: request.tabID || sender.tab.id
|
|
||||||
});
|
|
||||||
} else if (typeof request.newBadgeText != "undefined") {
|
|
||||||
chrome.browserAction.setBadgeText({
|
|
||||||
tabId: sender.tab.id,
|
|
||||||
text: request.newBadgeText
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
chrome.browserAction.setBadgeBackgroundColor({
|
|
||||||
color: "#0071b3"
|
|
||||||
});
|
|
||||||
|
Before Width: | Height: | Size: 277 B After Width: | Height: | Size: 277 B |
|
Before Width: | Height: | Size: 502 B After Width: | Height: | Size: 502 B |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.8 KiB |
@ -25,13 +25,13 @@
|
|||||||
"default_popup": "popup.html",
|
"default_popup": "popup.html",
|
||||||
"default_title": "AlwaysKillSticky - Click the icon to control sticky-killing on this site!",
|
"default_title": "AlwaysKillSticky - Click the icon to control sticky-killing on this site!",
|
||||||
"default_icon": {
|
"default_icon": {
|
||||||
"19": "images/ASK_on_19.png",
|
"19": "images/AKS_on_19.png",
|
||||||
"38": "images/ASK_on_38.png"
|
"38": "images/AKS_on_38.png"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"icons": {
|
"icons": {
|
||||||
"48": "images/ASK_on_48.png",
|
"48": "images/AKS_on_48.png",
|
||||||
"96": "images/ASK_on_96.png"
|
"96": "images/AKS_on_96.png"
|
||||||
},
|
},
|
||||||
"options_ui": {
|
"options_ui": {
|
||||||
"page": "options.html",
|
"page": "options.html",
|
||||||
|
|||||||