豆瓣条目跳转NeoDB条目

try to take over the world!*

目前為 2023-11-28 提交的版本,檢視 最新版本

// ==UserScript==
// @name         豆瓣条目跳转NeoDB条目
// @namespace    http://tampermonkey.net/
// @version      0.4
// @description  try to take over the world!*
// @author       You
// @match        *://m.douban.com/*/subject/*
// @match        *://*.douban.com/subject/*
// @match        *://neodb.social/movie/*
// @match        *://neodb.social/book/*
// @match        *://neodb.social/tv/season/*
// @match        *://neodb.social/discover/*
// @license   MIT
// @match        *://neodb.social/music/*
// @icon         https://neodb.social/static/img/logo_square.f6d14b9fa477.jpg
// @grant        none
// ==/UserScript==

(function () {
    "use strict";

    var currentUrl = window.location.href;
    if (/^https?:\/\/m\.douban\.com\/(book|movie|music)\/.*/.test(currentUrl)) {
      var type = "";
      if (currentUrl[21] == "b") {
        type = currentUrl.substring(21, 25);
      } else if (currentUrl[21] == "m") {
        type = currentUrl.substring(21, 26);
      }
      if (type == "music") {
        var parentElement = document.querySelector(".title");
      } else {
        var parentElement = document.querySelector(".sub-title");
      }
      var gotoURl =
        "https://neodb.social/search/?q=" +
        encodeURIComponent(
          currentUrl
            .replace("https://m.", "https://" + type + ".")
            .replace("/" + type + "/", "/")
        );
      var newdiv = `<a href="${gotoURl}" style="display: inline-block;margin-left:2px;background-color:#d94c3a;font-size:0.02rem;padding:0.03rem;border-radius: 0.03rem;color:#fff;">NeoDB</a>`;
      parentElement.insertAdjacentHTML("afterend", newdiv);
    } else if (
      /^https?:\/\/(book|movie|music)\.douban\.com\/subject\/(\d+)\//.test(
        currentUrl
      )
    ) {
      const bbElement = document.querySelector('#interest_sect_level > a:nth-child(3)')
      const aaElement = document.querySelector('#interest_sect_level > div > span:nth-child(7)');
      function createNeoDB (url){
        var newLink = `
        <a href="${url}" rel="nofollow" class="j a_show_login colbutt ll" name="pbtn-36414402-collect">
        <span style="letter-spacing: 0;
            font-weight: bold;
            font-family: serif;
            font-size: 14px;
            color: #423f38;">
            R-NeoDB
        </span>
        </a>
        `;
        return newLink
      }
      if(bbElement){
        var goUrl =
        "https://neodb.social/search/?q=" + encodeURIComponent(currentUrl);
        const newLinkElement = new DOMParser().parseFromString(createNeoDB (goUrl), "text/html").body.firstChild
        bbElement.insertAdjacentElement('afterend',newLinkElement )
      }
      if (aaElement) {
      var parentElement = document.getElementById("interest_sect_level");
      var divElement = parentElement.querySelector("div");
        const textContent = aaElement.textContent;
        var goUrl ="https://neodb.social/discover/?dbUrl="+encodeURIComponent(currentUrl)+'&myReview='+textContent;
        parentElement.insertBefore(
          new DOMParser().parseFromString(createNeoDB(goUrl), "text/html").body.firstChild,
          divElement
        );
      }
    }


    if(currentUrl.startsWith('https://neodb.social/discover/')){
      if(window.location.search){
          const item = new URLSearchParams(window.location.search);
          if (item.has('myReview')) {
              const myReview = item.get('myReview');
              localStorage.setItem('myReview',myReview)
              window.location.href = "https://neodb.social/search/?q=" + encodeURIComponent(item.get('dbUrl'));
          }
      }
    }
    if (/^https?:\/\/neodb\.social\/book/.test(currentUrl)) {
      const someButton = document.querySelector('#item-primary-action > div.item-action.item-mark-buttons > button:nth-child(3)')
      if(someButton){
        someButton.click()
        setTimeout(function(){
            const textarea = document.querySelector('#id_text')
            if(textarea){
                textarea.value = localStorage.getItem('myReview')
            }
        },1500)
      }

      var parentElement = document.querySelector("#item-title .site-list");
      var bookTitle = document.getElementById("item-title").querySelector("h1");
      var bookText = bookTitle.innerText;
      var newLink = `
         <a href="https://zh.annas-archive.org/search?q=${bookText}" class="douban" style='background-color:#ef6a32'>AnnA</a>
        `;
      if (bookTitle) {
        parentElement.insertAdjacentHTML("beforeend", newLink);
      }

    } else if (/^https?:\/\/neodb\.social\/(tv\/season|movie)/.test(currentUrl)) {
      var videoTitle = document.getElementById("item-title").querySelector("h1");
      var parentsElement = document.querySelector("#item-title .site-list");
      var videoText = videoTitle.textContent.trim().replace(/[\(\)]/g, "");
      console.log(videoText);
      var newsLink = `
        <a href="https://clmclm.com/search-${videoText}-0-0-1.html" class="douban" style='background-color:#061c12'>CaT</a>
        <a href="https://www.alipansou.com/search?k=${videoText}" class="douban" style='background-color:#7f93fa'>Ali</a>
      `;
      if (videoTitle && parentsElement) {
        parentsElement.insertAdjacentHTML("beforeend", newsLink);
      }
    }
  })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址