Greasy Fork is available in English.
Autoplay für SerienStream.to
当前为
// ==UserScript==
// @name s.to autoplay
// @namespace https://github.com/zaheer-exe
// @version 8.1
// @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)) {
let isAutoPlayed = false;
function nextEpisode() {
const currentLang = document.querySelector("img.selectedLanguage").dataset.langKey;
console.log("S: current lang ", currentLang);
const episodeMenuCurrentELem = document.querySelector('li a.active[href*="episode"]');
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 url = temp.querySelector('li[data-lang-key="' + currentLang + '"] .watchEpisode .icon.VOE').parentElement.href;
let title = temp.querySelector(".hosterSiteTitle").innerHTML;
document.querySelector(".inSiteWebStream iframe").src = url;
document.querySelector(".hosterSiteTitle").innerHTML = title;
document.querySelector(".breadCrumbMenu").innerHTML = temp.querySelector(".breadCrumbMenu").innerHTML;
episodeMenuCurrentELem.classList.remove('active');
nextEpisodeUrl.classList.add('active');
episodeMenuCurrentELem.classList.remove('active');
if (!isAutoPlayed) {
disableElements();
isAutoPlayed = true;
}
}
function disableElements() {
const style = document.createElement('style');
style.textContent = `
.changeLanguage, li[data-link-target] {
opacity: 0.3;
cursor: none;
}
.changeLanguageBox, li[data-link-target] > .generateInlinePlayer {
pointer-events: none;
}
.tooltip {
position: absolute;
background-color: #333; /* Dark background for contrast */
color: #fff; /* White text for contrast */
padding: 10px; /* Padding for better appearance */
border-radius: 5px; /* Rounded corners */
font-size: 14px; /* Font size for readability */
line-height: 1.4; /* Line height for better text readability */
white-space: nowrap; /* Prevent text wrapping */
display: none; /* Hidden by default */
z-index: 9999; /* Ensure it appears above other content */
pointer-events: none; /* Ensure it doesn't interfere with interactions */
transform: translate(-50%, -50%); /* Center tooltip on the cursor */
}
`;
document.head.appendChild(style);
const tooltip = document.createElement('div');
tooltip.className = 'tooltip';
tooltip.textContent = 'Autoplay enabled. Refresh/Reload Page to change settings.';
document.body.appendChild(tooltip);
function updateTooltipPosition(event) {
tooltip.style.left = `${event.pageX}px`;
tooltip.style.top = `${event.pageY}px`;
}
function showTooltip(event) {
tooltip.style.display = 'block';
updateTooltipPosition(event);
}
function hideTooltip() {
tooltip.style.display = 'none';
}
const elements = document.querySelectorAll('.changeLanguage, li[data-link-target]');
elements.forEach(element => {
element.addEventListener('mouseenter', showTooltip);
element.addEventListener('mousemove', updateTooltipPosition);
element.addEventListener('mouseleave', hideTooltip);
});
}
function showTooltip(e) {
const tooltip = document.getElementById('autoplay-tooltip');
tooltip.style.display = 'block';
tooltip.style.left = e.pageX + 10 + 'px';
tooltip.style.top = e.pageY + 10 + 'px';
}
function hideTooltip() {
const tooltip = document.getElementById('autoplay-tooltip');
tooltip.style.display = 'none';
}
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", "*");
});
}