京东加评测视频

在京东的产品页面上加上评测视频,目前只支持B站视频。

  1. // ==UserScript==
  2. // @name 京东加评测视频
  3. // @namespace add_review
  4. // @version 0.3
  5. // @description 在京东的产品页面上加上评测视频,目前只支持B站视频。
  6. // @author clvin
  7. // @homeurl https://gf.qytechs.cn/zh-CN/scripts/412665
  8. // @match http*://item.jd.com/*
  9. // @match http*://search.bilibili.com/all?vflag=1&*
  10. // @require http://cdn.bootcss.com/jquery/1.8.3/jquery.min.js
  11. // @grant GM_xmlhttpRequest
  12. // @run-at document-end
  13. // ==/UserScript==
  14.  
  15. (function() {
  16.  
  17. // This Userscirpt can't run under Greasemonkey 4.x platform
  18. if (typeof GM_xmlhttpRequest === "undefined") {
  19. alert("不支持Greasemonkey 4.x,请换用暴力猴或Tampermonkey");
  20. return;
  21. }
  22.  
  23. var cf = 1;
  24.  
  25. function loadSheet() {
  26. var sheet = `
  27. /* 评测视频iframe展示的样式 */
  28. .video-iframe {
  29. border: 0px;
  30. margin: 0px !important;
  31. width: 100% !important;
  32. height: 230px !important;
  33. }
  34. /* 搜索关键字iframe的样式 */
  35. .keyword{
  36. text-align:center;
  37. }
  38. `;
  39. var css = document.createElement('style');
  40. css.type = 'text/css';
  41. css.id = 'multi-search-css';
  42. css.textContent = sheet;
  43. document.getElementsByTagName('head')[0].appendChild(css);
  44. }
  45.  
  46. function getkeyword()
  47. {
  48. var keyword = "";
  49. var keyurl = "";
  50. var akeyw = ""
  51. $("#detail > div.tab-con > div:nth-child(1) > div.p-parameter > ul.parameter2.p-parameter-list > li").each(function () {
  52. var txtLI = $(this).text();
  53. var ts = "";
  54. if (txtLI.startsWith("商品名称"))
  55. {
  56. ts=txtLI.split(":");
  57. ts = ts[1].split(" ");
  58. keyword = ts[0];
  59. keyurl = encodeURI(keyword+" 评测");
  60. akeyw = "<a href='https://search.bilibili.com/all?vflag=1&keyword="+keyurl+"&order=click&duration=0&tids_1=0' target='video-iframe'>"+keyword+"</a>&nbsp;&nbsp;";
  61. $("#keyw").append(akeyw);
  62.  
  63. GM_xmlhttpRequest({
  64. method: 'GET',
  65. url: "http://api.pullword.com/get.php?source="+keyword+"&param1=0&param2=1&&json=1",
  66. contentType: "application/json",
  67. onload: function(res) {
  68. if (res.status == 200) {
  69. var text = res.responseText;
  70. var json = JSON.parse(text);
  71.  
  72. var desc = function(x,y)
  73. {
  74. return (x.p < y.p) ? 1 : -1
  75. }
  76. json.sort(desc);
  77.  
  78. for(var i=0;i<json.length;i++)
  79. {
  80. if(i<3)
  81. {
  82. keyword = json[i].t;
  83. keyurl = encodeURI(keyword+" 评测");
  84. akeyw = "<a href='https://search.bilibili.com/all?vflag=1&keyword="+keyurl+"&order=click&duration=0&tids_1=0' target='video-iframe'>"+keyword+"</a>&nbsp;&nbsp;";
  85. $("#keyw").append(akeyw);
  86. }
  87. }
  88.  
  89. $("#keyw a").unbind('click').click(function(e) {
  90. e.preventDefault();
  91. var src = $(this).attr('href');
  92.  
  93. var vf = '#vf'+cf;
  94. var vf_1 = '#vf'+(-cf);
  95.  
  96. $(vf_1).attr('src',src );
  97. $(vf).fadeOut(1500);
  98. $(vf_1).delay(1500).fadeIn(1000);
  99.  
  100. cf = -cf;
  101. });
  102. }
  103. }
  104. })
  105. }
  106. else if (txtLI.indexOf("类型")>-1)
  107. {
  108. ts=txtLI.split(":");
  109. ts = ts[1].split(",");
  110. keyword = ts[0];
  111. keyurl = encodeURI(keyword+" 评测");
  112. akeyw = "<a href='https://search.bilibili.com/all?vflag=1&keyword="+keyurl+"&order=click&duration=0&tids_1=0' target='video-iframe'>"+keyword+"</a>&nbsp;&nbsp;";
  113. $("#keyw").append(akeyw);
  114. }
  115. else if (txtLI.startsWith("材质"))
  116. {
  117. ts=txtLI.split(":");
  118. ts = ts[1].split(",");
  119. keyword = ts[0];
  120. keyurl = encodeURI(keyword+" 评测");
  121. akeyw = "<a href='https://search.bilibili.com/all?vflag=1&keyword="+keyurl+"&order=click&duration=0&tids_1=0' target='video-iframe'>"+keyword+"</a>&nbsp;&nbsp;";
  122. $("#keyw").append(akeyw);
  123. }
  124. });
  125.  
  126. return keyword;
  127. }
  128.  
  129. if (window.location.host == "search.bilibili.com")
  130. {
  131. $("#internationalHeader").remove();
  132. $("#server-search-app > div > div.head-contain").remove();
  133. $("#all-list > div.flow-loader > div.filter-wrap").remove();
  134. $("#bili-search > div.international-footer").remove();
  135. $("#server-search-app > div > div.rocket-con").remove();
  136. $("#all-list > div.flow-loader > div.page-wrap").remove();
  137. $("#all-list > div.flow-loader > ul > li:gt(4)").remove();
  138. setTimeout(function () { $("div[id^='van-popover']").remove(); }, 1000);
  139. }
  140. else
  141. {
  142. loadSheet();
  143.  
  144. var div_html = '<div class="m m-content" style="display: block;">';
  145. div_html += '<div class="mt">';
  146. div_html += '<h3 class="fl">评测视频</h3>';
  147. div_html += '<div >';
  148. div_html += '<div id="keyw" class="keyword"></div>';
  149. div_html += '</div>';
  150. div_html += '</div>';
  151. div_html += '<div>';
  152. div_html += '<iframe id="vf1" class="video-iframe" name="video-iframe" scrolling="no" src=""/>';
  153. div_html += '<iframe id="vf-1" style="display:none" class="video-iframe" name="video-iframe" scrolling="no" src=""/>';
  154. div_html += '</div>';
  155. div_html += '</div>';
  156.  
  157. var prev_tag = $("div.product-intro");
  158. if (prev_tag) {
  159. prev_tag.parent().append(div_html);
  160. }
  161.  
  162. var keyword = getkeyword();
  163. var keyurl = encodeURI(keyword+" 评测");;
  164. $('#vf1').attr('src', "https://search.bilibili.com/all?vflag=1&keyword="+keyurl+"&order=click&duration=0&tids_1=0");
  165.  
  166. $("#keyw a").click(function(e) {
  167. e.preventDefault();
  168. var src = $(this).attr('href');
  169.  
  170. var vf = '#vf'+cf;
  171. var vf_1 = '#vf'+(-cf);
  172.  
  173. $(vf_1).attr('src',src );
  174. $(vf).fadeOut(1500);
  175. $(vf_1).delay(1500).fadeIn(1000);
  176.  
  177. cf = -cf;
  178. });
  179. }
  180. })();

QingJ © 2025

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