From 0fc36cfd255659d4e83b6e3b1f20862c57be2363 Mon Sep 17 00:00:00 2001
From: Civati Danilo
+ Excluded channels +
Type below the channels you want to support through ads. Use ";" to separate the channels.
+ Example: twitchrivals;twitchgaming;twitchpresents
Whenever you change a setting, you have to reload the Twitch tab(s).
Ads blocked for a total of .
diff --git a/chrome/popup/popupjs.js b/chrome/popup/popupjs.js
index e1b247c..400d178 100644
--- a/chrome/popup/popupjs.js
+++ b/chrome/popup/popupjs.js
@@ -10,8 +10,10 @@ var forcedQuality = document.querySelector('select[name=dropdown_forced_quality]
var proxy = document.querySelector('select[name=dropdown_proxy]');
var proxyQuality = document.querySelector('select[name=dropdown_proxy_quality]');
var adTime = document.querySelector('#ad_time');
+var excludedChannels = document.querySelector('textarea[name=excluded_channels]');
-var allSettingsElements = [onOff,blockingMessage,forcedQuality,proxy,proxyQuality];
+
+var allSettingsElements = [onOff,blockingMessage,forcedQuality,proxy,proxyQuality,excludedChannels];
for (var i = 0; i < allSettingsElements.length; i++) {
if (allSettingsElements[i]) {
@@ -27,6 +29,7 @@ function saveOptions() {
//chrome.storage.local.set({forcedQualityTTV: forcedQuality.options[forcedQuality.selectedIndex].text});
chrome.storage.local.set({proxyTTV: proxy.options[proxy.selectedIndex].text});
chrome.storage.local.set({proxyQualityTTV: proxyQuality.options[proxyQuality.selectedIndex].text});
+ chrome.storage.local.set({excludedChannelsTTV: excludedChannels.value.replace(/\r?\n|\r|\s/g, "").split(";")});
}
function restoreOptions() {
@@ -36,6 +39,7 @@ function restoreOptions() {
restoreDropdown('proxyTTV', proxy);
restoreDropdown('proxyQualityTTV', proxyQuality);
restoreAdtime('adTimeTTV', adTime);
+ restoreTextArray('excludedChannelsTTV', excludedChannels, ';');
}
function restoreToggle(name, toggle) {
@@ -68,4 +72,13 @@ function restoreAdtime(name, container) {
});
}
+function restoreTextArray(name, textArea, separator) {
+ chrome.storage.local.get([name], function(result) {
+ var loadedArray = result[name];
+ if (loadedArray.length !== 0) {
+ textArea.value = loadedArray.join(separator);
+ }
+ });
+}
+
document.addEventListener('DOMContentLoaded', restoreOptions);
\ No newline at end of file
diff --git a/chrome/remove_video_ads.js b/chrome/remove_video_ads.js
index 0309993..b8a8453 100644
--- a/chrome/remove_video_ads.js
+++ b/chrome/remove_video_ads.js
@@ -81,7 +81,8 @@ var TwitchAdblockSettings = {
ForcedQuality: null,
ProxyType: null,
ProxyQuality: null,
- AdTime: 0
+ AdTime: 0,
+ ExcludedChannels: []
};
var twitchMainWorker = null;
@@ -312,13 +313,14 @@ function hookWorkerFetch() {
var responseText = await response.text();
var weaverText = null;
+ console.log(TwitchAdblockSettings);
- weaverText = await processM3U8(url, responseText, realFetch, PlayerType2);
+ weaverText = await processM3U8(url, responseText, realFetch, PlayerType2, TwitchAdblockSettings.ExcludedChannels);
if (weaverText.includes(AdSignifier)) {
- weaverText = await processM3U8(url, responseText, realFetch, PlayerType3);
+ weaverText = await processM3U8(url, responseText, realFetch, PlayerType3, TwitchAdblockSettings.ExcludedChannels);
}
if (weaverText.includes(AdSignifier)) {
- weaverText = await processM3U8(url, responseText, realFetch, PlayerType4);
+ weaverText = await processM3U8(url, responseText, realFetch, PlayerType4, TwitchAdblockSettings.ExcludedChannels);
}
resolve(new Response(weaverText));
@@ -497,7 +499,7 @@ function stripUnusedParams(str, params) {
return tempUrl.pathname.substring(1) + tempUrl.search;
}
-async function processM3U8(url, textStr, realFetch, playerType) {
+async function processM3U8(url, textStr, realFetch, playerType, excludedChannels) {
//Checks the m3u8 for ads and if it finds one, instead returns an ad-free stream.
var streamInfo = StreamInfosByUrl[url];
@@ -510,6 +512,11 @@ async function processM3U8(url, textStr, realFetch, playerType) {
if (!textStr) {
return textStr;
}
+
+ // Channel is excluded by user: ads are visible.
+ if (excludedChannels.includes(streamInfo.ChannelName)) {
+ return textStr;
+ }
//Some live streams use mp4.
if (!textStr.includes('.ts') && !textStr.includes('.mp4')) {
From 5357800593f509d6c4a451a77f2132631b95bfa8 Mon Sep 17 00:00:00 2001
From: Civati Danilo