Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PC friendly instagram
// ==UserScript==
// @name pc-friendly-instagram
// @namespace https://gist.github.com/justdanpo
// @version 0.3
// @description pc-friendly-instagram
// @author den_po
// @include https://*.instagram.com/*
// @run-at document-start
// @grant none
// ==/UserScript==
(function () {
const ua = navigator.userAgent += " Instagram"
document.documentElement.setAttribute('onreset', "navigator.__defineGetter__('userAgent', function(){ return '" + ua.replace(/'/g, "\'") + "' });")
document.documentElement.dispatchEvent(new CustomEvent('reset'))
document.documentElement.removeAttribute('onreset')
new MutationObserver((mutations, observer) => mutations.forEach(mutation => mutation.addedNodes.forEach(itm => {
if (itm.tagName == "SECTION") {
//expand feed width
itm.querySelectorAll("main > section").forEach(s => { s.style.maxWidth = "calc(100vh - 120px)" })
//limit preview size
itm.querySelectorAll("div > button > span.createSpriteExpand").forEach(expandButton => {
expandButton.parentNode.parentNode.style.width = expandButton.parentNode.parentNode.style.height = "calc(100vh - 100px)"
itm.style.display = "table"
})
//move buttons to top
itm.querySelectorAll('nav > div > div > div:nth-of-type(2)').forEach(buttons => {
buttons.style.left = "50px"
buttons.style.top = "0"
buttons.style.bottom = "auto"
buttons.style.zIndex = "20"
buttons.style.width = "200px"
})
//add permanent "feed" link
itm.querySelectorAll(".coreSpriteDesktopPhotoGridActive, .coreSpriteDesktopPhotoGrid, .glyphsSpritePhoto_grid__outline__24__blue_5").forEach(postsGrid => {
const link = postsGrid.closest("a")
const originalFeedLink = link.nextSibling
let newLink = document.createElement("a")
newLink.href = link.href += "feed/"
newLink.innerHTML = '<span class="glyphsSpritePhoto_list__outline__24__grey_5" aria-label="Feed"></span>';
newLink.className = originalFeedLink.className
newLink.onclick = (e) => { e.preventDefault(); originalFeedLink.click() }
originalFeedLink.style.display = "none"
link.parentNode.insertBefore(newLink, link.nextSibling)
new MutationObserver((mutations, observer) => mutations.forEach(mutation => {
if (newLink.className != mutation.target.className) newLink.className = mutation.target.className
})).observe(originalFeedLink, { attributes: true })
})
//search input
itm.querySelectorAll('input[placeholder="Search"]').forEach(searchInput => {
searchInput.style.marginLeft = "250px"
})
}
}))).observe(document, { childList: true, subtree: true })
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.