// ==UserScript== // @name bs.to and vivo enhancer // @author xtrars // @description Wechselt automatisch zum Vivo-Tab auf bs.to und öffnet Vivo. Wahlweise wird die Video-URL kopiert und der Tab geschlossen oder das Video startet automatisch. Wenn aktiviert, startet das nächste Video, sobald ein Vivo-Video beendet wurde. // @description:en Automatically switches to the Vivo tab on bs.to and opens Vivo. Optionally copies the video url and closes the tab or starts the video automatically. If enabled, the next video starts as soon as a vivo video is finished. // @include https://bs.to/* // @include https://*.vivo.sx/* // @include https://*.vivo.st/* // @include https://vivo.sx/* // @include https://vivo.st/* // @version 2.7 // @run-at document-start // @license CC BY 4.0 // @namespace https://greasyfork.org/users/140785 // @grant GM_setValue // @grant GM_getValue // @grant GM_setClipboard // @grant GM_addValueChangeListener // @grant GM_removeValueChangeListener // @downloadURL none // ==/UserScript== class SiteHandler { isVivoTab() { let sVivoStr = '/Vivo'; return document['location']['href'].search(sVivoStr) !== -1; } hasAnotherHoster() { let hosterRegex = /^https:\/\/bs.to\/.*[0-9]{1,2}\/[0-9]{1,2}\-.*\/[a-z]*\/(?!Vivo).*/g; return document['location']['href'].search(hosterRegex) !== -1; } isEpisode() { let serieRegex = /[0-9]{1,2}\/[0-9]{1,2}\-/g; let bsRegex = /^(https:\/\/bs.to)/g; return document['location']['href'].search(bsRegex) !== -1 && document['location']['href'].search(serieRegex) !== -1; } isVivo() { let vivoRegex = /^https:\/\/vivo.[a-z]{2,3}\//g; return document['location']['href'].search(vivoRegex) !== -1 && document.getElementsByTagName('video') && document.getElementsByTagName('video')[document.getElementsByTagName('video').length -1] } isReady() { return new Promise(result => { window.addEventListener('load', function() { result(true); }); }); } // thanks to xZaheer (https://greasyfork.org/de/scripts/400669-burningseries-autoplay/code) waitForElement(selector) { return new Promise(async resolve => { if (document.querySelector(selector)) { return resolve(document.querySelector(selector)); } const observer = new MutationObserver(mutations => { if (document.querySelector(selector)) { resolve(document.querySelector(selector)); observer.disconnect(); } }); let waitForElementInterval = setInterval(() => { if(document.body) { observer.observe(document.body, { childList: true, subtree: true, }); clearInterval(waitForElementInterval); } }, 20); }); } // thanks to xZaheer (https://greasyfork.org/de/scripts/400669-burningseries-autoplay/code) async clickPlay() { let playerElem = await this.waitForElement('section.serie .hoster-player').catch(() => {}); if(playerElem) { let clickEvent = new Event('click'); clickEvent.which = 1; clickEvent.pageX = 1; clickEvent.pageY = 1; setTimeout(() => { playerElem.dispatchEvent(clickEvent); }, 500); } } playNextEpisodeIfVideoEnded(bSetEvent = true) { if(!bSetEvent) { GM_removeValueChangeListener('isLocalVideoEnded'); GM_setValue('isLocalVideoEnded', false); return; } GM_addValueChangeListener('isLocalVideoEnded', () => { if (GM_getValue('isLocalVideoEnded')) { GM_setValue('isLocalVideoEnded', false); document['location'].replace(document.querySelector('.serie .frame ul li[class^="e"].active + li a').href); } }); } buildButton() { const style = document.createElement('style'); style.innerHTML = ` :root { --inner-pl: 14px; --inner-bc-before: #2FB536; --inner-bc-after: #12A6F6; --color: white; } @keyframes shake { 10%, 90% {transform: translate3d(-.5px, 0, 0);} 20%, 80% {transform: translate3d(1px, 0, 0);} 30%, 50%, 70% {transform: translate3d(-2px, 0, 0);} 40%, 60% {transform: translate3d(2px, 0, 0);} } .onoffswitch { position: relative; width: 350px; -webkit-user-select:none; -moz-user-select:none; -ms-user-select: none; } .onoffswitch-checkbox { position: absolute; opacity: 0; pointer-events: none; } .onoffswitch-label { width: 350px; display: block; overflow: hidden; cursor: pointer; border: 2px solid transparent; border-radius: 20px; } .onoffswitch-inner { display: block; width: 200%; margin-left: -100%; transition: margin 0.3s ease-in 0s; } .onoffswitch-inner:before, .onoffswitch-inner:after { display: block; float: left; width: 50%; height: 30px; padding: 0; line-height: 30px; font-size: 10px; color: white; font-family: Trebuchet, Arial, sans-serif; font-weight: bold; box-sizing: border-box; } .onoffswitch-switch { display: block; width: 23px; margin: 3.5px; background: #FFFFFF; position: absolute; top: 0; bottom: 0; right: 314px; border: 2px solid #999999; border-radius: 20px; transition: all 0.3s ease-in 0s; } .onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-inner { margin-left: 0; } .onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-switch { right: 0px; } #xtrars-btn { position: absolute; bottom: 70px; right: 18px; background: #12a6f6; border-radius: 50%; width: 70px; height: 70px; line-height: 81px; text-align: center; cursor: pointer; animation: shake 1s ease 1s 1 normal; } #xtrars-btn:hover { cursor: auto; } #xtrars-menu { right: 0; } #xtrars-btn-icon { color: var(--color); } .onoffswitch-inner.autoplay:before { padding-left: var(--inner-pl); background-color: var(--inner-bc-before); color: var(--color); text-align: start; content: "Vivo Autoplay aktiviert"; } .onoffswitch-inner.autoplay:after { padding-right: var(--inner-pl); background-color: var(--inner-bc-after); color: var(--color); text-align: end; content: "Video-URL wird in die Zwischenablage kopiert"; } .onoffswitch-inner.auto-next-episode:before { padding-left: var(--inner-pl); background-color: var(--inner-bc-before); color: var(--color); text-align: start; content: "Nächste Folge wird automatisch abgespielt"; } .onoffswitch-inner.auto-next-episode:after { padding-right: var(--inner-pl); background-color: var(--inner-bc-after); color: var(--color); text-align: end; content: "Nächste Folge wird manuell abgespielt"; } .onoffswitch-inner.enable-enhancer:before { padding-left: var(--inner-pl); background-color: var(--inner-bc-before); color: var(--color); text-align: start; content: "bs.to and vivo enhancer aktiviert"; } .onoffswitch-inner.enable-enhancer:after { padding-right: var(--inner-pl); background-color: var(--inner-bc-after); color: var(--color); text-align: end; content: "bs.to and vivo enhancer deaktiviert"; } `; document.head.appendChild(style); const button = document.createElement("div"); button['innerHTML'] = '