🏠 Home 

Discussions » Creation Requests

A "script" that wasn't even working anymore on firefox, fix needed for google chrome..

§
Posted: 16-02-2019
Edited: 17-02-2019

A "script" that wasn't even working anymore on firefox, fix needed for google chrome..

The actual issue:

if i click on the play icon on the left part of youtube screen in playlists, the play icon doesn't turn to a stop icon, & in fact the progress of passing from song to song never stops. & i need to be able to play one song at times only, & select play, when i want to hear everything:

Userscript code:

// ==UserScript==
// @version     1.0.6
// @name        Playlist Autoplay Control on YouTube
// @match       *://www.youtube.com/*
// @run-at      document-start
// @grant       none
// @noframes
// ==/UserScript==
(function () {
'use strict';
function injector(a, b) {
var injection = document.createElement(b);
document.head.appendChild(injection);
injection.textContent = a;
}
var styleSheet =
'#watch-appbar-playlist .yt-uix-button-icon-watch-appbar-autoplay-video-list\n' +
'{background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAMAAADXqc3KAAAAb1BMVEX///8AAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+hBK93AAAAJHRSTlMAAPT+sPxAEPcUSbmkAcWYHTWQK8+DJIKN+pcZoB+oJzC6OMQ+rrabAAAAY0lEQVQokbXQNw6AQBADwIMj55wz/v8b6RBI3g7cjrTBSn2c2HjnhioQAEgcAYAwFwCwSgGgo4YDYKcZB8ArfA6AWbsCtBS8jo7qh5Ett6eZnauXlT5obbSS/aAlnq9uH/BvLpzPEZ02MKzwAAAAAElFTkSuQmCC") no-repeat; width:24px; height:24px}',
core = function () {
function autoPlayControl(a) {
return function () {
var args = arguments;
if (!args[1] || window.localStorage.playlistAutoplay !== 'false' || (window.localStorage.playlistAutoplay === 'false' && args[1].feature && args[1].feature !== 'autoplay')) {
a.apply(this, arguments);
}
};
}
function detour(a) {
if (a.target.getAttribute('name') && a.target.getAttribute('name') === 'www/base') {
Object.keys(window._yt_www).some(function (b) {
if (typeof window._yt_www[b] === 'function' && window._yt_www[b].toString().indexOf('window.spf.navigate') !== -1) {
window._yt_www[b] = autoPlayControl(window._yt_www[b]);
return;
}
});
}
}
function buttonToggled(a) {
a = (window.chrome && a.target.parentNode) || a.target;
a.classList.toggle('yt-uix-button-toggled');
window.localStorage.playlistAutoplay = (window.localStorage.playlistAutoplay === 'true' && 'false') || 'true';
}
function insertButton() {
var playlistBar,
navControls,
spanWrapper,
spanIcon,
button = document.querySelector('[title="Autoplay"]');
if (location.href.indexOf('list=') !== -1 && !button) {
window.localStorage.playlistAutoplay = window.localStorage.playlistAutoplay || (window.localStorage.playlistAutoplay === undefined && 'false');
playlistBar = document.getElementById('watch-appbar-playlist');
navControls = document.querySelector('.playlist-nav-controls');
button = document.createElement('button');
button.title = 'Autoplay';
button.type = 'button';
button.className = 'yt-uix-button yt-uix-button-size-default yt-uix-button-player-controls yt-uix-button-empty yt-uix-button-has-icon autoplay-playlist yt-uix-button-opacity yt-uix-tooltip' + ((window.localStorage.playlistAutoplay === 'true' && ' yt-uix-button-toggled') || '');
button.setAttribute('data-tooltip-text', 'Autoplay');
spanWrapper = document.createElement('span');
spanWrapper.className = 'yt-uix-button-icon-wrapper';
spanIcon = document.createElement('span');
spanIcon.className = 'yt-uix-button-icon yt-uix-button-icon-watch-appbar-autoplay-video-list';
button.appendChild(spanWrapper);
button.appendChild(spanIcon);
navControls.appendChild(button);
button.addEventListener('click', buttonToggled);
playlistBar.className = playlistBar.className.replace('radio-playlist', '');
}
}
if (window.chrome) {
document.documentElement.addEventListener('load', detour, true);
} else {
window.addEventListener('afterscriptexecute', detour);
}
window.addEventListener('readystatechange', insertButton, true);
window.addEventListener('spfdone', insertButton);
};
injector('(' + core + ')()', 'script');
injector(styleSheet, 'style');
}());
§
Posted: 21-02-2019

i don't quit understand what you mean,if you mean to stop auto play when you change video in playlist i think i'm unable to help,this script seems out of date for current youtube either on page element or background script,especially there is nothing i can help on the inject of detour part,you'd better find the script author or others for help

§
Posted: 22-02-2019

noone else ? ((

Post reply

Sign in to post a reply.