Skip to content

Instantly share code, notes, and snippets.

@superskirv
Last active July 24, 2024 02:11
Show Gist options
  • Save superskirv/e1792bbcfce3ca5e7816fe605ce3ae19 to your computer and use it in GitHub Desktop.
Save superskirv/e1792bbcfce3ca5e7816fe605ce3ae19 to your computer and use it in GitHub Desktop.
Civitai Image Highlight Remover: Removes glowing border around images.
// ==UserScript==
// @name Civitai Image Highlight Remover
// @namespace https://civitai.com/user/superskirv
// @version 0.2k
// @description This isnt universal. Removes glowing border around images. Reload page to remove border.
// @author Super.Skirv and ChatGPT 3.5
// @match https://civitai.com/*
// @icon https://civitai.com/images/android-chrome-192x192.png
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Function to remove specific div
function searchDiv(classList) {
// Select the target node
var targetNode = document.body;
// Create a MutationObserver instance
var observer = new MutationObserver(function(mutationsList, observer) {
// Loop through each mutation
for (var mutation of mutationsList) {
// Check if nodes were added
if (mutation.type === 'childList') {
console.log('Child nodes were added.');
// Loop through added nodes
mutation.addedNodes.forEach(function(node) {
console.log('Added node:', node);
// Check if the added node is a div with the specified class name
removeDiv(classList);
});
}
}
});
// Start observing the target node for mutations
observer.observe(targetNode, { childList: true, subtree: true });
console.log('Mutation observer started.');
}
// Function to remove specific div
function removeDiv(classList) {
console.log('removeDiv called');
// Select all div elements with the specified class names
var divs = document.querySelectorAll(classList.map(className => `div.${className}`).join(','));
// Loop through each selected div and replace its class
divs.forEach(function(div) {
// Loop through the classes to remove
classList.forEach(className => {
// Replace class with empty string
div.classList.remove(className);
});
});
}
// List of border types to remove, based on ones found in testing, alphabetically sorted.
var classList = ['frame-decoration','mantine-10mqt3u','mantine-124y86v','mantine-16fm2gl','mantine-16r2udw','mantine-17rlm4z','mantine-18ne6ev','mantine-1999ln2','mantine-19hhxkf','mantine-19nbxo','mantine-1b7tadi','mantine-1brw3f','mantine-1d1dky7','mantine-1edkf1t','mantine-1ekwgrn','mantine-1ft57gg','mantine-1henowj','mantine-1jflyhx','mantine-1k1i467','mantine-1n538gd','mantine-1nj1sp7','mantine-1nztfqs','mantine-1oigoo7','mantine-1oonqu3','mantine-1qjlqef','mantine-1rct8m','mantine-1rruuqk','mantine-1v0arov','mantine-1w0kzqg','mantine-1w35kdp','mantine-1x9dan8','mantine-27sdtw','mantine-2qb2ot','mantine-5xkwup','mantine-6ubkyu','mantine-7r3q29','mantine-980aqg','mantine-ba0c8p','mantine-bcn7s8','mantine-c5eoei','mantine-coa5ry','mantine-e4wb36','mantine-elcpcb','mantine-ezrjfp','mantine-fewyrt','mantine-gd5ma','mantine-iqhjce','mantine-kgfzth','mantine-ky04wo','mantine-lpldu2','mantine-n6irgl','mantine-ny1gys','mantine-olyjy6','mantine-oruknk','mantine-pcl00h','mantine-pw56vg','mantine-rhl5r5','mantine-td18vc','mantine-tl8b88','mantine-tnmdzj','mantine-vhqouq','mantine-vhv3ug','mantine-wjihhf','mantine-xthlq8','mantine-ydrgc2'];
// Call the searchDiv function with the class list
searchDiv(classList);
console.log('Script executed.');
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment