Skip to content

Commit

Permalink
add wildcard to disqus json blob, add support for handling wildcard i…
Browse files Browse the repository at this point in the history
…n getWidgetList
  • Loading branch information
ablanathtanalba committed Jun 17, 2020
1 parent d995690 commit 9246104
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions src/js/webrequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -607,28 +607,30 @@ let getWidgetList = (function () {
continue;
}
let replace = widget.domains.some(domain => {
// checks for wildcard in domain
// handles wildcard placeholders for subdomains like *.disqus.com
if (domain[0] == "*") {
// reduce wildcard domain from "*.domain" to "domain"
domain = domain.slice(2);
if (!tabData.origins.hasOwnProperty(domain)) {
return false;
// reduce wildcard domain from "*.domain" to "domain" to easily compare in tabData
domain = domain.slice(1);

// returns the actions for any tabData origins that match the wildcard subdomain
for (let origin in tabData.origins) {
if (origin.endsWith(domain)) {
let action = tabData.origins[origin];
return (
action == constants.BLOCK ||
action == constants.USER_BLOCK
);
}
}
const action = tabData.origins[domain];
return (
action == constants.BLOCK ||
action == constants.USER_BLOCK
);
} else {
if (!tabData.origins.hasOwnProperty(domain)) {
return false;
}
const action = tabData.origins[domain];
return (
action == constants.BLOCK ||
action == constants.USER_BLOCK
);
}
if (!tabData.origins.hasOwnProperty(domain)) {
return false;
}
const action = tabData.origins[domain];
return (
action == constants.BLOCK ||
action == constants.USER_BLOCK
);
});
if (replace) {
widgetsToReplace[widget.name] = true;
Expand Down

0 comments on commit 9246104

Please sign in to comment.