您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
try to take over the world!
当前为
- // ==UserScript==
- // @name TitleSearch
- // @namespace http://tampermonkey.net/
- // @version 5.02
- // @description try to take over the world!
- // @author TitleSearch
- // @match *://www.abooky.com/*
- // @match *://www.yousuu.com/search*
- // @match *://dushuxiaozi.com/category*
- // @require http://libs.baidu.com/jquery/2.0.0/jquery.min.js
- // ==/UserScript==
- (function ( ) {
- "use strict";
- var $ = $ || window.$;
- var urllist = [
- { name: "abooky", url: /www\.abooky\.com/, titleid: ".ts", nosign: "" },
- ];
- var run_mk = false;
- function gettitle(t, str1, str2) {
- let lnum, rnum, title;
- lnum = t.indexOf(str1);
- rnum = t.indexOf(str2);
- if (lnum < 0) lnum = 0;
- if (rnum < 0) rnum = 0;
- if (lnum > 0 || rnum > 0) {
- title = t.substring(lnum + 1, rnum);
- }
- if (title) title = title.replace("[TXT格式]", "").replace("\n", "");
- return title;
- }
- function addbutton(t) {
- if (t) {
- console.log(t);
- let title = gettitle(t, "《", "》");
- if (!title) {
- title = gettitle(t, "<", ">");
- }
- if (!title) {
- title = gettitle(t, "]", "⊙");
- }
- console.log(title);
- if (title) {
- let b = $("<button></button>");
- b.text("优书网");
- b.css({
- color: " #666",
- "background-color": " #EEE",
- "border-color": " #EEE",
- "font-weight": " 300",
- "font-size": " 16px",
- "text-decoration": " none",
- "text-align": " center",
- "line-height": " 25px",
- height: " 25px",
- padding: " 0 15px",
- margin: " 0",
- display: " inline-block",
- appearance: " none",
- cursor: " pointer",
- border: " none",
- "-webkit-box-sizing": " border-box",
- "-moz-box-sizing": " border-box",
- "box-sizing": " border-box",
- "-webkit-transition-property": " all",
- "transition-property": " all",
- "-webkit-transition-duration": " .3s",
- "transition-duration": " .3s",
- "border-radius": " 4px",
- });
- b.click(function () {
- var content = document.createElement("a");
- content.href =
- "http://www.yousuu.com/search/?search_type=title&search_value=" +
- title +
- "#TitleSearch";
- content.target = "_blank";
- document.body.appendChild(content);
- content.click();
- document.body.removeChild(content);
- });
- return b;
- }
- }
- }
- function addDownbutton(t) {
- if (t) {
- console.log(t);
- let title = gettitle(t, "《", "》");
- if (!title) {
- title = gettitle(t, "<", ">");
- }
- if (!title) {
- title = gettitle(t, "]", "⊙");
- }
- console.log(title);
- if (title) {
- let b = $("<button></button>");
- b.text("下载");
- b.css({
- color: " #666",
- "background-color": " #EEE",
- "border-color": " #EEE",
- "font-weight": " 300",
- "font-size": " 16px",
- "text-decoration": " none",
- "text-align": " center",
- "line-height": " 25px",
- height: " 25px",
- padding: " 0 15px",
- margin: " 0",
- display: " inline-block",
- appearance: " none",
- cursor: " pointer",
- border: " none",
- "-webkit-box-sizing": " border-box",
- "-moz-box-sizing": " border-box",
- "box-sizing": " border-box",
- "-webkit-transition-property": " all",
- "transition-property": " all",
- "-webkit-transition-duration": " .3s",
- "transition-duration": " .3s",
- "border-radius": " 4px",
- });
- b.click(function () {
- var content = document.createElement("a");
- content.href =
- "https://dushuxiaozi.com/wp-content/uploads/2019/book/" +
- title +
- ".zip";
- content.target = "_blank";
- document.body.appendChild(content);
- content.click();
- document.body.removeChild(content);
- });
- return b;
- }
- }
- }
- function make(obj) {
- if (obj.url.test(location.href)) {
- let t = $(obj.titleid).text();
- let b = addbutton(t);
- if (b) $(obj.titleid).after(b);
- }
- }
- /**
- * @description : 根据ID检查元素是否可见,再点击
- * @param {*} cssid
- * @return {*}
- */
- function loop(cssid) {
- function checkVisible(elm) {
- var rect = elm.getBoundingClientRect();
- var viewHeight = Math.max(
- document.documentElement.clientHeight,
- window.innerHeight
- );
- return !(rect.bottom < 0 || rect.top - viewHeight >= 0);
- }
- const s = document.querySelector(cssid);
- if (s) {
- let r = checkVisible(s);
- if (r) {
- s.click();
- // serch();
- }
- }
- }
- function autoclick() {
- let num = 0;
- const _Interval = setInterval(
- () => {
- let books = $(".list-card-layout");
- console.log(books);
- if (books.length == 0) books = $(".result-item-layout");
- console.log(books.length);
- if (books.length == 1) {
- const bookname = books.find(".book-name");
- console.log(bookname);
- if (bookname.length == 1) {
- bookname[0].click();
- clearInterval(_Interval)
- setTimeout(function () {
- window.close();
- }, 200);
- }
- } else {
- if (window.document.body.innerText.indexOf('找不到你要的结果:-)') > 0 || num > 10) {
- clearInterval(_Interval)
- window.close();
- }
- num++
- }
- }, 200
- )
- }
- function dushuxiaozi() {
- var count = 0;
- var isok = false;
- function serch() {
- var list = document.querySelectorAll("#main h2 > a");
- console.log(list);
- if (count != list.length && !isok) {
- isok = true;
- for (var i = 0; i < list.length; i++) {
- let t = $(list[i]).text();
- console.log(t);
- if (list[i].getAttribute("titlesearch_mk") != "true") {
- let b = addbutton(t);
- let b2 = addDownbutton(t);
- if (b) {
- $(list[i]).after(b2);
- $(list[i]).after(b);
- list[i].parentNode.style.cssText =
- "font-size: 18px;width: 750px;";
- list[i].setAttribute("titlesearch_mk", "true");
- }
- }
- }
- isok = false;
- }
- }
- setInterval(() => loop(".ias-trigger-next"), 2000);
- serch();
- document.querySelector("#main").addEventListener("DOMNodeInserted", serch);
- }
- function run() {
- if (location.hash && location.hash == "#TitleSearch") {
- setTimeout(autoclick, 1100);
- } else {
- // if (/dushuxiaozi/.test(location.href)) {
- // dushuxiaozi();
- // } else {
- urllist.forEach(make);
- // }
- }
- if (/www\.abooky\.com/.test(location.href)) {
- $(window).scroll(function () {
- var scrollTop = $(this).scrollTop();
- var scrollHeight = $(document).height();
- var windowHeight = $(this).height();
- if (scrollTop + windowHeight >= scrollHeight - 350) {
- if (!run_mk) {
- run_mk = true;
- loop("#autopbn");
- run_mk = false;
- }
- }
- });
- }
- }
- run();
- })( );