Yahoo Answers Trash Filter

Hide Yahoo Answers questions matching a list of words

  1. // ==UserScript==
  2. // @name Yahoo Answers Trash Filter
  3. // @version 0.1
  4. // @description Hide Yahoo Answers questions matching a list of words
  5. // @include http://answers.yahoo.com/*
  6. // @include https://answers.yahoo.com/*
  7. // @author tlacuache
  8. // @namespace https://gf.qytechs.cn/users/688118
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. function getDivsByRegex(regex) {
  15. var divs = document.getElementsByTagName('div'),
  16. matches = [],
  17. index,
  18. div;
  19. for (index = 0; index < divs.length; index += 1) {
  20. div = divs[index];
  21. if (regex.test(div.className)) {
  22. matches.push(div);
  23. }
  24. }
  25. return matches;
  26. }
  27.  
  28. function cleanIt() {
  29. var questionCards = getDivsByRegex(/^QuestionCard__/),
  30. i, j, k,
  31. card, child, grandChild,
  32. hideme, questionText,
  33. hideCount = 0,
  34. skipRegex = /\b(trump|kamala|harris|pelosi|donald|blm|obama|clinton|biden|corona|coronavirus|covid\d*|conservatives?|liberals?|libtards?|dems?|democrats?|republicans?|coronavirus)\b/i;
  35.  
  36. for (i = 0; i < questionCards.length; i += 1) {
  37. card = questionCards[i];
  38. if (card.parentNode.style.display != 'none') {
  39. hideme = false;
  40. for (j = 0; j < card.childNodes.length; j += 1) {
  41. child = card.childNodes[j];
  42. for (k = 0; k < child.childNodes.length; k += 1) {
  43. grandChild = child.childNodes[k];
  44. if (/^QuestionCard__title__/.test(grandChild.className)) {
  45. questionText = grandChild.textContent;
  46. if (skipRegex.test(questionText)) {
  47. hideme = true;
  48. break;
  49. }
  50. }
  51. if (hideme) break;
  52. }
  53. if (hideme) break;
  54. }
  55. if (hideme) {
  56. card.parentNode.style.display = 'none';
  57. hideCount++;
  58. }
  59. }
  60. }
  61. // if (hideCount > 0) console.log('hid', hideCount, 'garbage questions');
  62. }
  63.  
  64. document.addEventListener('DOMNodeInserted', cleanIt, false);
  65.  
  66. cleanIt();
  67.  
  68. })();

QingJ © 2025

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