🏠 Home 

淘宝收藏夹快速删除

2020/5/22 上午12:57:50


Install this script?
  1. // ==UserScript==
  2. // @name 淘宝收藏夹快速删除
  3. // @namespace http://www.mozl.net
  4. // @match https://shoucang.taobao.com/item_collect*.htm*
  5. // @grant none
  6. // @run-at document-end
  7. // @version 1.0
  8. // @author Mozl
  9. // @description 2020/5/22 上午12:57:50
  10. // ==/UserScript==
  11. /*jshint esversion: 6 */
  12. (function () {
  13. 'use strict';
  14. KISSYisReady(function () {
  15. let observer
  16. S.one('.fav-tools').prepend('<div class="fav-tool-showbtn btn-quick-del btn-ok">快速删除</div>')
  17. showDelBtn()
  18. S.one('.btn-quick-del').on('click', () => {
  19. if (sessionStorage.getItem('quick-del-enable') === null) {
  20. sessionStorage.setItem('quick-del-enable', true)
  21. showDelBtn()
  22. } else {
  23. if (sessionStorage.getItem('quick-del-enable')) {
  24. S.one('.btn-quick-del').text('快速删除')
  25. S.all('.J_DeleteItem_Close.btn-close').fire('click')
  26. S.all('.is-quick-del').removeClass('.is-quick-del')
  27. sessionStorage.removeItem('quick-del-enable')
  28. observer.disconnect()
  29. }
  30. }
  31. })
  32. function showDelBtn () {
  33. if (sessionStorage.getItem('quick-del-enable')) {
  34. S.one('.btn-quick-del').text('关闭快速删除')
  35. setTimeout(function () {
  36. S.all('.J_FavListItem').addClass('is-quick-del').all('.delete-btn').fire('click')
  37. }, 500)
  38. const target = document.querySelector('.img-item-list.J_FavList')
  39. observer = new MutationObserver(function (mutations) {
  40. mutations.forEach(function (mutation) {
  41. const newItems = [].filter.call(mutation.addedNodes, (node) => { return S.one(node).hasClass("J_FavListItem") })
  42. if (newItems.length > 0) {
  43. S.all(newItems).addClass('is-quick-del').all('.delete-btn').fire('click')
  44. }
  45. });
  46. })
  47. observer.observe(target, {
  48. attributes: true,
  49. childList: true,
  50. characterData: true
  51. })
  52. }
  53. }
  54. }, 50)
  55. var css = [
  56. ".fav-tool-showbtn.btn-quick-del",
  57. "{",
  58. " width:88px;",
  59. " border-color: #ff4200;",
  60. " background-color: #ff4200;",
  61. " color: #fff !important;",
  62. "}",
  63. ".is-quick-del.del-pop-show .del-pop-bg",
  64. "{",
  65. " opacity:.2;",
  66. "}",
  67. ".J_FavListItem.is-quick-del .del-pop-box > .txt,",
  68. ".J_FavListItem.is-quick-del .del-pop-box > .btns > .btn-close",
  69. "{",
  70. " display:none",
  71. "}",
  72. ".J_FavListItem.is-quick-del .del-pop-box > .btns > .btn-ok",
  73. "{",
  74. " text-indent: -9999px;",
  75. " line-height: 0;",
  76. "}",
  77. ".J_FavListItem.is-quick-del .del-pop-box > .btns > .btn-ok::after",
  78. "{",
  79. " content: '删除';",
  80. " text-indent: 0;",
  81. " display:block;",
  82. " line-height: 22px;",
  83. "}"
  84. ].join("\n");
  85. if (typeof GM_addStyle != "undefined") {
  86. GM_addStyle(css);
  87. } else if (typeof PRO_addStyle != "undefined") {
  88. PRO_addStyle(css);
  89. } else if (typeof addStyle != "undefined") {
  90. addStyle(css);
  91. } else {
  92. var node = document.createElement("style");
  93. node.type = "text/css";
  94. node.appendChild(document.createTextNode(css));
  95. var heads = document.getElementsByTagName("head");
  96. if (heads.length > 0) {
  97. heads[0].appendChild(node);
  98. } else {
  99. // no head yet, stick it whereever
  100. document.documentElement.appendChild(node);
  101. }
  102. }
  103. function KISSYisReady (fn, time) {
  104. if (typeof KISSY.one === "function") {
  105. fn();
  106. } else {
  107. setTimeout(() => {
  108. KISSYisReady(fn, time);
  109. }, time)
  110. }
  111. }
  112. })()