Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Habbabreak2
- // @namespace http://habbabreak2.nil
- // @description Sanity helper script for Craig Murray's blog
- // @include https://www.craigmurray.org.uk/*
- // @version 1.0
- // @grant GM_getValue
- // @grant GM_setValue
- // @grant GM_deleteValue
- // @require http://code.jquery.com/jquery-1.7.2.min.js
- // @license Unlicense
- // ==/UserScript==
- var styles = '<style>' +
- 'div#habbabreak_options_div {display:none; background-color:#fff; padding:5px; border:1px #ccc solid;}' +
- 'input#habbabreak_add_person_input {max-width:300px;}' +
- 'a#habbabreak_disable_a.disabled {color:red;} div#habbabreak_options_div a {color:#262626; background: #ffff66;}' +
- 'a#habbabreak_toggle_options_a.disabled, a#habbabreak_toggle_options_a:visited.disabled {color:red;}' +
- 'a#habbabreak_toggle_options_a.disabled:hover {color:#28B7FF;} ' +
- '</style>';
- var boldstyle = '<style>' +
- 'article p>a, article p>a:hover {color:#262626; background: #ffff66;} article p {color:#262626; font-size:17px; line-height: 24px;} aside#text-10, aside#text-12, aside#archives-5, aside#categories-5{display:none;}' +
- 'aside a {color:#a27210;}' +
- '</style>';
- var peopletohide = function(s) {
- var pth = [];
- var pstr = GM_getValue('var-people-to-hide');
- if (pstr) {
- pth = pstr.split(s);
- pth.splice(-1,1); // remove last empty string from array
- }
- return pth;
- };
- jQuery.expr[':'].icontains = function(a, i, m) {
- return jQuery(a) .text() .toUpperCase() .indexOf(m[3] .toUpperCase()) >= 0;
- };
- $(document) .ready(function () {
- $('head') .append(styles);
- if (GM_getValue('var-option-bold')) $('head') .append(boldstyle);
- $('#menu-main-2') .append('<li><a href="" id="habbabreak_toggle_options_a">Habbabreak</a></li>');
- if (GM_getValue('var-script-disabled')) $('a#habbabreak_toggle_options_a') .addClass('disabled');
- var splitstring = "/c*nt^"; // DO NOT CHANGE
- // Options form html
- var options = '<div id="habbabreak_options_div">' +
- '<h3>Habbabreak V2</h3><div id="habbabreak_people_to_hide_div"></div>' +
- '<p><input type="input" id="habbabreak_add_person_input" placeholder="Loose matching eg habba will hide Habbakuk" maxlength="20"/> <a href="" id="habbabreak_add_person_a">add person</a></p>' +
- '<p><label><input type="checkbox" id="habbabreak_bold"/> High contrast</label></p>' +
- '<div><a href="" id="habbabreak_save_people_a">Save</a> | <a href="" id="habbabreak_cancel_options_a">Close</a> | <a href="" id="habbabreak_disable_a">Disable</a></div>' +
- '</div>' ;
- // Add divs to page
- $('#main-wrapper') .prepend(options);
- // Show/hide options form
- $('a#habbabreak_toggle_options_a') .click(function () {
- if (!$('#habbabreak_options_div') .is(":visible")) {
- $('#habbabreak_people_to_hide_div') .empty();
- // Display saved option values
- peopletohide(splitstring).forEach(function(value) {
- if (value.length > 0) {
- $('#habbabreak_people_to_hide_div') .append('<p><span>' + value + '</span> <a href="" class="remove_user">remove</a></p>');
- }
- });
- if (GM_getValue('var-option-bold')) $('#habbabreak_bold') .attr('checked', 'checked');
- if (GM_getValue('var-script-disabled')) {
- $('#habbabreak_disable_a') .text('Enable');
- $('a#habbabreak_disable_a') .addClass('disabled');
- }
- $('#habbabreak_options_div') .show();
- $('#habbabreak_add_person_input') .focus();
- } else {
- $('#habbabreak_options_div') .hide();
- }
- return false;
- });
- // Disable/enable script link click
- $('a#habbabreak_disable_a') .click(function () {
- GM_setValue('var-script-disabled', !GM_getValue('var-script-disabled'));
- $('#habbabreak_options_div') .hide();
- return true;
- });
- // Add user link click
- $('#habbabreak_options_div a#habbabreak_add_person_a') .click(function () {
- var value = $('#habbabreak_add_person_input') .val() .trim();
- if (value.length > 0) {
- $('#habbabreak_people_to_hide_div') .append('<p><span>' + value + '</span> <a href="" class="remove_user">remove</a></p>');
- $('#habbabreak_add_person_input') .val('');
- } else {
- alert ("Habbabreak V2:\nPlease enter a name!");
- $('#habbabreak_add_person_input').focus();
- }
- return false;
- });
- // Remove user link click
- $('#habbabreak_people_to_hide_div') .on('click', '.remove_user', function () {
- $(this) .parents('p') .remove();
- return false;
- });
- // Close form link click
- $('a#habbabreak_cancel_options_a') .click(function () {
- $('#habbabreak_options_div') .hide();
- return false;
- });
- // Save options link click
- $('a#habbabreak_save_people_a') .click(function () {
- // Delete existing saved options
- GM_deleteValue('var-people-to-hide');
- GM_deleteValue('var-script-disabled');
- GM_deleteValue('var-option-bold');
- // Save new options
- var pthstr = '';
- $('#habbabreak_people_to_hide_div p span') .each(function () {
- pthstr += $(this) .text() + splitstring;
- });
- if( pthstr.length > 0 ) GM_setValue('var-people-to-hide', pthstr);
- GM_setValue('var-option-bold', $('#habbabreak_bold') .attr('checked') == 'checked');
- // Hide options window
- $('#habbabreak_options_div') .hide();
- // Force page reload
- return true;
- });
- // Hide comments
- if (!GM_getValue('var-script-disabled')) {
- peopletohide(splitstring).forEach(function(value) {
- var comments = $('header.comment-author') .filter(function () {
- return $(this).is(':icontains(' + value + ')');
- }).parents('article') ;
- comments.hide();
- var recents = $('span.comment-author-link') .filter(function () {
- return $(this).is(':icontains(' + value + ')');
- }).parents('li') ;
- recents.hide();
- });
- };
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement