Skip to content

Commit

Permalink
Merge pull request #46 from bestpika/dev/@bestpika
Browse files Browse the repository at this point in the history
Add whitelist mode (#45). Support s.team/a/{appid} (#33).
  • Loading branch information
Revadike authored Mar 13, 2021
2 parents d3b5834 + 0ac01df commit ab1b068
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
24 changes: 15 additions & 9 deletions Steam Web Integration.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
// @contributor Black3ird
// @contributor Lex
// @contributor Luckz
// @contributor 観月唯
// @description Check every web page for game, dlc and package links to the steam store and mark using icons whether it's owned, unowned, wishlisted, ignored (not interested), DLC, removed/delisted (decommissioned), has low confidence metric, has cards, or is bundled.
// @downloadURL https://github.com/Revadike/SteamWebIntegration/raw/master/Steam%20Web%20Integration.user.js
// @exclude /^https?\:\/\/(.+.steampowered|steamcommunity).com\/(?!groups\/groupbuys).*/
Expand All @@ -28,7 +29,7 @@
// @run-at document-start
// @supportURL https://github.com/Revadike/SteamWebIntegration/issues/
// @updateURL https://github.com/Revadike/SteamWebIntegration/raw/master/Steam%20Web%20Integration.user.js
// @version 1.9.8
// @version 1.10.0
// ==/UserScript==

// ==Code==
Expand Down Expand Up @@ -317,13 +318,13 @@ function refreshBundles(callback) {
function doApp(elem, wishlist, ownedApps, ignoredApps, decommissioned, limited, cards, bundles, dlc, lcs, dlcs, dlclcs, llcs, clcs, blcs) {
$(elem).addClass(`swi`);

const attr = settings.attributes.find((a) => /apps?\/[0-9]+/g.test($(elem).attr(a)));
const attr = settings.attributes.find((a) => /a(pps?)?\/[0-9]+/g.test($(elem).attr(a)));
if (!attr) {
return;
}

const attrVal = $(elem).attr(attr);
const appID = parseInt(attrVal.match(/apps?\/[0-9]+/g)[0].split(/apps?\//)[1], 10);
const appID = parseInt(attrVal.match(/a(?:pps?)?\/[0-9]+/g)[0].split(/a(?:pps?)?\//)[1], 10);
if (Number.isNaN(appID)) {
return;
}
Expand Down Expand Up @@ -437,6 +438,7 @@ function integrate(userdata, decommissioned, cards, bundles, limited, dlc, lastC
`[href*="steamdb.info/app/"]`,
`[href*="store.steampowered.com/agecheck/app/"]`,
`[href*="store.steampowered.com/app/"]`,
`[href*="s.team/a/"]`,
`[style*="cdn.akamai.steamstatic.com/steam/apps/"]`,
`[style*="cdn.edgecast.steamstatic.com/steam/apps/"]`,
`[style*="steamcdn-a.akamaihd.net/steam/apps/"]`,
Expand Down Expand Up @@ -582,6 +584,7 @@ function init() {
"wantDLC": true,
"wantIgnores": true,
"wantLimited": true,
"whiteListMode": false,
"wishlistColor": `#ff69b4`,
"wishlistIcon": `❤`
};
Expand Down Expand Up @@ -621,13 +624,16 @@ function init() {
unsafeWindow.scriptInfo = GM_info.script;
unsafeWindow.settings = settings;
$(document).ready(displaySettings);
} else if (!settings.blackList.split(`\n`).find((url) => unsafeWindow.location.href.includes(url.trim()))) {
boxNode = createBoxNode();
GM_addStyle(stylesheet);
GM_registerMenuCommand(`Change settings`, () => unsafeWindow.open(settingsuri, `_blank`));
refresh();
} else {
const matchUrl = settings.blackList.split(`\n`).find((url) => unsafeWindow.location.href.includes(url.trim()))
if ((settings.whiteListMode && matchUrl) || (!settings.whiteListMode && !matchUrl)) {
boxNode = createBoxNode();
GM_addStyle(stylesheet);
GM_registerMenuCommand(`Change settings`, () => unsafeWindow.open(settingsuri, `_blank`));
refresh();
}
}
}

init();
// ==/Code==
// ==/Code==
13 changes: 9 additions & 4 deletions settings/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#snackbar.show {
visibility: visible;
/* Show the snackbar */
/* Add animation: Take 0.5 seconds to fade in and out the snackbar.
/* Add animation: Take 0.5 seconds to fade in and out the snackbar.
However, delay the fade out process for 2.5 seconds */
-webkit-animation: fadein 0.5s, fadeout 0.5s 2.5s;
animation: fadein 0.5s, fadeout 0.5s 2.5s;
Expand Down Expand Up @@ -197,6 +197,11 @@ <h1 id="title"></h1>
<td>Enter a list of domains you don't want this script running on.</td>
<td><textarea id="blackList" name="blackList" onchange="onChange(this)" cols="30" rows="5"></textarea></td>
</tr>
<tr id="whiteListModeRow">
<td><b>whiteListMode</b></td>
<td>Reverse the black list to the white list.</td>
<td><input id="whiteListMode" name="whiteListMode" type="checkbox" onclick="onChange(this)"></td>
</tr>
<tr id="dynamicContentRow">
<td><b>dynamicContent</b></td>
<td>Select which method you prefer to detect dynamically loaded web content.</td>
Expand All @@ -209,7 +214,7 @@ <h1 id="title"></h1>
<tr id="prefixRow">
<td><b>prefix</b></td>
<td>Prefix (checked) instead of suffix (unchecked) position icon.</td>
<td><input id="prefix" name="prefix" false="" type="checkbox" onclick="onChange(this)"></td>
<td><input id="prefix" name="prefix" type="checkbox" onclick="onChange(this)"></td>
</tr>
<tr id="boxedRow">
<td><b>boxed</b></td>
Expand Down Expand Up @@ -426,12 +431,12 @@ <h1 id="title"></h1>
<tr id="dateOverrideRow">
<td><b>dateOverride</b></td>
<td>Force date display in the YYYY-MM-DD HH:MM:SS style; otherwise matches system locale.</td>
<td><input id="dateOverride" name="dateOverride" false="" type="checkbox" onclick="onChange(this)"></td>
<td><input id="dateOverride" name="dateOverride" type="checkbox" onclick="onChange(this)"></td>
</tr>
</tbody>
</table>
</form>
</div>
</body>

</html>
</html>

0 comments on commit ab1b068

Please sign in to comment.