Reddit - Add Removeddit links

Adds a Removeddit.com link to every comment and post

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name           Reddit - Add Removeddit links
// @icon           https://www.google.com/s2/favicons?domain=www.reddit.com
// @description    Adds a Removeddit.com link to every comment and post
// @author         Arudarin
// @version        1.0.1
// @namespace      Violentmonkey Scripts
// @match          *://*.reddit.com/r/*/comments/*
// @grant          GM_addStyle
// @run-at         document-start
// @require        https://unpkg.com/jquery@3/dist/jquery.min.js
// @require        https://greasyfork.org/scripts/7602-mutation-observer/code/mutation-observer.js
// ==/UserScript==

; ($ => {
  'use strict'

  // --------------------------------------------------------------------------

  const url = new URL(location.href)
  url.host = 'www.removeddit.com'

  const observer = new MutationSummary({
    callback(summaries) {
      $(summaries[0].added)
        .append(`
          <li>
              <a class="removeddit" href="${url}">
                removeddit
              </a>
          </li>
        `)
    },
    rootNode: document.body,
    queries: [
      { element: '.flat-list' }
    ]
  })

})(jQuery);

jQuery.noConflict(true);


/*  The old script, for future use
(function() {
'use strict';
  url = new URL(location.href);
  url.host = 'www.removeddit.com';
  
  $("ul.flat-list.buttons").append(`
    <li>
      <a class="removeddit" href="${url}">
              removeddit
      </a>
    </li>
  `);
}());
*/