Skip to content

Instantly share code, notes, and snippets.

@marcustyphoon
Last active June 3, 2024 00:22
Show Gist options
  • Save marcustyphoon/75e45dfe9395e5c1c00f703680c17b0c to your computer and use it in GitHub Desktop.
Save marcustyphoon/75e45dfe9395e5c1c00f703680c17b0c to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Tumblr Blog Subs Default
// @namespace gist.github.com/marcustyphoon
// @version 0.2
// @description Forces the default Tumblr dashboard tab to "Blog Subs"
// @author marcustyphoon
// @match https://www.tumblr.com/*
// @grant none
// @noframes
// ==/UserScript==
/* globals tumblr */
/* eslint-disable no-unmodified-loop-condition */
(async function () {
'use strict';
let retries = 0;
while (typeof tumblr === 'undefined' || typeof tumblr.navigate === 'undefined') {
if (retries++ > 1000) return;
await new Promise((resolve) => setTimeout(resolve));
}
const attemptRedirect = () => {
if (
['/dashboard', '/'].includes(location.pathname) &&
document
.querySelector('main > :is([data-timeline], [data-timeline-id])')
?.matches(
'[data-timeline^="/v2/timeline/dashboard"], [data-timeline^="/v2/tabs/for_you"], [data-timeline-id="/dashboard/following"], [data-timeline-id="/dashboard/stuff_for_you"]',
)
) {
tumblr.navigate('/dashboard/blog_subs');
}
};
attemptRedirect();
new MutationObserver(attemptRedirect).observe(document.getElementById('root'), {
childList: true,
subtree: true,
attributeFilter: ['data-timeline', 'data-timeline-id'],
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment