京东加评测视频

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

目前为 2020-10-15 提交的版本。查看 最新版本

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

QingJ © 2025

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