Skip Content Warning - tumblr.com

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

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==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! @_@");
    }
})();