Skip Content Warning - tumblr.com

I made this because when browsing tumblr I didn't want to click a bunch of buttons

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

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το 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        Skip Content Warning - tumblr.com
// @namespace   http://www.tumblr.com/gmscripts
// @match       https://www.tumblr.com/safe-mode
// @match       https://www.tumblr.com/blog/view/*
// @run-at      document-start
// @grant       none
// @version     3.0
// @license     MIT
// @author      Mark Grappo
// @description I made this because when browsing tumblr I didn't want to click a bunch of buttons
//              just to get to the content if the blog was marked as nsfw. So when you open in a new
//              tab it skips all the button clicking for you
// ==/UserScript==

(() => {
    if (location && location.pathname && location.pathname.includes("/safe-mode")) {
        const linkToDashBoard = document.querySelector(".link");
        if (linkToDashBoard.innerText === "Go to my dashboard") {
            linkToDashBoard.target = "_self";
            linkToDashBoard.click();
        }
    }
    else if (location && location.pathname && location.pathname.includes("/blog/view/")) {
        const url = new URL(window.location.href);
        const source = url.searchParams.get("source");
        if (source === "content_warning_wall") {
            const checkForDashboardText = (currentElement) => {
                if (currentElement.innerText.toUpperCase().includes("DASHBOARD")) {
                    return true;
                }
                else if (currentElement.tagName === "A") {
                    if (currentElement.href && !currentElement.href.toUpperCase().includes("DASHBOARD")) {
                        return true;
                    }
                }
            };
            const listAllEventListeners = () => {
                // Inspired by https://www.sqlpac.com/en/documents/javascript-listing-active-event-listeners.html
                const base_container_context = document.querySelector("#base-container").querySelector("header").parentElement.nextSibling.querySelectorAll("*");
                const allElements = [...base_container_context];
                const elements = [];
                for (const currentElement of allElements) {
                    if (typeof currentElement["onclick"] === "function") {
                        if (!checkForDashboardText(currentElement)) {
                            elements.push(currentElement);
                        }
                    }
                }
                return elements;
            };
            const lastCheck = (element) => {
                if (element.innerText.toUpperCase() === "VIEW BLOG") {
                    element.click();
                }
            };
            window.addEventListener("load", () => {
                console.log("Skip Content Warning: Start The Search!");
                const possibleElements = listAllEventListeners();
                if (possibleElements && possibleElements.length) {
                    if (possibleElements.length === 1) {
                        lastCheck(possibleElements[0]);
                    }
                    else {
                        const filteredPossibleElements = possibleElements.filter((currentElement) => {
                            return currentElement.tagName === "BUTTON";
                        });
                        if (filteredPossibleElements && filteredPossibleElements.length) {
                            lastCheck(filteredPossibleElements[0]);
                        }
                    }
                }
            });
        }
    }
    else {
        console.log("FUG! @_@");
    }
})();