豆瓣直达片源网

在豆瓣电影页面新增一个按钮直达片源网搜索结果

  1. // ==UserScript==
  2. // @name 豆瓣直达片源网
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @description 在豆瓣电影页面新增一个按钮直达片源网搜索结果
  6. // @author JSSM
  7. // @match *://movie.douban.com/subject/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14. //感谢chatgpt帮我完成100%的代码
  15. // Find the #info div
  16. const infoDiv = document.getElementById('info');
  17.  
  18. // Get the IMDb ID by looking for a span with class 'pl' followed by a text node containing the ID
  19. let imdbIdElement = null;
  20. const plSpans = infoDiv.querySelectorAll('.pl');
  21. for (let i = 0; i < plSpans.length; i++) {
  22. const currentSpan = plSpans[i];
  23. if (currentSpan.textContent.includes('IMDb:')) {
  24. const nextNode = currentSpan.nextSibling;
  25. if (nextNode && nextNode.nodeType === Node.TEXT_NODE) {
  26. const imdbIdCandidate = nextNode.textContent.trim();
  27. if (imdbIdCandidate.startsWith('tt')) {
  28. imdbIdElement = {
  29. span: currentSpan,
  30. idNode: nextNode
  31. };
  32. break;
  33. }
  34. }
  35. }
  36. }
  37.  
  38. if (imdbIdElement) {
  39. const imdbId = imdbIdElement.idNode.textContent.trim();
  40.  
  41. // Create the search link
  42. const searchUrl = 'https://pianyuan.org/search?q=' + encodeURIComponent(imdbId);
  43.  
  44. // Create the new span with "片源网:"
  45. const newLineBreak = document.createElement('br');
  46. const newSpan = document.createElement('span');
  47. newSpan.classList.add('pl');
  48. newSpan.innerText = '片源网: ';
  49.  
  50. // Create the clickable link inside the new span
  51. const newLink = document.createElement('a');
  52. newLink.href = searchUrl;
  53. newLink.target = '_blank';
  54. newLink.rel = 'noopener noreferrer';
  55. newLink.innerText = '一键跳转';
  56.  
  57. // Append the link to the new span
  58. newSpan.appendChild(newLink);
  59.  
  60. // Insert the new span after the IMDb ID text node
  61. imdbIdElement.span.parentNode.insertBefore(newLineBreak, imdbIdElement.idNode.nextSibling); // Assuming you still want a line break here
  62. imdbIdElement.span.parentNode.insertBefore(newSpan, newLineBreak.nextSibling);
  63.  
  64.  
  65. // 新的搜索链接和网站名
  66. const anotherSearchUrl = 'https://therarbg.com/get-posts/?keywords=' + encodeURIComponent(imdbId);
  67. const anotherSiteName = 'RARBG: ';
  68.  
  69. // 创建新的换行符
  70. const anotherNewLineBreak = document.createElement('br');
  71.  
  72. // 创建包含新链接的新span元素
  73. const anotherNewSpan = document.createElement('span');
  74. anotherNewSpan.classList.add('pl');
  75. anotherNewSpan.innerText = anotherSiteName;
  76.  
  77. // 创建新的可点击链接
  78. const anotherNewLink = document.createElement('a');
  79. anotherNewLink.href = anotherSearchUrl;
  80. anotherNewLink.target = '_blank';
  81. anotherNewLink.rel = 'noopener noreferrer';
  82. anotherNewLink.innerText = '一键跳转';
  83.  
  84. // 将新链接添加到新span中
  85. anotherNewSpan.appendChild(anotherNewLink);
  86.  
  87. // 在上一次插入的位置之后再次插入新的换行符和span
  88. imdbIdElement.span.parentNode.insertBefore(anotherNewLineBreak, newSpan.nextSibling);
  89. imdbIdElement.span.parentNode.insertBefore(anotherNewSpan, anotherNewLineBreak.nextSibling);
  90. }
  91.  
  92. })();

QingJ © 2025

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