Last active
January 14, 2016 23:05
-
-
Save Aryoam/44ec2017854507b20b59 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Esconder Post Home | |
// @homepage https://gist.github.com/Aryoam/44ec2017854507b20b59 | |
// @version 0.3 | |
// @description Oculta Post de Destacados | |
// @author AryoamGames and N3HL | |
// @match https://www.taringa.net/* | |
// @match http://www.taringa.net/* | |
// @grant none | |
// ==/UserScript== | |
(function(){ | |
function getcraperos() { | |
if(localStorage.craperos == undefined){ | |
localStorage.setItems('craperos', '[]'); return []; | |
} | |
var dee = JSON.parse(localStorage.craperos); | |
return dee; | |
} | |
function addUsers(users) { | |
var dee = JSON.parse(localStorage.craperos); | |
dee.push(users); | |
localStorage.craperos = JSON.stringify(dee); | |
} | |
function removeUsers(users) { | |
var dee = JSON.parse(localStorage.craperos); | |
var indx = dee.indexOf(users); | |
if(indx > -1) { | |
dee.splice(indx, 1); localStorage.craperos = JSON.stringify(dee); | |
} | |
} | |
var box = `<div class="box" id="blockedcrap"> | |
<div class="title clearfix"> | |
<h2>Bloquear Craperos</h2> | |
</div> | |
<div style="margin-top: 8px; width: 95%"> | |
<input type="text" class="input" style="width: 100%;" id="usersBlock" autocomplete="off" placeholder="Escribe el nombre del Crapero"> | |
<button class="btn r" style="width: 100%; margin-top: 5px;">Bloquear</button> | |
</div> | |
<div class="list"> | |
</div> | |
</div>`; | |
var list_elements = '<div class="list-element"><b>%username%</b><span style="cursor:pointer" class="value delUser" data-users="%username%">Desbloquear</span></div>'; | |
$(".section-perfil #sidebar").prepend(box); | |
$("body").on("click", "#blockedcrap button", function(e){ | |
var usersBlock = $("#usersBlock").val(); | |
if($.inArray(usersBlock, getcraperos()) == -1) { | |
addUsers(usersBlock); | |
$("#blockedcrap > div.list").append(list_elements.replace(/%username%/g, usersBlock)); | |
} | |
}); | |
$("body").on("click", ".delUser", function(e){ | |
removeUsers($(this).data("users")); | |
$(this).closest("div.list-element").remove(); | |
}); | |
$(document).ready(function(e){ | |
var userslist = getcraperos(); | |
var $list = $("#blockedcrap div.list"); | |
userslist.forEach(function (items){ | |
$list.append(list_elements.replace(/%username%/g, items)); | |
var selector = 'a[title="' + items + '"]'; | |
var usuario = document.querySelectorAll(selector); | |
for (i = 0; i < usuario.length; i++) { | |
usuario[i].parentNode.parentNode.style.display = 'none'; | |
} | |
for (j = 0; j < items.length; j++) { | |
(items[j]); | |
} | |
}); | |
}); | |
})(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment