NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name Inbox Whitelist // @namespace http://tampermonkey.net/ // @version 0.7 // @description only see messages from people you approve of // @author WhyTrustTomHanks // @match *://fetlife.com/* // @grant GM.setValue // @grant GM.getValue // @require http://code.jquery.com/jquery-latest.js // @licence MIT // ==/UserScript== (function() { 'use strict'; var browserWhitelist = localStorage.getItem('fetWhitelist'); if (browserWhitelist == null) { browserWhitelist = ['']; console.log('creating!'); console.log(browserWhitelist); } else { browserWhitelist = browserWhitelist.split(','); console.log(browserWhitelist); } function triggerWhitelist(){ //localStorage.setItem ('whitelist', ['test', 'another test']); $('#chat main > div').eq(1).attr('id', 'unformatted'); $('<div id="formatted"></div>').insertAfter('#chat main header'); $('div[href*="users"').each(function(){ var username = $(this).text(); username = username.substring(0, username.length - 1); if(browserWhitelist.includes(username)) { $(this).closest('.w-100.hover-bg-primary').parent().addClass('whitelisted'); } else { $(this).closest('.w-100.hover-bg-primary').parent().addClass('blacklisted') .find('.flex-column.flex-auto').eq(1).remove() .parent().siblings('div').remove(); } }); if($('#approved').text().length > 0 || $('#unapproved').text().length > 0) { console.log("exists"); } else { var newInbox = '<div id="approved">'; $('.whitelisted').each(function(){ newInbox = newInbox + $(this).html(); }); newInbox = newInbox + '</div><div id="unapproved" style="padding: 20px; margin-bottom: 50vh;"><h1>Unapproved users (<a class="showhide">show</a>)</h1> <span id="unwashed-masses" style="display:none">'; $('.blacklisted').each(function(){ newInbox = newInbox + $(this).html(); }); newInbox = newInbox + '</span></div>'; $('#formatted').html(newInbox); $('#unformatted').html('').css('color', 'transparent').css('padding-bottom', '50vh'); } $('#unwashed-masses').children('div').each(function(){ $(this).children('.absolute').remove(); $(this).css('width', '200px').css('display', 'inline-block').css('background-color', '#333').css('border-radius', '10px').css('margin', '10px').css('position', 'relative'); $(this).find('.truncate').css('width', '100%'); $(this).append("<a class='approve' href='#' style='position: absolute; color: transparent; text-shadow: 0px 0px #333; display: block; text-decoration: none; top: 10px; right: 10px; width: 50px; height: 50px; line-height: 50px; text-align: center; font-size: 40px; background-color: #555; border-radius: 10px;'>👌</a>"); $(this).attr("onclick", "").unbind("click"); }); $('.approve').click(function(){ var approved = $(this).parent().find('a.f5').text(); approved = approved.substring(0, approved.length - 1); browserWhitelist.push(approved); localStorage.setItem ('fetWhitelist', browserWhitelist.toString()); location.reload(); }); } $( document ).ready(function() { triggerWhitelist(); }); $( document ).ready(function() { $('#unformatted').on('DOMNodeInserted', 'div', function () { //var browserWhitelist = localStorage.getItem('fetWhitelist'); //browserWhitelist = browserWhitelist.split(','); $('#unformatted').children('div').each(function(){ var browserWhitelist = localStorage.getItem('fetWhitelist'); browserWhitelist = browserWhitelist.split(','); var username = $(this).find('.flex-row-l .w-30-l a').text(); username = username.substring(0, username.length - 1); console.log(username); if(browserWhitelist.includes(username)) { console.log('pip pip!'); $(this).remove(); $("#approved").append($(this).html()); } else { console.log('ey no'); $(this).remove(); $("#unwashed-masses").append($(this).html()); } $('#unwashed-masses').children('div').each(function(){ $(this).children('.absolute').remove(); $(this).css('width', '200px').css('display', 'inline-block').css('background-color', '#333').css('border-radius', '10px').css('margin', '10px').css('position', 'relative'); $(this).find('.truncate').css('width', '100%'); $(this).append("<a class='approve' href='#' style='position: absolute; color: transparent; text-shadow: 0px 0px #333; display: block; text-decoration: none; top: 10px; right: 10px; width: 50px; height: 50px; line-height: 50px; text-align: center; font-size: 40px; background-color: #555; border-radius: 10px;'>👌</a>"); $(this).attr("onclick", "").unbind("click"); }); $('.approve').click(function(){ var approved = $(this).parent().find('.flex-row-l .w-30-l a').text(); approved = approved.substring(0, approved.length - 1); browserWhitelist.push(approved); localStorage.setItem ('fetWhitelist', browserWhitelist.toString()); location.reload(); }); }); }); $(document).ready(function() { $('.showhide').click(function(){ $('#unwashed-masses').toggle("slow"); if($(this).text() == "show") { $(this).text('hide'); } else { $(this).text('show'); } }); }); }); // console.log(browserWhitelist.toString()); // })();