Skip to content

Instantly share code, notes, and snippets.

@AprilSylph
Last active July 25, 2021 22:04
Show Gist options
  • Save AprilSylph/bc7b4cee25aa7f8ae430f4739cb1d0de to your computer and use it in GitHub Desktop.
Save AprilSylph/bc7b4cee25aa7f8ae430f4739cb1d0de to your computer and use it in GitHub Desktop.
Force Tumblr on-blog controls to be mobile-style
const iframe = document.querySelector('iframe[src^="https://www.tumblr.com/dashboard/iframe"]');
const modifiedSrc = new URL(iframe.src);
const { hash } = modifiedSrc;
const decodedHash = decodeURIComponent(hash);
const parsedHash = JSON.parse(decodedHash.substring(1));
Object.assign(parsedHash, { isOpticaLike: true, useThemeColors: true });
const newHash = JSON.stringify(parsedHash);
const encodedHash = encodeURIComponent(newHash);
modifiedSrc.hash = `#${encodedHash}`;
const newFrame = iframe.cloneNode();
newFrame.src = modifiedSrc.href;
iframe.replaceWith(newFrame);
document.body.classList.remove('tmblr-iframe-overlay', 'tmblr-iframe-compact');
document.body.classList.add('tmblr-iframe-pushdown', 'tmblr-iframe-full-width');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment