From 8d5abf9a30591bf293a3385113ed245a365f131a Mon Sep 17 00:00:00 2001 From: blankie Date: Thu, 28 Dec 2023 23:08:04 +1100 Subject: [PATCH] Add Tumblr Unnagger --- README.md | 4 +++ Tumblr Unnagger.user.js | 79 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 Tumblr Unnagger.user.js diff --git a/README.md b/README.md index cb19498..06a73d1 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,10 @@ build logs to view them without logging in ![A man yelling "I DON'T WANNA", followed by sign up/login boxes](https://gitlab.com/blankX/userscripts/-/raw/master/accounts.jpg) +## Tumblr Unnagger + +A script that removes several login/account walls on Tumblr + ## Wayback Machine Toolbar Toggler A userscript that replaces the "close this toolbar" button with one that lets diff --git a/Tumblr Unnagger.user.js b/Tumblr Unnagger.user.js new file mode 100644 index 0000000..968fed0 --- /dev/null +++ b/Tumblr Unnagger.user.js @@ -0,0 +1,79 @@ +// ==UserScript== +// @name Tumblr Unnagger +// @namespace blankie-scripts +// @match https://*.tumblr.com/* +// @grant GM_addStyle +// @version 1.0.0 +// @author blankie +// @description Removes login nags +// @inject-into content +// @run-at document-end +// ==/UserScript== + +"use strict"; + +let css = ` +/* Remove the "Sign up" and "Follow " buttons */ +.sign-up-button, .follow-button { + display: none !important; +} + +/* Remove the top iframe bar on the default theme (e.g. https://azulcrescent.tumblr.com/) */ +.tmblr-iframe { + display: none !important; +} + +/* Fix margin from the top iframe bar being hidden */ +.nav-wrapper.nav-fixed { + top: 0; +} + +/* Hide fullscreen nag when scrolling */ +#glass-container { + display: none; +} + +/* Restore scrolling when fullscreen nag is shown */ +html { + overflow: scroll !important; + } +`; + +if (/^\/archive(\/.*)?$/.test(window.location.pathname)) { + css += ` + /* Remove the "It's time to try Tumblr" nag on /archive */ + #base-container > div:has(style) > div:nth-child(4) { + display: none; + } + `; +} + +GM_addStyle(css); + + + +function removeLoginWall(element) { + element.removeAttribute("data-login-wall-type"); + for (let child of element.querySelectorAll("[data-login-wall-type]")) { + child.removeAttribute("data-login-wall-type"); + } +} + +// Remove login walls for elements before Javascript +removeLoginWall(document.body); + +// Remove login walls for elements added by Javascript +let observer = new MutationObserver(function(mutations) { + for (let mutation of mutations) { + if (mutation.type !== "childList") { + continue; + } + for (let node of mutation.addedNodes) { + if (node.nodeType !== 1) { + continue; + } + removeLoginWall(node); + } + } +}); +observer.observe(document.body, {childList: true, subtree: true}); \ No newline at end of file