Last active
July 25, 2021 22:04
-
-
Save AprilSylph/bc7b4cee25aa7f8ae430f4739cb1d0de to your computer and use it in GitHub Desktop.
Force Tumblr on-blog controls to be mobile-style
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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