Skip to content

Commit 29216c1

Browse files
committed
V2.2.0
1 parent 3c10bf5 commit 29216c1

File tree

5 files changed

+35
-10
lines changed

5 files changed

+35
-10
lines changed

manifest.chromium.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "Steam Web Integration",
33
"description": "Integrate your personal Steam information on the web, at your convenience!.",
44
"homepage_url": "https://github.com/revadike/steamwebintegration",
5-
"version": "2.1.1",
5+
"version": "2.2.0",
66
"author": "Revadike",
77
"manifest_version": 3,
88
"action": {

manifest.firefox.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "Steam Web Integration",
33
"description": "Integrate your personal Steam information on the web, at your convenience!.",
44
"homepage_url": "https://github.com/revadike/steamwebintegration",
5-
"version": "2.1.1",
5+
"version": "2.2.0",
66
"author": "Revadike",
77
"browser_specific_settings": {
88
"gecko": {

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
{
22
"name": "steamwebintegration",
3-
"version": "2.1.1",
3+
"version": "2.2.0",
44
"description": "Integrate your personal Steam information on the web, at your convenience!",
55
"main": "manifest.json",
66
"type": "module",
77
"scripts": {
88
"test": "echo \"Error: no test specified\" && exit 1",
99
"build": "mkdir build || cp manifest.json build/manifest.json && cp popup.html build/popup.html && cp LICENSE build/LICENSE && cp -r --parents images build && cp -r --parents css build && cp -r --parents webfonts build && cp -r --parents scripts build",
1010
"build:firefox": "cp manifest.firefox.json manifest.json",
11+
"build:firefox:zip": "mkdir bin || npm run build:firefox && npm run build && (cd build && zip -1 -r ../bin/steamwebintegration-firefox.zip .) && npm run build:clear",
1112
"build:chromium": "cp manifest.chromium.json manifest.json",
13+
"build:chromium:zip": "mkdir bin || npm run build:chromium && npm run build && (cd build && zip -1 -r ../bin/steamwebintegration-chrome.zip .) && npm run build:clear",
1214
"build:xpi": "mkdir bin || npm run build:firefox && npm run build && (cd build && zip -1 -r ../bin/steamwebintegration.xpi .) && npm run build:clear",
1315
"build:crx": "mkdir bin || npm run build:chromium && npm run build && crx pack build -o bin/steamwebintegration.crx -p bin/steamwebintegration.pem && npm run build:clear",
1416
"build:all": "npm run build:crx && npm run build:xpi",

scripts/background.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ async function getFromStorage(key, defaultValue) {
55
return response[key];
66
}
77

8-
async function getSettings() {
8+
async function getSettings(newSettings = {}) {
99
const defaults = {
1010
"attributes": ["href", "src", "style"],
1111
"blackList": "https://store.steampowered.com/\nhttps://steamcommunity.com/",
@@ -26,7 +26,7 @@ async function getSettings() {
2626
"dlcColor": "#a655b2",
2727
"dlcIcon": "download",
2828
"dlcRefreshInterval": 1440,
29-
"dynamicContent": "disabled",
29+
"dynamicContent": "ping",
3030
"followedColor": "#f7dc6f",
3131
"followedIcon": "star",
3232
"iconsBold": false,
@@ -66,6 +66,18 @@ async function getSettings() {
6666
return settings;
6767
}
6868

69+
async function addToBlacklist(url) {
70+
let settings = await getSettings();
71+
let uri = new URL(url);
72+
settings.blackList = [
73+
...new Set(
74+
[...settings.blackList.split("\n"), uri.host],
75+
),
76+
].join("\n");
77+
78+
await chrome.storage.local.set({ "swi_settings": settings });
79+
}
80+
6981
function arrayToObject(array, key) {
7082
if (!key) {
7183
return array.reduce((obj, item) => Object.assign(obj, { [item]: 1 }), {});
@@ -277,6 +289,9 @@ chrome.contextMenus.onClicked.addListener((info, tab) => {
277289
case "clear-swi":
278290
chrome.tabs.sendMessage(tab.id, { "action": "clearSWI" });
279291
break;
292+
case "add-to-blacklist":
293+
addToBlacklist(tab.url);
294+
break;
280295
default:
281296
break;
282297
}
@@ -296,3 +311,8 @@ chrome.contextMenus.create({
296311
"title": "Clear",
297312
"contexts": ["page"],
298313
});
314+
chrome.contextMenus.create({
315+
"id": "add-to-blacklist",
316+
"title": "Add to whitelist/blacklist",
317+
"contexts": ["page"],
318+
});

scripts/content.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -318,16 +318,19 @@ function integrate(settings, userdata, decommissioned, cards, bundles, limited,
318318
"attributes": true,
319319
"attributeFilter": settings.attributes,
320320
});
321-
} else if (settings.dynamicContent === "ping") {
322-
pinger = setInterval(doSWI, settings.pingInterval);
323321
}
324322
};
325323

326-
if (document.readyState === "complete" || document.readyState === "loaded") {
327-
setupSWI();
324+
if (settings.dynamicContent === "ping") {
325+
pinger = setInterval(doSWI, settings.pingInterval, 0);
326+
return;
328327
}
329328

330-
document.addEventListener("DOMContentLoaded", setupSWI);
329+
if (document.readyState === "complete" || document.readyState === "interactive") {
330+
setupSWI();
331+
} else {
332+
document.addEventListener("DOMContentLoaded", setupSWI);
333+
}
331334
}
332335

333336
function addStylesheet(url) {

0 commit comments

Comments
 (0)