SPAM

So Pictures A Many! ... Shh, it's a perfect acronym. This script will hide a comment when it contains more than 3 images / embeds, with the option to show it anyway. With 6 images or more, it gets deleted.

  1. // ==UserScript==
  2. // @name SPAM
  3. // @version 3.6
  4. // @description So Pictures A Many! ... Shh, it's a perfect acronym. This script will hide a comment when it contains more than 3 images / embeds, with the option to show it anyway. With 6 images or more, it gets deleted.
  5. // @author Valognir (https://www.deviantart.com/valognir)
  6. // @namespace https://gf.qytechs.cn/en/scripts/417286-spam
  7. // @run-at document-start
  8. // @match *://*.deviantart.com/*
  9. // @exclude *://*.deviantart.com/*realEstateId*
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // looking to change the numbers or somethin? here you go.
  16. // number of images / embeds within a comment before its content...
  17.  
  18. // ...gets hidden, with the option to show it anyway.
  19. let hides = 3;
  20.  
  21. // ...gets deleted.
  22. let yeets = 10;
  23.  
  24. // that's all, better don't touch the stuff below.
  25.  
  26. let css = `
  27. .yeeted {
  28. display: flex;
  29. flex-wrap: wrap;
  30. }
  31. .heya, .toggle {
  32. text-align: center;
  33. opacity: .6;
  34. font-size: 12px;
  35. }
  36.  
  37. .heya {
  38. font-family: "Comic Sans MS";
  39. flex-grow: 1;
  40. }
  41.  
  42. .toggle {
  43. width: 45px;
  44. color: var(--g-typography-primary);
  45. border: 1px solid currentColor;
  46. background: none;
  47. font-weight: bold;
  48. }
  49.  
  50. .toggle:hover {
  51. color: var(--C14);
  52. }
  53.  
  54. .toggle + div {
  55. height: 0;
  56. }
  57.  
  58. .heya i {
  59. font-style: italic;
  60. }
  61. `;
  62.  
  63.  
  64. function waitForBody() {
  65. if (document.body) {
  66. const styleNode = document.createElement('style');
  67. const headElement = document.head;
  68. console.log("[SPAM]", headElement);
  69. styleNode.appendChild(document.createTextNode(css));
  70. headElement.appendChild(styleNode);
  71.  
  72. const observer = new MutationObserver(function(mutations) {
  73. const comments = document.querySelectorAll('div[data-commentid] .ds-surface-secondary>div:last-child:not(.yeeted)');
  74. comments.forEach(function (element){
  75. console.log(element);
  76. const imgs = element.querySelectorAll('div[data-editor-viewer] img[srcset]');
  77. if (imgs.length >= yeets) {
  78. element.classList.add('yeeted');
  79. element.innerHTML = '<span class="heya">spam identified.<br>yeet!</span>';
  80. } else if (imgs.length >= hides) {
  81. element.classList.add('yeeted');
  82. element.insertAdjacentHTML('afterbegin', '<span class="heya more">can\'t <i>picture</i> what\'s in here. wanna check?</span><button class="toggle">Yes</button>');
  83. }
  84. });
  85.  
  86. const toggleButtons = document.querySelectorAll('.heya+.toggle');
  87.  
  88. if (toggleButtons.length > 0) {
  89. toggleButtons.forEach(function(element) {
  90. if (!element.classList.contains('click')) {
  91. element.classList.add('click');
  92. element.addEventListener('click', function () {
  93. if (element.nextElementSibling.style.height !== 'auto') {
  94. element.nextElementSibling.style.height = 'auto';
  95. element.previousElementSibling.innerHTML = 'huh, so that\'s what\'s in here. wanna hide it again?';
  96. } else {
  97. element.nextElementSibling.style.height = '0px';
  98. element.previousElementSibling.innerHTML = 'can\'t <i>picture</i> what\'s in here. wanna check?';
  99. }
  100. });
  101. }
  102. });
  103. }
  104. });
  105. observer.observe(document, { childList: true, subtree: true });
  106. console.log("[SPAM] Loading screen added.");
  107. } else {
  108. setTimeout(waitForBody, 100); // Retry after 100ms
  109. console.log("[SPAM] Body not found. Retrying.");
  110. }
  111. }
  112. waitForBody();
  113. })();

QingJ © 2025

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