Added ratechange blocklist to fix #72 #521 and #584

This commit is contained in:
Chad Bailey
2020-03-01 21:42:23 -06:00
parent 5a53f81cba
commit 9b8f9dfbae
4 changed files with 122 additions and 28 deletions

View File

@@ -23,6 +23,11 @@ var tcDefaults = {
vine.co
imgur.com
teams.microsoft.com
`.replace(regStrip, ""),
blacklistrc: `\
twitch.tv
pluralsight.com
teamtreehouse.com
`.replace(regStrip, "")
};
@@ -191,7 +196,25 @@ function validate() {
var regexp = new RegExp(match);
} catch (err) {
status.textContent =
"Error: Invalid Regex: " + match + ". Unable to save";
"Error: Invalid blacklist regex: " + match + ". Unable to save";
valid = false;
return;
}
}
});
document
.getElementById("blacklistrc")
.value.split("\n")
.forEach(match => {
match = match.replace(regStrip, "");
if (match.startsWith("/")) {
try {
var regexp = new RegExp(match);
} catch (err) {
status.textContent =
"Error: Invalid ratechange blacklist regex: " +
match +
". Unable to save";
valid = false;
return;
}
@@ -216,6 +239,7 @@ function save_options() {
var startHidden = document.getElementById("startHidden").checked;
var controllerOpacity = document.getElementById("controllerOpacity").value;
var blacklist = document.getElementById("blacklist").value;
var blacklistrc = document.getElementById("blacklistrc").value;
chrome.storage.sync.remove([
"resetSpeed",
@@ -238,7 +262,8 @@ function save_options() {
startHidden: startHidden,
controllerOpacity: controllerOpacity,
keyBindings: keyBindings,
blacklist: blacklist.replace(regStrip, "")
blacklist: blacklist.replace(regStrip, ""),
blacklistrc: blacklistrc.replace(regStrip, "")
},
function() {
// Update status to let user know options were saved.
@@ -261,6 +286,7 @@ function restore_options() {
document.getElementById("controllerOpacity").value =
storage.controllerOpacity;
document.getElementById("blacklist").value = storage.blacklist;
document.getElementById("blacklistrc").value = storage.blacklistrc;
// ensure that there is a "display" binding for upgrades from versions that had it as a separate binding
if (storage.keyBindings.filter(x => x.action == "display").length == 0) {