gaoqing 关联豆瓣

- 在http://gaoqing.la 网站的电影中的片名一栏添加超链接跳转到豆瓣对于评分页面。

  1. // ==UserScript==
  2. // @name gaoqing 关联豆瓣
  3. // @namespace http://tampermonkey.net/
  4. // @version 2.11
  5. // @description - 在http://gaoqing.la 网站的电影中的片名一栏添加超链接跳转到豆瓣对于评分页面。
  6. // @author backrock12
  7. // @match https://www.douban.com/search*
  8. // @match http://gaoqing.la/*
  9. // @require https://cdn.staticfile.org/jquery/3.3.1/jquery.min.js
  10. // ==/UserScript==
  11.  
  12. (function ( ) {
  13. 'use strict';
  14.  
  15. console.log('gaoqing');
  16. //var $ = unsafeWindow.jQuery;
  17.  
  18. $(function () {
  19. // try {
  20. if (/www\.douban\.com/.test(location.href)) {
  21. if (location.hash && location.hash.length > 0) {
  22. if (location.hash.slice(1) == "autoselect") {
  23. $(".result-list .result .title h3").each(function () {
  24. if (
  25. $(this)
  26. .find("span")
  27. .eq(0)
  28. .text() == "[电影]"
  29. ) {
  30. if (
  31. $(this)
  32. .find("a")
  33. .eq(0)
  34. .attr("href") != null
  35. ) {
  36. $(location).prop(
  37. "href",
  38. $(this)
  39. .find("a")
  40. .eq(0)
  41. .attr("href")
  42. );
  43. return false;
  44. }
  45. }
  46. });
  47. }
  48. }
  49. } else {
  50. _subGaoqingReplace();
  51. }
  52. // } catch (err) {
  53. // console.log("gaoqing replace Error:" + err.message);
  54. // }
  55.  
  56.  
  57.  
  58.  
  59. function _subGaoqingReplace() {
  60.  
  61. var isfind = false;
  62.  
  63. $("span").not("script").not("a").each(
  64. function () {
  65. if (isfind) return;
  66. var valuetext = $(this).text();
  67. if (!valuetext || valuetext.length < 1) return;
  68. var n1 = valuetext.indexOf("片  名");
  69. if (n1 && n1 > 0) {
  70. var name = null;
  71. if (this.nodeName == "P") {
  72. var n2 = valuetext.indexOf("年  代");
  73. name = valuetext.substr(n1 + 4, n2 - n1 - 4 - 1);
  74. } else {
  75. name = valuetext.substr(n1 + 4);
  76. }
  77. name = $.trim(name).replace("\n", "");
  78. if (name != null) {
  79. console.log("gaoqingreplace:" + name);
  80. console.log(this);
  81.  
  82. var h = $(this)
  83. .html()
  84. .replace(
  85. name,
  86. "<a href='https://www.douban.com/search?cat=1002&q=" +
  87. name +
  88. "#autoselect' target='_blank' style='font-weight:bold;'><font color='#0000FF'>" +
  89. name +
  90. "</font></a>"
  91. );
  92.  
  93. $(this).before(h);
  94. $(this).remove();
  95. isfind = true;
  96. return false;
  97. }
  98. }
  99. });
  100.  
  101. $("p").not("script").not("a").each(
  102. function () {
  103. if (isfind) return;
  104. var valuetext = $(this).text();
  105. if (!valuetext || valuetext.length < 1) return;
  106. var n1 = valuetext.indexOf("片  名");
  107. if (n1 && n1 > 0) {
  108. var name = null;
  109. if (this.nodeName == "P") {
  110. var n2 = valuetext.indexOf("年  代");
  111. name = valuetext.substr(n1 + 4, n2 - n1 - 4 - 1);
  112. } else {
  113. name = valuetext.substr(n1 + 4);
  114. }
  115. name = $.trim(name).replace("\n", "");
  116. if (name != null) {
  117. console.log("gaoqingreplace:" + name);
  118. console.log(this);
  119.  
  120. var h = $(this)
  121. .html()
  122. .replace(
  123. name,
  124. "<a href='https://www.douban.com/search?cat=1002&q=" +
  125. name +
  126. "#autoselect' target='_blank' style='font-weight:bold;'><font color='#0000FF'>" +
  127. name +
  128. "</font></a>"
  129. );
  130.  
  131. $(this).before(h);
  132. $(this).remove();
  133. isfind = true;
  134. return false;
  135. }
  136. }
  137. });
  138. };
  139.  
  140. });
  141.  
  142. })( );

QingJ © 2025

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