Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name NFOHump Hidden Users (Phill test)
- // @namespace com.LeoNatan.hideusers
- // @version 1.5.6
- // @description Adds proper ignore list in NFOHump forums, where posts actually disappear.
- // @author Leo Natan
- // @match *://nfohump.com/forum/*
- // @match *://www.nfohump.com/forum/*
- // @grant none
- // @downloadURL https://raw.githubusercontent.com/LeoNatan/NFOHump/master/IgnoreList/NFOHumpIgnoreList.user.js
- // @updateURL https://raw.githubusercontent.com/LeoNatan/NFOHump/master/IgnoreList/NFOHumpIgnoreList.user.js
- // @position 1
- // @noframes
- // @run-at document-end
- // ==/UserScript==
- if(window.$ == undefined) {
- return;
- }
- const className = "hiddenByNFOHumpIgnore";
- const supportClassName = "supportForNFOHumpIgnore";
- if(localStorage.blocklist === null || localStorage.blocklist === undefined)
- {
- localStorage.blocklist = "";
- }
- if(localStorage.isBlocklistEnabled === null || localStorage.isBlocklistEnabled === undefined)
- {
- localStorage.isBlocklistEnabled = "true";
- }
- const anchor = $('<a class="mainmenu" style="cursor: pointer;">Hidden users</a>').click(function() {
- var q = prompt("Ignored users are hidden automatically.\n\nEnter a comma-separated list of additional users to hide:", localStorage.blocklist);
- if(q === null)
- {
- return;
- }
- if (q != localStorage.blocklist)
- {
- localStorage.blocklist = q;
- resetAndHideElements();
- }
- });
- const checkbox = $('<input style="margin: 0px; margin-left: 31px; margin-top: 1px;" type="checkbox" ' + (localStorage.isBlocklistEnabled == "true" ? 'checked' : '') + ' />').click(function () {
- localStorage.isBlocklistEnabled = (localStorage.isBlocklistEnabled == "true" ? "false" : "true");
- resetAndHideElements();
- });
- const ul = $('#leftdiv > div.menuLeftContainer:first > ul');
- const hiddenThreads = ul.find(".hiddethreadsli").first();
- const newMenuItem = $('<li class="hiddenusersli" style="vertical-align: middle;"></li>').append(anchor).append(checkbox);
- if(hiddenThreads[0] != undefined)
- {
- hiddenThreads.before(newMenuItem);
- }
- else
- {
- ul.append(newMenuItem);
- }
- const ignoreUser = $('<li style="padding-right: 3px;"><a href="about:blank">Hide User</a></li>').click(function(e) {
- const clickedUserName = $(e.target).parent().parent().parent().parent().parent().parent().parent().parent().parent().find("a[title^='click to insert']").text();
- var arr = $.grep($.map(localStorage.blocklist.split(','), function(v) {
- return $.trim(v);
- }), function(e) { return e !== clickedUserName; });
- arr.push(clickedUserName);
- localStorage.blocklist = arr.join(', ');
- resetAndHideElements();
- return false;
- });
- const userParents = $("a:contains('Ignore User')").parent();
- userParents.before(ignoreUser);
- const userParentsAlreadyIgnored = $("a:contains('Un-ignore User')").parent();
- userParentsAlreadyIgnored.before(ignoreUser);
- function hideElements() {
- if(window.location.href.includes('/viewtopic.php') == false) {
- return;
- }
- if(!(localStorage['blocklist'] && localStorage['blocklist'].length > 0))
- {
- return;
- }
- $.each(localStorage.blocklist.split(','), function(k,v) {
- v = $.trim(v);
- $('span.genmed:contains("' + v + '")').each(function() {
- if($(this).text().startsWith(v) != true) {
- return;
- }
- const x = $(this).parent().parent().parent().parent();
- if(x.hasClass(className)) {
- return;
- }
- x.addClass(className);
- if($(x[0]).parents('#userSig').length == 0) {
- $.getJSON('https://uselessfacts.jsph.pl/api/v2/facts/random', function(data) {
- const y = $('<div class="fact"><div class="fact-text"><span>Random fact</span>' + data.text + '</div></div>');
- y.addClass(supportClassName);
- y.insertBefore(x);
- });
- }
- x.hide();
- });
- $('span.nav > b > a:contains("' + v + '")').each(function() {
- if($(this).text() !== v) {
- return;
- }
- const x = $(this).parents('td:eq(0)').parent();
- if(x.hasClass(className)) {
- return;
- }
- x.addClass(className);
- x.hide();
- x.next().addClass(className);
- x.next().hide();
- x.next().next().addClass(className);
- x.next().next().hide();
- });
- });
- }
- function resetHiddenElements() {
- $('.' + supportClassName).remove();
- $('.' + className).each(function () {
- $(this).removeClass(className);
- $(this).show();
- });
- }
- function resetAndHideElements() {
- resetHiddenElements();
- if (localStorage.isBlocklistEnabled == "true") {
- hideElements();
- }
- //Rerun the video embedding script to fixup hidden posts.
- if(window.__api_applyEmbedding)
- {
- window.__api_applyEmbedding();
- }
- }
- resetAndHideElements();
- // Add CSS styles
- const styles = `
- .fact {
- font-size: 12px;
- color: #ffd700;
- border-left: 5px solid #ffd700;
- padding: 15px;
- background: rgba(0,0,0,.25);
- }
- .fact span {
- display: block;
- margin-bottom: 4px;
- font-size: 10px;
- text-transform: uppercase;
- color: #fff;
- font-weight: bold;
- }
- `;
- $('<style>').text(styles).appendTo('head');
Advertisement
Add Comment
Please, Sign In to add comment