Skip to content

Instantly share code, notes, and snippets.

@trex005
Created May 8, 2018 19:53
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 trex005/68a939b9496f9272f80c29785d50856d to your computer and use it in GitHub Desktop.
Save trex005/68a939b9496f9272f80c29785d50856d to your computer and use it in GitHub Desktop.
Tampermonkey/Greasemonkey script which adds the ability to reject domains generated on the bustaname domain generator.
// ==UserScript==
// @name Bustaname Reject Button
// @namespace https://gist.github.com/trex005/
// @version 0.0.1
// @description Tampermonkey/Greasemonkey script which adds the ability to reject domains generated on the bustaname domain generator.
// @author trex005
// @match http://www.bustaname.com/*
// @grant GM_addStyle
// @require https://code.jquery.com/jquery-3.3.1.min.js
// ==/UserScript==
(function() {
'use strict';
jQuery.noConflict();
let reject_checkbox = jQuery("<input type='checkbox' id='reject_checkbox'>");
function handleCheckbox(){
if(reject_checkbox.is(':checked')){
localStorage.setItem('reject_checkbox','checked');
jQuery("#availableResultList").addClass('hideRejected');
} else {
localStorage.removeItem('reject_checkbox');
jQuery("#availableResultList").removeClass('hideRejected');
}
}
GM_addStyle(
'#hide_rejected{clear:both}'+
'#availableResultList.hideRejected .rejected{display:none!important}'+
'.reject_button, .unreject_button{float:right}'+
'.rejected{background-color:pink!important}'+
'.rejected .reject_button{display:none}'+
'#availableResultList .unreject_button{display:none}'+
'#availableResultList .rejected .unreject_button{display:block};'
);
reject_checkbox.on('click',handleCheckbox);
if(localStorage.getItem('reject_checkbox')==='checked')
reject_checkbox.prop('checked','true');
jQuery('#resultsContainer br').first().after(reject_checkbox);
reject_checkbox.after("<label for='reject_checkbox'>Hide rejected</label>");
handleCheckbox();
function addButtons(){
let words = document.querySelectorAll('#availableResultList .wordDiv');
words.forEach((w)=>{
let word = jQuery(w);
let div = word.find('div');
if(localStorage.getItem(div.text()) === 'true')
word.addClass('rejected');
if(jQuery(word).hasClass('added_reject'))return;
word.addClass('added_reject');
let reject_button = jQuery("<button class='reject_button'>X</button>");
let unreject_button = jQuery("<button class='unreject_button'>+</button>");
reject_button.on('click',()=>{
word.addClass('rejected');
localStorage.setItem(div.text(),'true');
});
unreject_button.on('click',()=>{
localStorage.removeItem(div.text());
word.removeClass('rejected');
});
div.before(unreject_button);
div.before(reject_button);
});
}
setInterval(addButtons,1000);
// Your code here...
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment