Greasy Fork is available in English.

Brainly Filter by Points

Hides questions that award below a certain number of points.

  1. // ==UserScript==
  2. // @name Brainly Filter by Points
  3. // @namespace tacheometry
  4. // @match *://*brainly.pl/*
  5. // @match *://*znanija.com/*
  6. // @match *://*brainly.lat/*
  7. // @match *://*brainly.com.br/*
  8. // @match *://*nosdevoirs.fr/*
  9. // @match *://*eodev.com/*
  10. // @match *://*brainly.ro/*
  11. // @match *://*brainly.co.id/*
  12. // @match *://*brainly.in/*
  13. // @match *://*brainly.ph/*
  14. // @match *://*brainly.com/*
  15. // @grant GM.getValue
  16. // @grant GM.setValue
  17. // @grant GM.registerMenuCommand
  18. // @license MIT
  19. // @version 1.0
  20. // @author tacheometry
  21. // @description Hides questions that award below a certain number of points.
  22. // ==/UserScript==
  23.  
  24. (function () {
  25. "use strict";
  26.  
  27. const KEY_NAME = "MinimumQuestionAward";
  28. const scanQuestions = async () => {
  29. const minPoints = await GM.getValue(KEY_NAME, 10);
  30.  
  31. for (const pointsCounter of document.querySelectorAll(
  32. "[data-testid='points_counter']"
  33. )) {
  34. const number = parseInt(pointsCounter.innerText);
  35. if (number >= minPoints) continue;
  36.  
  37. const parent =
  38. pointsCounter.closest("[data-testid='feed-item']") ??
  39. pointsCounter.closest(
  40. "[data-testid='answering_feed_question_list_item']"
  41. );
  42. if (!parent) continue;
  43.  
  44. parent.remove();
  45. }
  46. };
  47.  
  48. const observer = new MutationObserver(scanQuestions);
  49. scanQuestions();
  50. observer.observe(document, {
  51. childList: true,
  52. subtree: true,
  53. attributes: false,
  54. });
  55.  
  56. GM.registerMenuCommand(
  57. "Change minimum award filter",
  58. () => {
  59. const result = prompt(
  60. "Set minimum points awarded for a question to be shown:"
  61. );
  62. if (result) GM.setValue(KEY_NAME, parseInt(result));
  63. },
  64. {
  65. id: "minAwardChangeButton",
  66. }
  67. );
  68. })();