闲鱼/咸鱼-助手

适应新版闲鱼首页,添加搜索框,改变移动端二维码出现位置,删除下载推广连接,删除修正咸鱼宝贝图片的大小

  1. // ==UserScript==
  2. // @name 闲鱼/咸鱼-助手
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.3
  5. // @description 适应新版闲鱼首页,添加搜索框,改变移动端二维码出现位置,删除下载推广连接,删除修正咸鱼宝贝图片的大小
  6. // @author ruibty
  7. // @require https://cdn.bootcss.com/jquery/3.1.1/jquery.min.js
  8. // @match https://2.taobao.com/*
  9. // @match https://s.2.taobao.com/*
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. var locationPage = "home";
  17. if(document.URL.indexOf("taobao.com/list") != -1){
  18. //搜索列表
  19. locationPage = "list";
  20. }else if(document.URL.indexOf("taobao.com/item") != -1){
  21. //宝贝详情页
  22. locationPage = "item";
  23. }
  24.  
  25.  
  26. var assistant = {
  27. ready : function(){
  28. switch(locationPage){
  29. case "home":
  30. $('div[data-v-0bf36d39]').remove();
  31. $('div[data-v-2f52e05e]').remove();
  32. $('div[data-v-6f55242a]').remove();
  33. assistant.addSearchBar();
  34. break;
  35. case "list":
  36. assistant.removeXYGuide();
  37. break;
  38. case "item":
  39. assistant.removeTheMauGuide();
  40. assistant.removeXYGuide();
  41. assistant.removeGuarantee();
  42. assistant.removeIdleFooter();
  43. assistant.setDisplayContact();
  44. break;
  45. default:
  46. break;
  47. }
  48. },
  49. onload : function(){
  50. switch(locationPage){
  51. case "home":
  52. assistant.initSearchBar();
  53. break;
  54. case "list":
  55. assistant.changeImgWidthAndHeight();
  56. break;
  57. case "item":
  58. assistant.changeImgWidthAndHeight();
  59. break;
  60. default:
  61. break;
  62. }
  63. assistant.removeTheDownloadLayer();
  64. },
  65. removeTheMauGuide : function(){
  66. //去掉宝贝轮播图第一张碍眼的遮挡文字,放到最后
  67. var imgSrc = $('.guide-img').attr("src");
  68. $('.mau-guide').remove();
  69.  
  70. //放到轮播图最后
  71. var lastLi = $('ul[class="album"] li:last');
  72. var reg = /(?<=(lazyload-img="))[^"]*?(?=")/ig;
  73. var guideHtml = lastLi[0].outerHTML.replace(reg, imgSrc);
  74. $('ul[class="album"]').append(guideHtml);
  75.  
  76. //处理thumb
  77. var thumbUl = $('.thumb-list ul');
  78. var thumbUlLastLiHtml = thumbUl.children('li')[0].outerHTML;
  79. var thumbReg = /(?<=(src="))[^"]*?(?=")/ig;
  80. thumbUl.append(thumbUlLastLiHtml.replace(thumbReg, imgSrc));
  81. },
  82. removeTheDownloadLayer : function(){
  83. //宝贝详情页-去掉遮挡推广链接
  84. $('.download-layer').remove();
  85. },
  86. removeXYGuide : function(){
  87. //宝贝详情页-去掉介绍页咸鱼app的推广广告
  88. $('.xy-guide').remove();
  89. },
  90. removeGuarantee : function(){
  91. //宝贝详情页-去掉“安全保障”说明
  92. $('#guarantee').remove();
  93. },
  94. removeIdleFooter : function(){
  95. //宝贝详情页-去掉底部灰色的淘宝官方推广
  96. $('.idle-footer').remove();
  97. },
  98. setDisplayContact : function(){
  99. //宝贝详情页-增加联系窗口
  100. $('.contact div').show();
  101. },
  102. changeImgWidthAndHeight : function(){
  103. //修正图片的大小
  104. $('img').each(function(){
  105. var imgSrc = $(this).attr("src");
  106. if(imgSrc && imgSrc.length >= 3){
  107. var imgSrcEnd = imgSrc.substr(imgSrc.length - 3, imgSrc.length);
  108. if(imgSrcEnd == "jpg"){
  109.  
  110. var imgWidth = $(this)[0].naturalWidth //图片真实宽度
  111. var imgHeight = $(this)[0].naturalHeight //图片真实高度
  112. $(this).attr("width",imgWidth);
  113. $(this).attr("height",imgHeight);
  114. }
  115. }
  116. });
  117. },
  118. addSearchBar : function(){
  119. var searchBar = "<div id='searchBar' style='position: absolute; padding: 0; margin: 0; box-sizing: border-box; height: 42px; width: 300px; border: solid 1px #000000;'>";
  120. searchBar += "<input type='text' style='padding: 0; margin: 0; border: 0; height: 40px; width: 80%; background-color: #EEEEEE;'>";
  121. searchBar += "<button style='padding: 0; margin: 0; border: 0; height: 40px; width: 20%; background-color: #59b3f3;'>查询</button>";
  122. searchBar += "</div>"
  123. $("body").append(searchBar);
  124. },
  125. initSearchBar : function(){
  126.  
  127. var marginRight = 50;
  128. var marginTop = 150;
  129. var searchBarDiv = document.getElementById("searchBar");
  130.  
  131. searchBarDiv.getElementsByTagName("button")[0].onclick = function () {
  132. var inputText = searchBarDiv.getElementsByTagName("input")[0].value.trim();
  133. window.location.href = "https://s.2.taobao.com/list/list.htm?q=" + inputText;
  134. };
  135.  
  136. //var top = document.documentElement.scrollTop + marginTop;
  137. var top = document.documentElement.clientHeight - marginTop;
  138. searchBarDiv.style.bottom = top + "px";
  139. var left = document.documentElement.clientWidth - searchBarDiv.offsetWidth - marginRight;
  140. searchBarDiv.style.left = left + "px";
  141. // setTimeout(this,100);
  142. }
  143. }
  144.  
  145. function changeState() {
  146. if(document.readyState == "complete"){
  147. assistant.changeImgWidthAndHeight();
  148. }
  149. }
  150.  
  151. document.onreadystatechange = changeState;
  152.  
  153. $(function(){
  154. assistant.ready();
  155. });
  156.  
  157. window.onload = function(){
  158. assistant.onload();
  159. }
  160.  
  161. })();

QingJ © 2025

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