// ==UserScript==
// @name Censored redgif
// @namespace http://tampermonkey.net/
// @version 1.5.0
// @description This script censors redgifs.com.
// @author whtb
// @match https://www.redgifs.com/*
// @icon https://static.vecteezy.com/system/resources/previews/006/736/319/non_2x/censored-pixel-sign-flat-style-design-illustration-concept-isolated-on-white-background-vector.jpg
// @grant none
// @license MIT
// ==/UserScript==
var n=0;
var imgs;
var i=0;
var mousePosition;
var offset = [0,0];
var div, scroller;
var isDown = false;
var ScrollerFokusCheck= false;
var opacity=0.9;
var blure= 5;
var imgsbase64 = [];
const links = [
"https://iili.io/Jz944WP.png",
"https://iili.io/JzFuRcJ.png",
"https://iili.io/JzFTrTN.png",
"https://iili.io/JxQb8p2.png",
"https://iili.io/JxgKbYQ.png",
"https://iili.io/JRAXdXI.png",
"https://iili.io/JRAXJzN.png",
"https://iili.io/JRAXK1n.png",
"https://iili.io/JRAX2st.png"
];
function toDataURL(url, callback) {
var xhr = new XMLHttpRequest();
xhr.onload = function() {
var reader = new FileReader();
reader.onloadend = function() {
callback(reader.result);
}
reader.readAsDataURL(xhr.response);
};
xhr.open('GET', url);
xhr.responseType = 'blob';
xhr.send();
}
links.forEach((link) => {
toDataURL( link, function(dataUrl) {
imgsbase64.push(dataUrl);
})
});
function newstyle(){
let newst = document.createElement('style');
newst.innerHTML = `
.Player-BackdropWrap, .overlay{
opacity: ${opacity};
z-index: 9;
}
video, .thumbnail, .ready, .ImageGif-Thumbnail, .GalleryGif-Image, div.Player-BackdropWrap > img[src^='https://thumbs44.redgifs.com/']{
filter: blur(${blure}px);
}{
filter: blur(${blure}px);
}
.stripe {
filter: blur(${blure}px);
}
img.icon{
filter: blur(${1.2+blure/20}px);
}
div.UserInfo-ImageWrap{
filter: blur(${2+blure/10}px);
}
.thumbnail.lazyLoad.visible, .Video-Poster, .picture, .CreatorInfo-Avatar{
filter: blur(${2+blure/3}px);
}
`;
return newst;
}
var style = document.createElement('style');
style.innerHTML = `
.divmenu {
z-index: 20;
width: 150px;
height: 150px;
top: 200px;
left: 400px;
background-color: #4533E9;
color: #96F3F6;
border-radius: 10px;
box-shadow: 0px 9px 30px 0px rgba(255,149,5,0.3);
}
.pmenu{
margin-bottom: 8px;
margin-top: 8px;
font-size: 18px;
}
li {
margin-left: 10px;
padding: .1em;
}
li, ul {
list-style-type: none;
}
.Player-MetaInfo, .Player-SideBarWrap, .GalleryGifNav{
z-index: 10;
}
.Player-BackdropWrap {
z-index: 9;
object-fit: cover;
}
.overlay{
height: 100%;
object-fit: cover;
object-position: center;
width: 100%;}
.ApplicationFooter, .topNav, .TapTracker, .thumbnail.lazyLoad.visible, .ImageGif-Thumbnail, .Video-Poster, .picture{
z-index: 1;
}
video {
background: #000;
color: #FFF;
z-index: 1;
}
div.Player-BackdropWrap img{
opacity: 1;
-webkit-filter: blur(0px);
filter: blur(0px);
}
[class="wPZ+D9-J"]{
display: none;
}
`;
document.head.appendChild(style);
document.head.appendChild(newstyle());
div = document.createElement("div");
div.style.position = "fixed";
div.classList.add("divmenu");
var im = document.createElement("img");
im.classList.add("thumbnail");
div.innerHTML = `<ul class="set_boxes">
<li><p class="pmenu">Opacity</p>
<input id="inputOpacity" type="range" step="0.05" min="0" value="0.6" max="1" style="width: 120px;" ></li>
<li><p class="pmenu">Blure</p>
<input id="inputBlure" type="range" step="0.1" value="8" min="5" max="30" style="width: 120px;"></li>
</ul>`;
const scrollerOp = div.querySelector("#inputOpacity");
const scrollerBl = div.querySelector("#inputBlure");
document.body.insertAdjacentElement("beforeend", div);
function scroller_in_fokus(){ScrollerFokusCheck= true;}
function scroller_in_blure(){ScrollerFokusCheck= false;}
div.addEventListener('mousedown', function(e) {
if (!ScrollerFokusCheck){
isDown = true;
offset = [
div.offsetLeft - e.clientX,
div.offsetTop - e.clientY
];
}
}, true);
document.addEventListener('mouseup', function() {
if (!ScrollerFokusCheck){isDown = false;}
}, true);
document.addEventListener('mousemove', function(event) {
if (!ScrollerFokusCheck){
event.preventDefault();
if (isDown) {
mousePosition = {
x : event.clientX,
y : event.clientY
};
div.style.left = (mousePosition.x + offset[0]) + 'px';
div.style.top = (mousePosition.y + offset[1]) + 'px';
}
}
}, true);
scrollerOp.addEventListener('input', function() {opacity = this.value; document.head.appendChild(newstyle());}, false);
scrollerBl.addEventListener('input', function() {blure = this.value; document.head.appendChild(newstyle()); }, false);
scrollerOp.addEventListener("mouseenter", scroller_in_fokus);
scrollerOp.addEventListener("mouseleave", scroller_in_blure);
scrollerBl.addEventListener("mouseenter", scroller_in_fokus);
scrollerBl.addEventListener("mouseleave", scroller_in_blure);
function myFunction(){
imgs = document.querySelectorAll("div.Player-BackdropWrap > img[src^='https://thumbs44.redgifs.com/']");
if (imgs.length != n && imgs.length!=0){
i++;
i%=(imgsbase64.length);
imgs[imgs.length-1].src = imgsbase64[i];
imgs[imgs.length-1].style.filter = "blur(0px)";
document.head.appendChild(style);
document.head.appendChild(newstyle());
}
n = imgs.length ;
if(imgs.length==0){
let imags = document.querySelectorAll("a.tile");
for (let k=0; k<imags.length; k++) {
if(imags[k].querySelectorAll(".shadow-hover img").length==0){
let imghtml = `<img class="overlay" style="blur(0px);" src="${imgsbase64[k%links.length]}">`;
imags[k].querySelectorAll(".shadow-hover")[0].insertAdjacentHTML("beforeend", imghtml);
imags[k].querySelectorAll(".shadow")[0].insertAdjacentHTML("beforeend", imghtml);
document.head.appendChild(style);
document.head.appendChild(newstyle());
}
}
}
}
var timer = setInterval( myFunction, 5);