Skip to content

Instantly share code, notes, and snippets.

@evilUrge
Last active June 25, 2024 07:44
Show Gist options
  • Select an option

  • Save evilUrge/999787edfbb9c9f485037eebdbd2ada3 to your computer and use it in GitHub Desktop.

Select an option

Save evilUrge/999787edfbb9c9f485037eebdbd2ada3 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Clozemaster artifical image URL Changer and Resizer
// @namespace https://gist.github.com/evilUrge/999787edfbb9c9f485037eebdbd2ada3
// @version 0.4
// @description Change background image URLs from *.small.png to *.png, stretch images, and ensure they are not trimmed on Clozemaster
// @author Gilad Maoz
// @license MIT
// @icon https://www.clozemaster.com/icons/favicon-96x96.png
// @match https://www.clozemaster.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
function replaceImageURLs() {
const elements = document.querySelectorAll('div[style*=".small.png"]');
elements.forEach(el => {
let style = el.getAttribute('style'); // Replace .small.png with .png
let newStyle = style.replace(/\.small\.png/g, '.png'); // Add styles to stretch the background image and prevent it from being trimmed
newStyle += ' background-size: cover; background-repeat: no-repeat; overflow: visible; min-height: 1024px';
el.setAttribute('style', newStyle);
});
}
function removeShowImageButton() {
const button = document.querySelector('.btn-default.toggle-image');
if (button) {
button.remove();
}
}
replaceImageURLs();
// removeShowImageButton();
const observer = new MutationObserver(() => {
replaceImageURLs();
// removeShowImageButton();
});
observer.observe(document.body, { childList: true, subtree: true });
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment