Skip to content

Instantly share code, notes, and snippets.

@xWTF
Created January 30, 2023 12:40
Show Gist options
  • Save xWTF/76de4ed5eb1fc5a4005e54b8306cedb7 to your computer and use it in GitHub Desktop.
Save xWTF/76de4ed5eb1fc5a4005e54b8306cedb7 to your computer and use it in GitHub Desktop.
Stash User Scripts
// Enables you to blur all images & replace title with SFW text
// Usage: enableSFW() in console
(function () {
const TITLE = ['Blue Puya', 'Parrot’s Beak', 'Middlemist Red Camellia', 'Queen of the Night', 'Catherine-Wheel Pincushion', 'Ghost Orchid', 'Darwin’s Slippers', 'Jade Vine', 'Lady’s Slipper Orchids', 'Purple Passionflower', 'Himalayan Poppy', 'Chocolate Cosmos', 'Bleeding Heart', 'Crown Imperial', 'Pitcher Plants', 'Sea Holly', 'Calla Lilies', 'Bird of Paradise', 'Ginger Flowers', 'Anthurium', 'Lobster Claws', 'Corpse Flower', 'Stinking Corpse Lily', 'Surprise Lily', 'Silk Tree', 'Black Bat Flower', 'Girlfriend Kiss'];
const random = (item) => item[Math.floor(Math.random() * item.length)];
const canvas = document.createElement("canvas"), ctx = canvas.getContext('2d', {
willReadFrequently: true,
});
window.enableSFW = () => {
document.querySelectorAll('.card-section-title,.performer-name,.performer-head .alias,.tag-item').forEach(e => e.textContent = random(TITLE));
document.querySelectorAll('.gallery-card-image,img.performer').forEach(e => {
const w = e.naturalWidth, h = e.naturalHeight;
canvas.width = w;
canvas.height = h;
ctx.drawImage(e, 0, 0);
var pixelArr = ctx.getImageData(0, 0, w, h).data;
sample_size = 50;
for (let y = 0; y < h + sample_size; y += sample_size) {
for (let x = 0; x < w + sample_size; x += sample_size) {
let p = (x + (y * w)) * 4;
ctx.fillStyle = "rgba(" + pixelArr[p] + "," + pixelArr[p + 1] + "," + pixelArr[p + 2] + "," + pixelArr[p + 3] + ")";
ctx.fillRect(x, y, sample_size, sample_size);
}
}
e.src = canvas.toDataURL("image/jpeg");
});
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment