GC Block Pet Names

Allows you to block specific pet names and replace them with "A Neopet".

  1. // ==UserScript==
  2. // @name GC Block Pet Names
  3. // @namespace https://greasyfork.org/en/users/1175371/
  4. // @version 0.2
  5. // @description Allows you to block specific pet names and replace them with "A Neopet".
  6. // @author sanjix
  7. // @match https://www.grundos.cafe/userlookup/?user=*
  8. // @match https://www.grundos.cafe/petlookup/?pet_name=*
  9. // @match https://www.grundos.cafe/palette/*
  10. // @match https://www.grundos.cafe/~*
  11. // @match https://www.grundos.cafe/*/?pet_name=*
  12. // @match https://www.grundos.cafe/book_award/*
  13. // @match https://www.grundos.cafe/music_pros/*
  14. // @match https://www.grundos.cafe/plushie_pros/*
  15. // @match https://www.grundos.cafe/gourmet_club/*
  16. // @match https://www.grundos.cafe/dome/1p/highscores/*
  17. // @match https://www.grundos.cafe/island/training/?type=toppets
  18. // @icon https://www.google.com/s2/favicons?sz=64&domain=grundos.cafe
  19. // @grant none
  20. // @license MIT
  21. // ==/UserScript==
  22.  
  23. // Enter pet names exactly as they appear on the site between the [] brackets on line 25 below.
  24. // Each name should be in quotation marks (single or double is fine). Separate names with commas.
  25. // For example the line below would hide the pets with the names "Pet 1", "Pet2", and "No":
  26. // var block = ['Pet 1', 'Pet2', 'No'];
  27. var block = [];
  28. var petNames = document.querySelectorAll('.ul--petname, .pet--name, .pet--traits--name, .pet--petpetheader strong');
  29. var header = document.querySelector('h1');
  30. var text = document.querySelectorAll('#page_content a, #page_content p, #page_content strong, #page_content em, #page_content h2, #page_content b, #page_content h3, #page_content h4, #page_content h5, #page_content h6');
  31.  
  32. // If you want to customize the replacement text, change the text between the single quotes in the line below
  33. var replace = 'A Neopet';
  34. petNames.forEach((name) => {
  35. if (block.includes(name.textContent)) {
  36. name.textContent = replace;
  37. }
  38. });
  39. block.forEach((name) => {
  40. if (header != null && header.textContent.includes(name)) {
  41. header.textContent = header.textContent.replace(name, replace);
  42. }
  43. // var pageText = document.evaluate('//em[contains(.,' + name + ')]',
  44. // document,
  45. // null,
  46. // XPathResult.ANY_UNORDERED_NODE_TYPE,
  47. // null
  48. // );
  49. // if (pageText.singleNodeValue != null && pageText.singleNodeValue.textContent.includes(name)) {
  50. // pageText.singleNodeValue.textContent = pageText.singleNodeValue.textContent.replace(name, replace);
  51. // }
  52. });
  53. text.forEach((node) => {
  54. if (node.children.length == 0) {
  55. block.forEach((name) => {
  56. if (node.textContent.includes(name)) {
  57. node.textContent = node.textContent.replaceAll(name, replace);
  58. }
  59. });
  60. }
  61. });