Skip to content

Instantly share code, notes, and snippets.

@Loner1024
Last active November 25, 2020 09:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Loner1024/b564b29795359683df2f07eaf2ae32d5 to your computer and use it in GitHub Desktop.
Save Loner1024/b564b29795359683df2f07eaf2ae32d5 to your computer and use it in GitHub Desktop.
Anti Anti NSFW
// ==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