Greasy Fork

69shuba auto 書簽

自動書籤,更改css,可以在看書頁(https://www.69shuba.com/txt/*/*)找到作者連結

当前为 2024-01-10 提交的版本,查看 最新版本

// ==UserScript==
// @name         69shuba auto 書簽
// @namespace    pl816098
// @version      2.4.0
// @description  自動書籤,更改css,可以在看書頁(https://www.69shuba.com/txt/*/*)找到作者連結
// @author       pl816098
// @match        https://www.69shuba.com/txt/*/*
// @match        https://www.69xinshu.com/txt/*/*
// @match        https://www.69xinshu.com/book/*.htm*
// @match        https://www.69shuba.com/book/*.htm*
// @match        https://www.69shuba.com/txt/*/end.html
// @match        https://www.69xinshu.com/txt/*/end.html
// @icon         https://www.google.com/s2/favicons?sz=64&domain=69shuba.com
// @grant        window.close
// @license      MIT
// ==/UserScript==

var url = window.location.href;
var pattern = {
  book: /^(https?:\/\/)(www\.(69shuba|69xinshu)\.com)\/txt\/.*\/.*$/gm,
  info: /^(https?:\/\/)(www\.(69shuba|69xinshu)\.com)\/book\/.*\.htm.*$/gm,
  end: /^(https?:\/\/)(www\.(69shuba|69xinshu)\.com)\/txt\/.*\/end\.html$/gm,
};
if (pattern.book.test(url)) {
  document.querySelector("#a_addbookcase").click();
  let author = "";
  if (bookinfo.author) {
    author = bookinfo.author;
  } else {
    author = document
      .querySelector(
        "body > div.container > div.mybox > div.txtnav > div.txtinfo.hide720 > span:nth-child(2)"
      )
      .textContent.trim()
      .split(" ")[1];
  }
  debug(`author: ${author}`);
  let spanElement = document.querySelector(
    "body > div.container > div.mybox > div.txtnav > div.txtinfo.hide720 > span:nth-child(2)"
  );
  let aElement = document.createElement("a");
  aElement.href = `https://www.69shuba.com/modules/article/author.php?author=${author}`;
  aElement.textContent = author;
  aElement.style.color = "#007ead";
  spanElement.textContent = spanElement.textContent.trim().split(" ")[0];
  spanElement.appendChild(aElement);
  let style = document.createElement("style");
  style.innerHTML = `
  .container .mybox {
        margin: -71px -75px;
        width: auto;
    }`;
  document.head.appendChild(style);
  document.querySelector("#pageheadermenu").remove();
  document
    .querySelector("body > div.container > div.mybox > div.top_Scroll")
    .remove();
  document
    .querySelector("body > div.container > div.yuedutuijian.light")
    .remove();
  document.querySelector("#tuijian").remove();
  document.querySelector("#ad").remove();
} else if (pattern.info.test(url)) {
  document
    .querySelector(
      "body > div.container > ul > li.col-8 > div:nth-child(2) > ul > li:nth-child(2) > a"
    )
    .click();
  document.querySelector(
    "body > div.container > ul > li.col-8 > div:nth-child(1) > div > div.booknav2 > p:nth-child(2) > a"
  ).style.color = "#007ead";
  document.querySelector(
    "body > div.container > ul > li.col-8 > div:nth-child(1) > div > div.booknav2 > p:nth-child(3) > a"
  ).style.color = "#007ead";
} else if (pattern.end.test(url)) {
  window.close();
}