Skip to content

Commit

Permalink
changed addon popup settings to dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreamlinerm committed Aug 24, 2022
1 parent 7e63667 commit 2035912
Show file tree
Hide file tree
Showing 9 changed files with 251 additions and 147 deletions.
4 changes: 4 additions & 0 deletions chrome/popup/settings.css
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ div {
display: flex;
justify-content: space-between;
}
.flex-end {
display: flex;
justify-content: flex-end;
}
.line,
h1,
h2,
Expand Down
134 changes: 83 additions & 51 deletions chrome/popup/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,70 +21,102 @@ <h2 class="title">Auto-skip</h2>
</div>
</div>
<div class="categoryPrime">
<h2>Prime Video Auto-skips:</h2>
<div class="line flex">
<p>Skip Intro:</p>
<!-- Rounded switch -->
<div class="flex flex-between" style="padding: 5px 0">
<h2>All Prime Video Auto-skips</h2>
<label class="switch">
<input type="checkbox" id="AmazonIntro" />
<input type="checkbox" id="AmazonSkips" />
<span class="slider round"></span>
</label>
</div>
<!-- <div class="line flex">
<p>Skip Recaps:</p>
<input class="checkbox AmazonRecap" id="AmazonRecap" type="checkbox" />
</div> -->
<div class="line flex">
<p>Skip Credits:</p>
<label class="switch">
<input type="checkbox" id="AmazonCredits" />
<span class="slider round"></span>
</label>
</div>
<div class="line flex">
<p>Skip Self Ads:</p>
<label class="switch">
<input type="checkbox" id="AmazonAds" />
<span class="slider round"></span>
</label>
<div class="line flex-end flex-align" id="openAmazonSettings">
<p id="openAmazonSettings">Individual settings:</p>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 20" height="1em" id="openAmazonSettings" class="AmazonDownArrow">
<path d="M0 0 40 0 20 20 0 0" fill="white" id="openAmazonSettings" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 20" height="1em" id="openAmazonSettings" class="AmazonUpArrow hidden">
<path d="M20 0 40 20 0 20 20 0" fill="white" id="openAmazonSettings" />
</svg>
</div>
<div class="line flex">
<p>Block Freevee Ads:</p>
<label class="switch">
<input type="checkbox" id="AmazonFreevee" />
<span class="slider round"></span>
</label>
<!-- show on click -->
<div id="AmazonSettings" style="display: none">
<div class="line flex">
<p>Skip Intro:</p>
<label class="switch">
<input type="checkbox" id="AmazonIntro" />
<span class="slider round"></span>
</label>
</div>
<div class="line flex">
<p>Skip Credits:</p>
<label class="switch">
<input type="checkbox" id="AmazonCredits" />
<span class="slider round"></span>
</label>
</div>
<div class="line flex">
<p>Skip Self Ads:</p>
<label class="switch">
<input type="checkbox" id="AmazonAds" />
<span class="slider round"></span>
</label>
</div>
<div class="line flex">
<p>Block Freevee Ads:</p>
<label class="switch">
<input type="checkbox" id="AmazonFreevee" />
<span class="slider round"></span>
</label>
</div>
</div>
</div>

<div class="categoryNetflix">
<h2>Netflix Auto-skips:</h2>
<div class="line flex">
<p>Skip Intro:</p>
<div class="flex flex-between" style="padding: 5px 0">
<h2>All Netflix Auto-skips</h2>
<label class="switch">
<input type="checkbox" id="NetflixIntro" />
<input type="checkbox" id="NetflixSkips" />
<span class="slider round"></span>
</label>
</div>
<div class="line flex">
<p>Skip Recaps:</p>
<label class="switch">
<input type="checkbox" id="NetflixRecap" />
<span class="slider round"></span>
</label>
</div>
<div class="line flex">
<p>Skip Credits:</p>
<label class="switch">
<input type="checkbox" id="NetflixCredits" />
<span class="slider round"></span>
</label>
<div class="line flex-end flex-align" id="openNetflixSettings">
<p id="openNetflixSettings">Individual settings:</p>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 20" height="1em" id="openNetflixSettings" class="NetflixDownArrow">
<path d="M0 0 40 0 20 20 0 0" fill="white" id="openNetflixSettings" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 20" height="1em" id="openNetflixSettings" class="NetflixUpArrow hidden">
<path d="M20 0 40 20 0 20 20 0" fill="white" id="openNetflixSettings" />
</svg>
</div>
<div class="line flex">
<p>Resume inactivity warning</p>
<label class="switch">
<input type="checkbox" id="NetflixBlocked" />
<span class="slider round"></span>
</label>
<!-- show on click -->
<div id="NetflixSettings" style="display: none">
<div class="line flex">
<p>Skip Intro:</p>
<label class="switch">
<input type="checkbox" id="NetflixIntro" />
<span class="slider round"></span>
</label>
</div>
<div class="line flex">
<p>Skip Recaps:</p>
<label class="switch">
<input type="checkbox" id="NetflixRecap" />
<span class="slider round"></span>
</label>
</div>
<div class="line flex">
<p>Skip Credits:</p>
<label class="switch">
<input type="checkbox" id="NetflixCredits" />
<span class="slider round"></span>
</label>
</div>
<div class="line flex">
<p>Resume inactivity warning</p>
<label class="switch">
<input type="checkbox" id="NetflixBlocked" />
<span class="slider round"></span>
</label>
</div>
</div>
</div>
<div class="button reset">Reset to default</div>
Expand Down
47 changes: 46 additions & 1 deletion chrome/popup/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,19 @@ chrome.storage.sync.onChanged.addListener(function (changes, namespace) {
}
});
function setCheckboxesToSettings() {
let button = document.querySelector("#AmazonIntro");
let button = document.querySelector("#AmazonSkips");
if (button) button.checked = settings?.Amazon.skipIntro && settings?.Amazon.skipCredits && settings?.Amazon.skipAd && settings?.Amazon.blockFreevee;
button = document.querySelector("#AmazonIntro");
if (button) button.checked = settings?.Amazon.skipIntro;
button = document.querySelector("#AmazonCredits");
if (button) button.checked = settings?.Amazon.skipCredits;
button = document.querySelector("#AmazonAds");
if (button) button.checked = settings?.Amazon.skipAd;
button = document.querySelector("#AmazonFreevee");
if (button) button.checked = settings?.Amazon.blockFreevee;

button = document.querySelector("#NetflixSkips");
if (button) button.checked = settings?.Netflix.skipIntro && settings?.Netflix.skipRecap && settings?.Netflix.skipCredits && settings?.Netflix.skipBlocked;
button = document.querySelector("#NetflixIntro");
if (button) button.checked = settings?.Netflix.skipIntro;
button = document.querySelector("#NetflixRecap");
Expand All @@ -51,6 +56,25 @@ function listenForClicks() {
if (e.target.classList.contains("reset")) {
console.log("settings resetted to", defaultSettings);
chrome.storage.sync.set(defaultSettings, function () {});
} else if (e.target.id === "AmazonSkips") {
const AmazonSkips = !(settings.Amazon.skipIntro && settings.Amazon.skipCredits && settings.Amazon.skipAd && settings.Amazon.blockFreevee);
settings.Amazon.skipIntro = AmazonSkips;
settings.Amazon.skipCredits = AmazonSkips;
settings.Amazon.skipAd = AmazonSkips;
settings.Amazon.blockFreevee = AmazonSkips;
console.log("settings.AmazonSkips", settings);
chrome.storage.sync.set({ settings: settings }, function () {});
} else if (e.target.id === "openAmazonSettings") {
let AmazonSettings = document.getElementById("AmazonSettings");
if (AmazonSettings.style.display === "none") {
AmazonSettings.style.display = "block";
document.getElementsByClassName("AmazonDownArrow")[0].style.display = "none";
document.getElementsByClassName("AmazonUpArrow")[0].style.display = "block";
} else {
AmazonSettings.style.display = "none";
document.getElementsByClassName("AmazonDownArrow")[0].style.display = "block";
document.getElementsByClassName("AmazonUpArrow")[0].style.display = "none";
}
} else if (e.target.id === "AmazonCredits") {
settings.Amazon.skipCredits = !settings.Amazon.skipCredits;
console.log("settings.AmazonCredits", settings);
Expand All @@ -67,6 +91,27 @@ function listenForClicks() {
settings.Amazon.blockFreevee = !settings.Amazon.blockFreevee;
console.log("settings.blockFreevee", settings);
chrome.storage.sync.set({ settings: settings }, function () {});
}
// ------------- Netflix ---------------------------------------
else if (e.target.id === "NetflixSkips") {
const NetflixSkips = !(settings.Netflix.skipIntro && settings.Netflix.skipRecap && settings.Netflix.skipCredits && settings.Netflix.skipBlocked);
settings.Netflix.skipIntro = NetflixSkips;
settings.Netflix.skipRecap = NetflixSkips;
settings.Netflix.skipCredits = NetflixSkips;
settings.Netflix.skipBlocked = NetflixSkips;
console.log("settings.NetflixSkips", settings);
chrome.storage.sync.set({ settings: settings }, function () {});
} else if (e.target.id === "openNetflixSettings") {
let NetflixSettings = document.getElementById("NetflixSettings");
if (NetflixSettings.style.display == "none") {
NetflixSettings.style.display = "block";
document.getElementsByClassName("NetflixDownArrow")[0].style.display = "none";
document.getElementsByClassName("NetflixUpArrow")[0].style.display = "block";
} else {
NetflixSettings.style.display = "none";
document.getElementsByClassName("NetflixDownArrow")[0].style.display = "block";
document.getElementsByClassName("NetflixUpArrow")[0].style.display = "none";
}
} else if (e.target.id === "NetflixIntro") {
settings.Netflix.skipIntro = !settings.Netflix.skipIntro;
console.log("settings.NetflixIntro", settings);
Expand Down
14 changes: 3 additions & 11 deletions chrome/skipper.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ if (isVideo || isNetflix) {
// adTimeText.textContent.length > 7 so it doesn't try to skip when the self ad is playing
// !document.querySelector(".fu4rd6c.f1cw2swo") so it doesn't try to skip when the self ad is playing
if (!document.querySelector(".fu4rd6c.f1cw2swo") && video != null && adTimeText != null && lastAdTimeText != adTimeText.textContent) {
console.log("FreeVee Ad skipped", adTimeText.textContent);
console.log("FreeVee Ad skipped|", adTimeText.textContent);
lastAdTimeText = adTimeText.textContent;
resetLastATimeText();
video.currentTime += parseInt(adTimeText.textContent.match(/\d+/)[0]);
Expand Down Expand Up @@ -221,7 +221,7 @@ if (isVideo || isNetflix) {
async function Amazon_AdTimeout() {
// set loop every 1 sec and check if ad is there
setInterval(function () {
// if infobar is shown
// if video is shown
if (getComputedStyle(document.querySelector("#dv-web-player")).display != "none") {
let button = document.querySelector(".fu4rd6c.f1cw2swo");
if (button) {
Expand All @@ -245,7 +245,7 @@ if (isVideo || isNetflix) {
}
NetflixSkipIntroObserver.observe(document, NetflixConfig);
} else {
console.log("stopped observing | intro");
console.log("stopped observing| intro");
NetflixSkipIntroObserver.disconnect();
}
}
Expand Down Expand Up @@ -339,14 +339,6 @@ if (isVideo || isNetflix) {
async function startAmazonBlockFreeveeObserver() {
if (settings.Amazon.blockFreevee === undefined || settings.Amazon.blockFreevee) {
console.log("started observing| FreeVee Ad");
let video = document.querySelector("#dv-web-player > div > div:nth-child(1) > div > div > div.scalingVideoContainer > div.scalingVideoContainerBottom > div > video");
let adTimeText = document.querySelector(".atvwebplayersdk-adtimeindicator-text");
if (!document.querySelector(".fu4rd6c.f1cw2swo") && video != null && adTimeText != null) {
lastAdTimeText = adTimeText.textContent;
resetLastATimeText();
video.currentTime += parseInt(adTimeText.textContent.match(/\d+/)[0]);
console.log("FreeVee Ad skipped", adTimeText, video);
}
AmazonFreeVeeObserver.observe(document, FreeVeeConfig);
} else {
console.log("stopped observing| FreeVee Ad");
Expand Down
Binary file not shown.
Loading

0 comments on commit 2035912

Please sign in to comment.