Last active
November 25, 2020 09:10
-
-
Save Loner1024/b564b29795359683df2f07eaf2ae32d5 to your computer and use it in GitHub Desktop.
Anti Anti NSFW
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Anti Anti NSFW | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Anti Anti NSFW | |
// @author Loner | |
// @match *://web.okjike.com/* | |
// @grant none | |
// @require https://unpkg.com/nsfwjs@2.3.0/dist/nsfwjs.min.js | |
// @require https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@1.0.0/dist/tf.min.js | |
// ==/UserScript== | |
const modeljs = nsfwjs.load(); | |
(function() { | |
//'use strict'; | |
var imgList = document.images; | |
for(var i=0;i<imgList.length;i++){ | |
if(imgList[i].src == "https://cdn.jellow.site/962110.jpg" || imgList[i].src=="https://cdn.jellow.site/o_1ci1ibi9716h11r0s1bmgqfgo487.png"){ | |
break; | |
} | |
const img = new Image(); | |
img.crossOrigin = "anonymous"; | |
img.src = imgList[i].src; | |
if(!nsfw(img)){ | |
imgList[i].src = "https://cdn.jellow.site/FhIpbUoI2KfB-NYc9kJsGiVOn7qj.jpg?imageMogr2/auto-orient/thumbnail/400x2000%3E/quality/70/interlace/1" | |
} | |
} | |
var divList = document.getElementsByTagName("div"); | |
for(var i=0;i<divList.length;i++){ | |
const img = new Image(); | |
img.crossOrigin = "anonymous"; | |
img.src = getComputedStyle(divList[i]).backgroundImage.replace('url("','').replace('")',''); | |
console.log(img.src); | |
if(img.src == "https://web.okjike.com/originalPost/none" || img.src == "https://web.okjike.com/none"){ | |
divList[i].style.backgroundImage = 'url("https://web.okjike.com/originalPost/none")' | |
} | |
else if(!nsfw(img)){ | |
divList[i].style.backgroundImage = 'url("https://cdn.jellow.site/FhIpbUoI2KfB-NYc9kJsGiVOn7qj.jpg?imageMogr2/auto-orient/thumbnail/400x2000%3E/quality/70/interlace/1")' | |
} | |
} | |
})(); | |
function nsfw(img){ | |
modeljs.then((model) => { | |
// Classify the image. | |
model.classify(img,1).then((predictions) => { | |
if(predictions[0].className == "Drawing" || predictions[0].className == "Neutral"){ | |
console.log(predictions); | |
return false; | |
} | |
else{ | |
console.log(predictions); | |
return true; | |
} | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment