Navigate_streamallthis.is

A little script to navigate trough series at the streaming host <a href="http://streamallthis.is">streamallthis.is</a>

目前為 2014-10-12 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name       Navigate_streamallthis.is
// @namespace  http://use.i.E.your.homepage/
// @version    0.1.1
// @description  A little script to navigate trough series at the streaming host <a href="http://streamallthis.is">streamallthis.is</a>
// @match      http://streamallthis.is/watch/*/s*
// @copyright  2012+, You
// ==/UserScript==


var url = window.location.pathname;
var filename = url.substring(url.lastIndexOf('/')+1);
filename = filename.replace(".html","");
filename = filename.replace("s","");
var series = filename.substr(0,filename.indexOf('e'));
var episode = filename.substr(filename.indexOf('e') + 1);

if(document.title == '404 Not Found'){
    changeSerie();
} else {
    
    var p = document.createElement("P");
    p.align = "center";
    
    
    var prev=document.createElement("input");
    prev.type="button";
    prev.value="<<= PREV";
    prev.onclick = function(){changeEpisode(false)};
    p.appendChild(prev);
    
    var next=document.createElement("input");
    next.type="button";
    next.value="NEXT =>>";
    next.onclick = function(){changeEpisode(true)};
    p.appendChild(next);
    
    //document.body.appendChild(p);
    document.getElementsByClassName("fa")[0].appendChild(p);
}

function changeSerie(){
    var next = episode > 1;
    if (next){
        series++;
        episode = '01';
        series = addMissingZero(series);
        window.location.assign(url.substring(0,url.lastIndexOf('/') + 1) + 's' + series + 'e' + episode + '.html');
    } else {
        series --;
        //TODO
    }
}


function changeEpisode(next) {
    
    
    
    next ? episode++ : episode--;
    
    episode = addMissingZero(episode);
    
    window.location.assign(url.substring(0,url.lastIndexOf('/') + 1) + 's' + series + 'e' + episode + '.html');
    
}

function addMissingZero(number) {
    return (number < 10 ? "0" + number : number);
    //return number;
}