Skip to content

Instantly share code, notes, and snippets.

@idolpx
Last active February 5, 2024 22:40
Show Gist options
  • Save idolpx/1bc722a68ef241e1f02098ed37c40cdb to your computer and use it in GitHub Desktop.
Save idolpx/1bc722a68ef241e1f02098ed37c40cdb to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Reddit Hide NSFW
// @namespace https://gist.github.com/idolpx
// @version 1.0.0
// @description Removes NSFW content from the main feed
// @downloadURL https://openuserjs.org/install/idolpx/Reddit_Hide_NSFW.user.js
// @updateURL https://openuserjs.org/meta/idolpx/Reddit_Hide_NSFW.meta.js
// @author Jaime Idolpx
// @copyright 2020, idolpx (https://openuserjs.org/users/idolpx)
// @license MIT
// @match https://www.reddit.com/
// @require http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
// @grant none
// ==/UserScript==
function hide_element() {
$.each( $('span:contains("nsfw")'), function( key, value ) {
let text = $(this).text();
//console.log( key + ': ' + text );
if ( text.indexOf('nsfw') > -1 )
{
console.log( key + ': ' + text );
//$(this).parent().eq(7).remove();
$(this).parent().parent().parent().parent().parent().parent().parent().remove();
}
});
}
(function() {
'use strict';
hide_element();
$('body').on("click",function(){
console.log('body click');
hide_element();
});
$(window).scroll(function() {
clearTimeout($.data(this, 'scrollTimer'));
$.data(this, 'scrollTimer', setTimeout(function() {
hide_element();
}, 350));
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment