Remove Trollface Emoji from GitHub

Remove trollface emoji from GitHub pages

目前为 2025-04-02 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Remove Trollface Emoji from GitHub
  3. // @namespace https://github.com/Simyon264
  4. // @version 2025-03-29
  5. // @description Remove trollface emoji from GitHub pages
  6. // @author Simyon
  7. // @match https://github.com/*
  8. // @grant GM_setValue
  9. // @grant GM_getValue
  10. // @icon https://github.githubassets.com/images/icons/emoji/trollface.png
  11. // @license MIT
  12. // ==/UserScript==
  13.  
  14. /*
  15.  
  16.  
  17. Copyright 2025 Simyon
  18.  
  19. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
  20.  
  21. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
  22.  
  23. THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  24.  
  25. */
  26.  
  27. (function () {
  28. 'use strict';
  29. function removeTrollfaceEmojis() {
  30. var trollfaceEmojis = document.querySelectorAll('img[title=":trollface:"]');
  31. trollfaceEmojis.forEach(function (emoji) {
  32. emoji.remove();
  33. var removalCount = GM_getValue('totalRemovalCount', 0);
  34. removalCount++;
  35. GM_setValue('totalRemovalCount', removalCount);
  36. console.log(`Removed a troll emoji! Total: ${removalCount}! `)
  37. });
  38. }
  39.  
  40. removeTrollfaceEmojis();
  41.  
  42. var observer = new MutationObserver(function (mutationsList, observer) {
  43. for (var mutation of mutationsList) {
  44. if (mutation.type === 'childList') {
  45. removeTrollfaceEmojis();
  46. }
  47. }
  48. });
  49.  
  50. observer.observe(document.body, { subtree: true, childList: true });
  51. })();