click x button to remove a post for PC and mobile tumblr

点击x按钮移除一个tumblr帖子

  1. // ==UserScript==
  2. // @name click x button to remove a post for PC and mobile tumblr
  3. // @description 点击x按钮移除一个tumblr帖子
  4. // @version 0.1
  5. // @include http://*.tumblr.com/*
  6. // @include https://*.tumblr.com/*
  7. // @author yechenyin
  8. // @namespace https://gf.qytechs.cn/users/3586-yechenyin
  9. // @require https://code.jquery.com/jquery-1.11.2.min.js
  10. // ==/UserScript==
  11.  
  12. jQuery.fn.inserted = function(action) {
  13. var selector = this.selector;
  14. if ($(selector).length > 0) {
  15. console.log($(selector).length + ' ' + selector + " is loaded at begin");
  16. action.call($(selector));
  17. }
  18. var reaction = function(records) {
  19. records.map(function(record) {
  20. if (record.target !== document.body && $(record.target).find(selector).length) {
  21. if (record.target.id)
  22. console.log('#' + record.target.id + ' which contains ' + selector + ' is loaded');
  23. else if (record.target.className)
  24. console.log('#' + record.target.className + ' which contains ' + selector + ' is loaded');
  25. else
  26. console.log('#' + record.target.tagName + ' which contains ' + selector + ' is loaded');
  27. //if (trigger_once)
  28. //observer.disconnect();
  29. action.call($(record.target).find(selector));
  30. }
  31. });
  32. };
  33.  
  34. var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
  35. if (MutationObserver) {
  36. var observer = new MutationObserver(reaction);
  37. observer.observe(document.body, {
  38. childList: true,
  39. subtree: true
  40. });
  41. } else {
  42. //setInterval(reaction, 100);
  43. }
  44. };
  45.  
  46. if ($('body').hasClass('is_mobile')) {
  47. $('head').append($('<style>', {
  48. class: 'close_button_css',
  49. text: `
  50. .post-close:before {
  51. content: "\\EA1E";
  52. font-family: tumblr-icons,Blank;
  53. -webkit-font-smoothing: antialiased;
  54. -moz-osx-font-smoothing: grayscale;
  55. font-smoothing: antialiased;
  56. text-rendering: optimizeLegibility;
  57. font-style: normal;
  58. font-variant: normal;
  59. font-weight: 400;
  60. text-decoration: none;
  61. text-transform: none;
  62. }.post-close {
  63. position: absolute;
  64. top: 10px;
  65. right: 14px;
  66. opacity: 0.3;
  67. width: 20px;
  68. height: 20px;
  69. font-size: 24px;
  70. line-height: 1;
  71. overflow: hidden;
  72. text-decoration: none;
  73. }
  74. `
  75. }));
  76.  
  77. $('.mh_post_page').inserted(function() {
  78. $(this).find(".mh_post_head").append($('<a class="post-close"></a>').click(function() {
  79. $(this).parent().parent().remove();
  80. }));
  81. });
  82. } else {
  83. $('head').append($('<style>', {
  84. class: 'close_button_css',
  85. text: `
  86. .post-close:before {
  87. content: "\\EA1E";
  88. font-family: tumblr-icons,Blank;
  89. -webkit-font-smoothing: antialiased;
  90. -moz-osx-font-smoothing: grayscale;
  91. font-smoothing: antialiased;
  92. text-rendering: optimizeLegibility;
  93. font-style: normal;
  94. font-variant: normal;
  95. font-weight: 400;
  96. text-decoration: none;
  97. text-transform: none;
  98. }.post-close {
  99. position: absolute;
  100. top: -2px;
  101. right: 10px;
  102. opacity: 0.3;
  103. width: 20px;
  104. height: 20px;
  105. font-size: 20px;
  106. line-height: 1;
  107. overflow: hidden;
  108. text-decoration: none;
  109. }
  110. `
  111. }));
  112.  
  113. $(".post_wrapper, .post_container").inserted(function() {
  114. $(this).find(".post_header").append($('<a class="post-close"></a>').click(function() {
  115. $(this).parent().parent().parent().parent().remove();
  116. }));
  117. });
  118. }

QingJ © 2025

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