GreasyFork脚本列表优化助手

此脚本会在GreasyFork网站的脚本列表页面每个脚本的下面添加几个快捷操作的按钮。作者:浴火凤凰(QQ:307053741,油猴脚本讨论QQ群:194885662)

当前为 2019-12-06 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name GreasyFork脚本列表优化助手
  3. // @namespace https://github.com/kingphoenix2000/tampermonkey_scripts
  4. // @supportURL https://github.com/kingphoenix2000/tampermonkey_scripts
  5. // @version 0.1.0
  6. // @author 浴火凤凰(QQ:307053741,油猴脚本讨论QQ群:194885662)
  7. // @description 此脚本会在GreasyFork网站的脚本列表页面每个脚本的下面添加几个快捷操作的按钮。作者:浴火凤凰(QQ:307053741,油猴脚本讨论QQ群:194885662)
  8. // @homepage https://blog.csdn.net/kingwolf_javascript/
  9. // @include https://greasyfork.org/*
  10. // @grant GM_xmlhttpRequest
  11. // @connect greasyfork.org
  12. // ==/UserScript==
  13.  
  14.  
  15. (function () {
  16. 'use strict';
  17.  
  18. function removeADS(arr) {
  19. arr.forEach(function (v) {
  20. let elem = document.querySelector(v);
  21. if (elem) { elem.remove(); }
  22. });
  23. }
  24.  
  25. let items = document.querySelectorAll("#browse-script-list > li");
  26. let len = items.length;
  27. for (let i = 0; i < len; i++) {
  28. items[i].addEventListener("click", function (e) {
  29. if (e.ctrlKey === true) {
  30. e.preventDefault();
  31. this.remove();
  32. return false;
  33. }
  34. return true;
  35. }, true);
  36. }
  37.  
  38.  
  39. var links = document.querySelectorAll("#browse-script-list > li > article > h2 > a");
  40. links = Array.from(links);
  41. links.forEach(function (item) {
  42. var href = item.href;
  43. GM_xmlhttpRequest({
  44. "method": "GET",
  45. "url": href,
  46. "onload": function (response) {
  47. var text = response.responseText;
  48. var scriptURL = text.match(/\/scripts\/[^"']+\.(user\.js)/)[0];
  49. console.log(scriptURL);
  50. let a = document.createElement('a');
  51. a.href = "https://greasyfork.org" + scriptURL;
  52. a.innerText = "安装脚本";
  53. let a2 = document.createElement('a');
  54. a2.href = "javascript:void(0);";
  55. a2.innerText = "删除脚本";
  56. a2.onclick = function () { item.parentNode.parentNode.parentNode.remove(); }
  57. a2.style.marginLeft = "15px";
  58. let a3 = document.createElement('a');
  59. a3.href = "https://greasyfork.org/zh-CN/users/289205-%E6%B5%B4%E7%81%AB%E5%87%A4%E5%87%B0";
  60. a3.innerText = "浴火凤凰的其它脚本";
  61. a3.style.marginLeft = "15px";
  62. item.parentNode.appendChild(a);
  63. item.parentNode.appendChild(a2);
  64. item.parentNode.appendChild(a3);
  65. },
  66. onerror: function (response) {
  67. console.error("查询信息发生错误。");
  68. },
  69. ontimeout: function (response) {
  70. console.info("查询信息超时。");
  71. }
  72. });
  73. });
  74. // Your code here...
  75. })();