Proxer-Subs/Scans -- UserScript

Dieses Script klappt alle Einträge in der "Meine Projecte" Liste ein

目前為 2015-06-29 提交的版本,檢視 最新版本

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

You will need to install an extension such as Tampermonkey to install this script.

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Proxer-Subs/Scans -- UserScript
// @namespace    
// @version      1.0
// @description  Dieses Script klappt alle Einträge in der "Meine Projecte" Liste ein
// @author       Dominik Bissinger alias Nihongasuki
// @include      http://proxer.me/*
// @include      https://proxer.me/*
// @include      http://www.proxer.me/*
// @include      https://www.proxer.me/*        
// @run-at       document-start
// ==/UserScript==

document.addEventListener('DOMContentLoaded', function(event) {
    $(document).ajaxSuccess (function () {
        main();
    });
    main();
});

var table = [];
var main = function () {
    if (window.location.href.indexOf('subs?s=my') === -1 || window.location.href.indexOf('forum') > -1) {return;};
    if (document.getElementsByClassName('hideButton').length !== 0) {return;};
    var style = document.createElement('style');
    style.innerHTML = "\
    .hideButton {\
        height: 20px; \
        border-style: solid;\
        border-width: 1px; \
        padding: 5px; \
        border-radius: 10px;\
    }\
    ";
    document.head.appendChild(style);
    var inner = document.getElementsByClassName('inner')[0];
    var div = inner.getElementsByTagName('div');
    var a = [];
    var aString = [];
    table = [];
    
    for (var i = 0; i < div.length; i++) {
        table[i] = div[i].getElementsByTagName('table')[0];
        table[i].style.display = "none";
        
        var hr = div[i].getElementsByTagName('hr')[0];
        var br = document.createElement('br');
        var newSpan = document.createElement('span');
        var img = document.createElement('img');
        
        img.setAttribute ("class","hideButton");
        img.setAttribute ("id","showState"+i);
        img.setAttribute ("style","display: inline; position: relative; top: 10px; left: 5px;");
        if (div[i].getElementsByClassName('nextState').length !== 0 || div[i].getElementsByClassName('prevState').length !== 0) {
            img.src = "/images/misc/offlineicon.png";
        }else{
            img.src = "/images/misc/onlineicon.png";
        };
        
        newSpan.setAttribute ("class","hideButton");
        newSpan.setAttribute ("id","hideButton"+i);
        newSpan.setAttribute ("style","cursor: pointer; display: inline;");
        newSpan.innerHTML = "Tabelle anzeigen";
        
        div[i].insertBefore(newSpan,hr);
        div[i].insertBefore(img,hr);
        div[i].appendChild(br);
        
        document.getElementById('hideButton'+i).addEventListener("click",function () {
            showHide(this.id);
        })
    };
    
    //setStyle of Buttons
    var color = "";
    var setStyle = function () {  
        for (var i = 0; i < 4; i++) {
            if (color === "gray") {
                var buttons = document.getElementsByClassName('hideButton');
                for (var j = 0; j < buttons.length; j++) {
                    buttons[j].style.backgroundColor = "#5E5E5E";
                    buttons[j].style.borderColor = "#FFF";
                };
            }else if (color === "black") {
                var buttons = document.getElementsByClassName('hideButton');
                for (var j = 0; j < buttons.length; j++) {
                    buttons[j].style.backgroundColor = "#000";
                    buttons[j].style.borderColor = "#FFF";
                };
            }else if (color === "old_blue") {
                var buttons = document.getElementsByClassName('hideButton');
                for (var j = 0; j < buttons.length; j++) {
                    buttons[j].style.backgroundColor = "#F3FBFF";
                    buttons[j].style.borderColor = "#000";
                };
            }else{
                var buttons = document.getElementsByClassName('hideButton');
                for (var j = 0; j < buttons.length; j++) {
                    buttons[j].style.backgroundColor = "#F3FBFF";
                    buttons[j].style.borderColor = "#000";
                };
            };
        };
    };
        
    //Read Cookie
    var name = "style=";
    var cookieCheck = function () {
        var ca = document.cookie.split(';');
        for (var i = 0; i < ca.length; i++) {
            var c = ca[i];
            while (c.charAt(0) === " ") {
                c = c.substring(1);
            };
            if (c.indexOf(name) == 0) {
                color = c.substring(name.length,c.length);
                setStyle();
            };
        };
        if (color === "") {
            cookieCheck();
        };
    };
    cookieCheck();
};

var showHide = function (id) {
    var i = id.substring(10);
    if (table[i].style.display === "none") {
        table[i].style.display = "inline";
        document.getElementById(id).innerHTML = "Tabelle ausblenden";
        document.getElementById("showState"+i).style.display = "none";
    }else{
        table[i].style.display = "none";
        document.getElementById(id).innerHTML = "Tabelle anzeigen";
        document.getElementById("showState"+i).style.display = "inline";
    };
};