4chan Session ID Unbreaker

Tries to detect and un-break Session IDs posted on 4chan

Από την 26/02/2024. Δείτε την τελευταία έκδοση.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         4chan Session ID Unbreaker
// @license      GPLv3
// @namespace    https://boards.4chan.org/
// @version      1.3
// @description  Tries to detect and un-break Session IDs posted on 4chan
// @author       ceodoe
// @match        https://boards.4chan.org/*/thread/*
// @match        https://boards.4chan.org/*/res/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=4chan.org
// @grant        none
// ==/UserScript==

function parsePosts() {
    let posts = document.querySelectorAll("blockquote.postMessage");
    for(let i = 0; i < posts.length; i++) {
        if(posts[i].getAttribute("data-4sidu-parsed") !== "1") {
            posts[i].setAttribute("data-4sidu-parsed", "1");

            // Strip all backlinks as they are likely to contain the magic number 05 that all Session IDs start with
            let postText = posts[i].innerText.replace(/\>\>\b[0-9]+\b/g, "");
            let idStartIndex = postText.indexOf("05");

            if(idStartIndex > -1) {
                let id = postText.substring(idStartIndex).replace(/[^A-Fa-f0-9]/g, "").substring(0, 66);

                if(id.length == 66) { // All Session IDs are 66 characters long; if we didn't get that many characters, the ID is invalid
                    let html = `
                        <div style="margin-top: 1em; border-top: 1px solid; padding: 0.5em; width: fit-content;">
                            <span style="color: #66cc33; font-weight: bold;">Session ID:</span> ${id}
                        </div>
                    `;

                    posts[i].insertAdjacentHTML("beforeend", html);
                }
            }
        }
    }
}

new MutationObserver(function(event) { parsePosts(); }).observe(document.querySelector("div.thread"), {childList: true});
parsePosts();