ixdzs8.tw

自用

目前為 2024-02-22 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

/** @format */

// ==UserScript==
// @name         ixdzs8.tw
// @namespace    pl816098
// @version      1.2.3
// @description  自用
// @author       paul
// @match        https://ixdzs8.tw/read/*/*.html
// @match        https://ixdzs8.tw/read/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=ixdzs8.tw
// @license      MIT
// @grant        GM_addStyle
// @grant        window.close
// ==/UserScript==
let ele = [];
set_gm: {
  var _GM_xmlhttpRequest,
    _GM_registerMenuCommand,
    _GM_notification,
    _GM_addStyle,
    _GM_openInTab,
    _GM_info,
    _GM_setClipboard;
  GM_xmlhttpRequest: {
    if (typeof GM_xmlhttpRequest !== "undefined") {
      _GM_xmlhttpRequest = GM_xmlhttpRequest;
    } else if (
      typeof GM !== "undefined" &&
      typeof GM.xmlHttpRequest !== "undefined"
    ) {
      _GM_xmlhttpRequest = GM.xmlHttpRequest;
    } else {
      _GM_xmlhttpRequest = (f) => {
        fetch(f.url, {
          method: f.method || "GET",
          body: f.data,
          headers: f.headers,
        })
          .then((response) => response.text())
          .then((data) => {
            f.onload && f.onload({ response: data });
          })
          .catch(f.onerror && f.onerror());
      };
    }
  }
  GM_registerMenuCommand: {
    if (typeof GM_registerMenuCommand !== "undefined") {
      _GM_registerMenuCommand = GM_registerMenuCommand;
    } else if (
      typeof GM !== "undefined" &&
      typeof GM.registerMenuCommand !== "undefined"
    ) {
      _GM_registerMenuCommand = GM.registerMenuCommand;
    } else {
      _GM_registerMenuCommand = (s, f) => {
        debug(s);
        debug(f);
      };
    }
  }
  GM_info: {
    if (typeof GM_info !== "undefined") {
      _GM_info = GM_info;
    } else if (typeof GM !== "undefined" && typeof GM.info !== "undefined") {
      _GM_info = GM.info;
    } else {
      _GM_info = { script: {} };
    }
  }
  GM_notification: {
    if (typeof GM_notification !== "undefined") {
      _GM_notification = GM_notification;
    } else if (
      typeof GM !== "undefined" &&
      typeof GM.notification !== "undefined"
    ) {
      _GM_notification = GM.notification;
    } else {
      _GM_notification = (s) => {
        showTips(String(s.text || s));
      };
    }
  }
  GM_openInTab: {
    if (typeof GM_openInTab !== "undefined") {
      _GM_openInTab = GM_openInTab;
    } else if (
      typeof GM !== "undefined" &&
      typeof GM.openInTab !== "undefined"
    ) {
      _GM_openInTab = GM.openInTab;
    } else {
      _GM_openInTab = (s, t) => {
        window.open(s);
        debug(t);
      };
    }
  }
  GM_addStyle: {
    if (typeof GM_addStyle !== "undefined") {
      _GM_addStyle = GM_addStyle;
    } else if (
      typeof GM !== "undefined" &&
      typeof GM.addStyle !== "undefined"
    ) {
      _GM_addStyle = GM.addStyle;
    } else {
      _GM_addStyle = (cssStr = null) => {
        let styleEle = document.createElement("style");
        styleEle.classList.add("_GM_addStyle");
        styleEle.innerHTML = cssStr;
        document.head.appendChild(styleEle);
        return styleEle;
      };
    }
  }
  GM_setClipboard: {
    if (typeof GM_setClipboard !== "undefined") {
      _GM_setClipboard = GM_setClipboard;
    } else if (
      typeof GM !== "undefined" &&
      typeof GM.setClipboard !== "undefined"
    ) {
      _GM_setClipboard = GM.setClipboard;
    } else {
      _GM_setClipboard = (s, i) => {
        debug(s);
        debug(i);
      };
    }
  }
}
let url = window.location.href;
let pattern = {
  book: {
    pattern:
      /^(https?:\/\/)(ixdzs8\.tw\/read\/[0-9]*\/(?!end)p[0-9]*\.html)$/gm,
    is: (url) => {
      if (pattern.book.pattern.test(url)) {
        return true;
      } else {
        return false;
      }
    },
  },
  info: {
    pattern: /^(https?:\/\/)(ixdzs8\.tw\/read\/[0-9]*\/)$/gm,
    is: (url) => {
      if (pattern.info.pattern.test(url)) {
        return true;
      } else {
        return false;
      }
    },
  },
  end: {
    pattern: /^(https?:\/\/)(ixdzs8\.tw\/read\/[0-9]*\/end\.html)$/gm,
    is: (url) => {
      if (pattern.end.pattern.test(url)) {
        return true;
      } else {
        return false;
      }
    },
  },
};

if (pattern.book.is(url)) {
  ele = [
    "#page-id3",
    "#page-toolbar",
    "#page > article > section > p:nth-child(1)",
  ];
  ele.forEach((ele) => {
    if (document.querySelector(ele)) {
      document.querySelector(ele).remove();
    }
  });
  _GM_addStyle(`
    .page-content{
max-width: none;
padding: 10px 15px;
transform: translateX(0px);
background: #ffffff!important;
}
`);
}
if (pattern.end.is(url)) {
  // console.log("end");
  window.close();
}
if (pattern.info.test(url)) {
  document.querySelector("#intro").click();
}