Skip to content

Instantly share code, notes, and snippets.

@crashmax-dev
Last active June 16, 2023 14:45
Show Gist options
  • Save crashmax-dev/fea6d70ad36da84cae9953e5f1347a9c to your computer and use it in GitHub Desktop.
Save crashmax-dev/fea6d70ad36da84cae9953e5f1347a9c to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Improve Imgur
// @version 0.2
// @author crashmax
// @match https://imgur.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=imgur.com
// @grant GM_addStyle
// ==/UserScript==
GM_addStyle(`
.Footer-wrapper {
display: none;
}
`)
window.addEventListener('keydown', (event) => {
if (event.altKey) {
event.preventDefault()
const image = getImage()
if (!image) return
location.href = image.src
}
})
const observer = new MutationObserver((mutation) => {
const button = getButton()
if (!button) return
button.click()
})
observer.observe(document.body, {
childList: true,
subtree: true
})
function getButton() {
return document.querySelector('.Wall-choices > .btn-wall--yes')
}
function getImage() {
return document.querySelector('.imageContainer > img')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment