soup.io: Display hidden elements

Shows hidden reactions, reposts, icons and dates on soup.io pages

当前为 2018-03-27 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name soup.io: Display hidden elements
  3. // @namespace http://xcvbnm.org/
  4. // @author Nordern
  5. // @description Shows hidden reactions, reposts, icons and dates on soup.io pages
  6. // @version 4
  7. // @match http://*.soup.io/*
  8. // @match https://*.soup.io/*
  9. // @license public domain
  10. // ==/UserScript==
  11. /*
  12. * Available on github under: https://github.com/edave64/souplements/blob/master/showHiddenElements.js
  13. * Using the infinite scrolling support template: https://github.com/edave64/souplements/blob/master/infiniteScrollingTemplate.js
  14. */
  15. (function () {
  16. function customCode () {
  17. [].forEach.call(
  18. document.querySelectorAll('.hide-reposted-by,.icons.hidden,.date.hidden,.hide-tags'),
  19. function (ele) {
  20. ele.classList.remove('hide-reposted-by');
  21. ele.classList.remove('hidden');
  22. }
  23. );
  24. }
  25.  
  26. // Reduces calls to customCode by limiting it to execute once per javascript activity and stops it from calling
  27. // itself.
  28. var _runner = null;
  29. function runDelayed () {
  30. if (_runner === null) {
  31. _runner = setTimeout(function () {
  32. try {
  33. customCode();
  34. } finally {
  35. _runner = null;
  36. }
  37. }, 0);
  38. }
  39. }
  40. function register () {
  41. customCode();
  42. new MutationObserver(runDelayed).observe(
  43. document.getElementById('contentcontainer'), {
  44. childList: true,
  45. subtree: true
  46. }
  47. );
  48. }
  49. // Is the soup page already loaded? This allows the custom code to run as both a bookmarklet and a userscript.
  50. if (document.getElementById('contentcontainer')) {
  51. register();
  52. } else {
  53. document.addEventListener("load", register);
  54. }
  55. }());