Last active
June 16, 2023 14:45
-
-
Save crashmax-dev/fea6d70ad36da84cae9953e5f1347a9c to your computer and use it in GitHub Desktop.
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
// ==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