Add Unddit, Reveddit & Wayback Machine Links to Reddit

Adds links to unddit, reveddit, wayback machine at the bottom of reddit post to quickly view deleted comments (old.reddit only)

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         Add Unddit, Reveddit & Wayback Machine Links to Reddit
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Adds links to unddit, reveddit, wayback machine at the bottom of reddit post to quickly view deleted comments (old.reddit only)
// @author       jack_the_dripper
// @match        *://*.reddit.com/r/*/comments/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=reddit.com
// @grant        none
// @license      MIT
// ==/UserScript==

let observerOptions = {subtree: true, childList: true};
let mObserver = new MutationObserver(function() {
    let comments = document.querySelectorAll("ul.buttons");

    for(let i = 0; i < comments.length; i++) {
        if(!comments[i].querySelector("a.revedditLink")) {
            let newListItem = document.createElement("li");
            let commentPermalink = comments[i].querySelector("li.first > a.bylink");
            let revedditLink;

            if(commentPermalink) {
                revedditLink = commentPermalink.href.replace("reddit.com","reveddit.com");
                newListItem.innerHTML = `<a href="${revedditLink}" class="revedditLink" target="_blank">reveddit</a>`;
                comments[i].appendChild(newListItem);
            }
        }
    };
    for(let i = 0; i < comments.length; i++) {
        if(!comments[i].querySelector("a.undditLink")) {
            let newListItem = document.createElement("li");
            let commentPermalink = comments[i].querySelector("li.first > a.bylink");
            let undditLink;

            if(commentPermalink) {
                undditLink = commentPermalink.href
                    .replace("www.reddit.com", "undelete.pullpush.io")
                    .replace("old.reddit.com", "undelete.pullpush.io");
                newListItem.innerHTML = `<a href="${undditLink}" class="undditLink" target="_blank">unddit</a>`;
                comments[i].appendChild(newListItem);
            }
        }
    };
    for(let i = 0; i < comments.length; i++) {
        if(!comments[i].querySelector("a.waybackmachineLink")) {
            let newListItem = document.createElement("li");
            let commentPermalink = comments[i].querySelector("li.first > a.bylink");
            let waybackmachineLink;

            if(commentPermalink) {
                waybackmachineLink = commentPermalink.href.replace("https://", "https://web.archive.org/web/2/");
                newListItem.innerHTML = `<a href="${waybackmachineLink}" class="waybackmachineLink" target="_blank">wayback machine</a>`;
                comments[i].appendChild(newListItem);
            }
        }
    }
});

mObserver.observe(document, observerOptions);