Greasy Fork is available in English.
Autoplay für SerienStream.to
当前为
// ==UserScript==
// @name s.to autoplay
// @namespace https://github.com/zaheer-exe
// @version 8
// @description Autoplay für SerienStream.to
// @author zaheer-exe
// @match https://s.to/*
// @match https://serienstream.to/*
// @match https://aniworld.to/*
// @match https://voe.sx/*
// @match *://*/*
// @grant GM_xmlhttpRequest
// @icon https://www.google.com/s2/favicons?sz=64&domain=s.to
// @license Apache License
// @grant none
// ==/UserScript==
////////// LISTER ////////////////////////////////////////////////////////////////
const sToHosts = ['s.to', 'aniworld.to', 'serienstream.to'];
if (sToHosts.includes(new URL(window.location.href).hostname)) {
function nextEpisode() {
const episodeMenuCurrentELem = document.querySelector('li a.active[href*="episode"]');
episodeMenuCurrentELem.classList.remove('active');
const nextEpisodeUrl = episodeMenuCurrentELem.parentElement.nextElementSibling.querySelector('a');
var xmlHttp = new XMLHttpRequest();
xmlHttp.open( "GET", nextEpisodeUrl, false );
xmlHttp.send(null);
let temp = document.createElement('div')
temp.innerHTML=xmlHttp.responseText;
let tempElem = temp.querySelector('.watchEpisode .icon.VOE')
let url = tempElem.parentElement.href
let title = temp.querySelector(".hosterSiteTitle").innerHTML;
document.querySelector(".inSiteWebStream iframe").src = url;
document.querySelector(".hosterSiteTitle").innerHTML = title;
episodeMenuCurrentELem.classList.remove('active');
nextEpisodeUrl.classList.add('active');
}
window.addEventListener("message", (event) => {
if(typeof event.data === "string" && event.data.startsWith("autoplay")) {
const parsed = event.data.split("$");
console.log("event", parsed);
switch (parsed[1]) {
case "url": {
console.log("S: url");
let streamIframe = document.querySelector(".inSiteWebStream iframe");
if (streamIframe.src.includes("/redirect")) {
document.querySelector(".inSiteWebStream iframe").src = parsed[2];
}
break;
}
case "end": {
console.log("S: ended");
nextEpisode();
}
}
}
}, false);
document.querySelector(".inSiteWebStream iframe").allow="autoplay; fullscreen; picture-in-picture; xr-spatial-tracking; clipboard-write";
}
////////// HOSTER ////////////////////////////////////////////////////////////////
let checkIfVoe = document.querySelector("head > meta[name='og:sitename']");
if (checkIfVoe && checkIfVoe.content == "VOE: Video Hosting Platform & Online Cloud Storage") {
window.parent.postMessage("autoplay$url$" + window.location.href, '*');
document.querySelector("video").play();
document.querySelector("video").addEventListener("ended", () => {
console.log("VEO: ended");
window.parent.postMessage("autoplay$end", "*");
});
}