Greasy Fork

Better Anime1

Provides better Anime1 UI experience

目前为 2021-12-23 提交的版本。查看 最新版本

// ==UserScript==
// @name         Better Anime1
// @namespace    http://tampermonkey.net/
// @version      1.2
// @description  Provides better Anime1 UI experience
// @author       PoH98
// @match        https://anime1.me/*
// @icon         https://anime1.me/favicon-32x32.png
// @grant        none
// @run-at       document-body
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';
    function httpGet(url)
    {
        fetch(url).then(function(response) {
            return response.text();
        }).then(function(data) {
            let parser = new DOMParser();
            let doc = parser.parseFromString(data, 'text/html');
            let content = doc.querySelector('#main');
            let item = content.querySelectorAll("*");
            item.forEach(function(el){
                if(el.id.includes("ad") && !el.id.includes("head") && !el.id.includes("thread")){
                    el.remove();
                    return;
                }
                if(el.className === 'nav-next'){
                    el.remove();
                }
                if(el.className === 'pagination'){
                    el.style.display = "none";
                    return;
                }
                el.style.color = "#fff"
                el.style.backgroundColor = "#444";
            });
            content.className = "";
            Array.prototype.slice.call(content.childNodes).forEach(el =>{
                document.getElementById("main").appendChild(el);
            })

            let prev = content.querySelectorAll(".nav-previous a");
            if(prev.length > 0){
                httpGet(prev[0].href);
                prev.forEach(el =>{
                    el.remove();
                })
            }
        })
    }

    let table = document.getElementById("tablepress-1");
    if(table != null){
        table.id = "";
        table.className = "";
    }
    let side = document.getElementById("secondary");
    if(side != null){
        side.remove();
    }
    let main = document.getElementById("primary");
    if(main != null){
        main.style.width = "100%";
    }
    let content = document.getElementById("content");
    if(content != null){
        content.style.minHeight = "calc(100vh - 238px)";
    }
    document.body.style.backgroundColor = "#000";
    document.body.style.color = "#fff"
    let prev = document.querySelectorAll(".nav-previous a");
    if(prev.length > 0){
        httpGet(prev[0].href);
        prev.forEach(el =>{
            el.remove();
        })
    }
    let page = document.getElementById("page");
    let item = page.querySelectorAll("*");
    item.forEach(function(el){
        if(el.id.includes("ad") && !el.id.includes("head") && !el.id.includes("thread")){
            el.remove();
            return;
        }
        if(el.id === 'disqus_thread'){
            el.style.backgroundColor = "#999";
            el.style.padding = "10px";
            el.style.margin = "-10px";
            return;
        }
        if(el.id === 'dcl_comment_btn'){
            el.click();
        }
        if(el.className === 'pagination'){
            el.style.display = "none";
            return;
        }
        el.style.color = "#fff"
        el.style.backgroundColor = "#444";
    });
    if(window.innerWidth > 1280){
        let img = document.createElement("img");
        img.style.position = "fixed";
        img.style.bottom = "10px";
        img.style.right = "10px";
        img.src = "https://i.pinimg.com/originals/1c/79/ac/1c79ac50b06bb42a24058bf13c162a3e.gif";
        page.appendChild(img);
    }
    var tick = setInterval(
        function(){
            let frame = document.querySelectorAll("iframe");
            frame.forEach(el => {
                el.height = 720;
                el.width = 1280;
            })
        }, 2000)
    })();