Reddit - Add unddit links

Adds a unddit.com link to every comment and post on old Reddit, the site displays removed and deleted comments/posts.

  1. // ==UserScript==
  2. // @name Reddit - Add unddit links
  3. // @icon https://www.google.com/s2/favicons?domain=www.reddit.com
  4. // @description Adds a unddit.com link to every comment and post on old Reddit, the site displays removed and deleted comments/posts.
  5. // @author Arudarin
  6. // @version 1.0.2
  7. // @namespace Violentmonkey Scripts
  8. // @match *://*.reddit.com/r/*/comments/*
  9. // @grant GM_addStyle
  10. // @run-at document-start
  11. // @require https://unpkg.com/jquery@3/dist/jquery.min.js
  12. // @require https://greasyfork.org/scripts/7602-mutation-observer/code/mutation-observer.js
  13. // ==/UserScript==
  14.  
  15. ; ($ => {
  16. 'use strict'
  17.  
  18. // --------------------------------------------------------------------------
  19.  
  20. const url = new URL(location.href)
  21. url.host = 'www.unddit.com'
  22.  
  23. const observer = new MutationSummary({
  24. callback(summaries) {
  25. $(summaries[0].added)
  26. .append(`
  27. <li>
  28. <a class="unddit" href="${url}">
  29. unddit
  30. </a>
  31. </li>
  32. `)
  33. },
  34. rootNode: document.body,
  35. queries: [
  36. { element: '.flat-list' }
  37. ]
  38. })
  39.  
  40. })(jQuery);
  41.  
  42. jQuery.noConflict(true);
  43.  
  44.  
  45. /* The old script, for future use
  46. (function() {
  47. 'use strict';
  48. url = new URL(location.href);
  49. url.host = 'www.unddit.com';
  50. $("ul.flat-list.buttons").append(`
  51. <li>
  52. <a class="unddit" href="${url}">
  53. unddit
  54. </a>
  55. </li>
  56. `);
  57. }());
  58. */