mirror of
https://github.com/lawrencehook/remove-youtube-suggestions.git
synced 2026-07-25 06:54:31 +00:00
Add an option to disable autoplay for playlists
This commit is contained in:
@@ -134,6 +134,11 @@ const SECTIONS = [
|
||||
id: "disable_autoplay",
|
||||
defaultValue: true
|
||||
},
|
||||
{
|
||||
name: "Disable autoplay for playlists",
|
||||
id: "disable_playlist_autoplay",
|
||||
defaultValue: true
|
||||
},
|
||||
{
|
||||
name: "Redirect shorts to the default viewer",
|
||||
tags: "Redirects, Basic",
|
||||
@@ -381,6 +386,7 @@ browser.runtime.onMessage.addListener((data, sender) => {
|
||||
const { frameId, tab } = sender;
|
||||
browser.storage.local.get(localSettings => {
|
||||
const settings = { ...DEFAULT_SETTINGS, ...localSettings };
|
||||
|
||||
browser.tabs.sendMessage(tab.id, { settings }, {});
|
||||
|
||||
// Gray out browserAction
|
||||
|
||||
@@ -56,11 +56,9 @@ document.addEventListener("DOMContentLoaded", event => {
|
||||
counter = 0;
|
||||
theaterClicked = false;
|
||||
hyper = false;
|
||||
originalPlayback = undefined;
|
||||
originalMuted = undefined;
|
||||
onResultsPage = resultsPageRegex.test(location.href);
|
||||
|
||||
requestRunDynamicSettings()
|
||||
handleNewPage();
|
||||
});
|
||||
|
||||
// let lastRun = Date.now();
|
||||
@@ -83,10 +81,8 @@ function runDynamicSettings() {
|
||||
url = location.href;
|
||||
theaterClicked = false;
|
||||
hyper = false;
|
||||
originalPlayback = undefined;
|
||||
originalMuted = undefined;
|
||||
onResultsPage = resultsPageRegex.test(location.href);
|
||||
handleUrlChange();
|
||||
handleNewPage();
|
||||
}
|
||||
|
||||
// Mark the left nav bar sections
|
||||
@@ -246,7 +242,34 @@ function runDynamicSettings() {
|
||||
}
|
||||
|
||||
|
||||
function handleUrlChange() {
|
||||
function injectScripts() {
|
||||
|
||||
// Disable playlist autoplay
|
||||
if (cache['disable_playlist_autoplay']) {
|
||||
const existingScript = document.querySelector('script[id="disable_playlist_autoplay"]')
|
||||
if (existingScript) return;
|
||||
|
||||
const script = document.createElement("script");
|
||||
script.id = 'disable_playlist_autoplay';
|
||||
script.type = "text/javascript";
|
||||
script.innerText = `
|
||||
(function() {
|
||||
let pm;
|
||||
function f() {
|
||||
if (!pm) pm = document.querySelector('yt-playlist-manager');
|
||||
if (pm) pm.canAutoAdvance_ = false;
|
||||
}
|
||||
f();
|
||||
setInterval(f, 100);
|
||||
})()
|
||||
`;
|
||||
document.body?.appendChild(script);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function handleNewPage() {
|
||||
if (cache['global_enable'] !== true) return;
|
||||
|
||||
dynamicIters = 0;
|
||||
@@ -275,6 +298,7 @@ function handleUrlChange() {
|
||||
location.replace(newUrl);
|
||||
}
|
||||
|
||||
injectScripts();
|
||||
requestRunDynamicSettings();
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
"description": "Spend less time on YouTube. Customize YouTube's user interface to be less engaging.",
|
||||
"homepage_url": "https://github.com/lawrencehook/remove-youtube-suggestions",
|
||||
"manifest_version": 2,
|
||||
"version": "4.3.14",
|
||||
"version": "4.3.15",
|
||||
|
||||
"icons": {
|
||||
"16": "images/16.png",
|
||||
|
||||
Reference in New Issue
Block a user