Greasy Fork

Greasy Fork is available in English.

ixueshu reader

make ixueshu pdf more readable

当前为 2020-08-13 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         ixueshu reader
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  make ixueshu pdf more readable
// @author       Shae
// @match        https://www.ixueshu.com/document/*.html
// @match        https://www.ixueshu.com/h5/document/*.html
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    if (/\/h5\//.test (location.pathname) ) {
        var newURL = location.pathname.replace (/\/h5\//, "/");
        location.replace (newURL);
    }
    setTimeout(function() {
        // close top fav bar
        var fav = document.querySelector("body > div.top_collect_web");
        if (fav) {
            document.querySelector("body > div.top_collect_web > a.cw_close").click();
        }
        // close weixin band layer
        var wxband_shade = document.querySelector("#layui-layer-shade1");
        var wxband = document.querySelector("#layui-layer1");
        if (wxband) {
            var iframe = document.querySelector("#layui-layer-iframe1");
            var iframe_doc = iframe.contentDocument ? iframe.contentDocument : iframe.contentWindow.document;
            var wx_close = iframe_doc.querySelector("body > div > div > div.wx_close");
            wx_close.click();
        }
        // remove navbar and sidebar
        var navbar = document.querySelector("body > div:nth-child(5) > div.nav_0814");
        var sidebar = document.querySelector("#preview > div.det_right");
        navbar.parentNode.removeChild(navbar);
        sidebar.parentNode.removeChild(sidebar);
        // make container width 100%
		document.querySelector("#preview > div > div.det_left").style.width = "100%";
		document.querySelector("#preview > div.det_rel_left").style.width = "100%";
		document.querySelector("#preview > div").style.width = "100%";
		// make pdf width 100%
        var docs = document.getElementsByClassName("main");
        var doc;
        for (var i = 0; i < docs.length; i++) {
            doc = docs[i];
            doc.style.width = "100%";
            doc.style.height = "100%";
        }
        // remove elements
        // remove feedback button
        document.querySelector("body > div.suspFeedback_1").remove();
        // remove upload button
        document.querySelector("body > div:nth-child(4) > div > div > div.head_upload").remove();
        // remove ads
        var links = document.querySelectorAll("a");
        // var adpattern = new RegExp("^https://adapi.ixueshu.com/link/[0-9]+$");
        var adpattern = /^https:\/\/adapi.ixueshu.com\/link\/\d+$/;
        for (i = 0; i < links.length; i++) {
            if (adpattern.test(links[i].href)) {
                links[i].remove();
            }
        }
    }, 3000);
})();