// ==UserScript==
// @name Censored redgif
// @namespace http://tampermonkey.net/
// @version 1.8.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 imgs;
var i=0;
var mousePosition;
var offset = [0,0];
var div, scroller;
var isDown = false;
var ScrollerFokusCheck= false;
var opacity=0.7;
var blure= 8;
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 newstyle(){
let newst = document.createElement('style');
newst.innerHTML = `
.overlay, .Player-BackdropWrap > img[src^='data:image/']{
opacity: ${opacity};
z-index: 9;
}
video, .thumbnail, .ImageGif-Thumbnail, .GalleryGif-Image, Player-BackdropWrap > img[src^='data:image/'] {
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, .ready, .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;
user-select: none;
}
li, ul {
list-style-type: none;
user-select: none;
}
.overlay{
height: 100%;
z-index: 9;
object-fit: cover;
object-position: center;
width: 100%;}
.ImageGif-Thumbnail{
z-index: 0;
}
.Player-MetaInfo, .GalleryGifNav{z-index: 10; }
.SideBar-Item [class^='LiveButton']{
display: none;
}
`;
div = document.createElement("div");
div.style.position = "fixed";
div.classList.add("divmenu");
div.innerHTML = `<ul class="set_boxes">
<li><p class="pmenu" id="opacity_p" >Opacity: ${Math.round(opacity*100)}%</p>
<input id="inputOpacity" type="range" step="0.01" min="0.05" value="${opacity}" max="1" style="width: 120px;" ></li>
<li><p class="pmenu" id="blure_p">Blure: ${blure} px</p>
<input id="inputBlure" type="range" step="0.1" value="${blure}" min="5" max="30" style="width: 120px;"></li>
</ul>`;
var scrollerOp = div.querySelector("#inputOpacity");
var scrollerBl = div.querySelector("#inputBlure");
var pOp = div.querySelector("#opacity_p");
var pBl = div.querySelector("#blure_p");
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;
pOp.innerHTML=`Opacity: ${Math.round(opacity*100)}%`;
scrollerOp.value=opacity;
document.head.appendChild(newstyle());}, false);
scrollerBl.addEventListener('input', function() {
blure = this.value;
pBl.innerHTML=`Blure: ${blure} px`;
scrollerBl.value=blure;
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);
document.addEventListener("load",function() {
document.head.appendChild(style);
document.head.appendChild(newstyle());
});
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 startVideo(){
let tiles = document.querySelectorAll('.tile');
let event = new MouseEvent('mouseover', {
'view': window,
'bubbles': true,
'cancelable': true
});
tiles.forEach((e) => e.dispatchEvent(event));
console.log('start');
}
function rmAds(){
if (document.querySelector(".SideBar-Item [class^='LiveButton']") != null) {
document.querySelectorAll(".SideBar-Item [class^='LiveButton']").forEach((ad) => ad.parentElement.parentElement.remove())
}
}
function myFunction(){
try {
document.querySelector('.ApplicationFooter').style.zIndex=5;
document.querySelector('.topNav').style.zIndex=5;
}
catch{}
rmAds();
if( document.querySelector("div.TapTracker .Video")!=null){
document.querySelectorAll("div.TapTracker .Video").forEach((block) => {
if (block.querySelector("img.overlay")==null){
i=(i+1)%links.length;
let imghtml = `<img class="overlay" src="${imgsbase64[i]}">`;
block.insertAdjacentHTML("afterbegin", imghtml);
block.style.filter = "blur(0px)";
document.head.appendChild(style);
document.head.appendChild(newstyle());}
});}
else if(document.querySelector("div.Player-BackdropWrap > img[src^='https://thumbs44.redgifs.com/']")!=null){
document.querySelectorAll("div.Player-BackdropWrap > img[src^='https://thumbs44.redgifs.com/']").forEach((imgs) => {
i++;
i%=(imgsbase64.length);
imgs.src = imgsbase64[i];
imgs.style.filter = "blur(0px)";
imgs.parentElement.style.zIndex = 10;
document.head.appendChild(style);
document.head.appendChild(newstyle());
});
}
if(document.querySelectorAll("div.TapTracker > .Video").length==0){
document.querySelectorAll('.icon, .duration').forEach((e)=>{ e.style.zIndex=5});
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" src="${imgsbase64[k%links.length]}">`;
imags[k].querySelector(".shadow-hover").insertAdjacentHTML("beforeend", imghtml);
imags[k].querySelector(".shadow").insertAdjacentHTML("beforeend", imghtml);
document.head.appendChild(style);
document.head.appendChild(newstyle());
}
}
//startVideo();
}
}
var timer = setInterval( myFunction, 5);