Last active
January 2, 2016 12:19
-
-
Save rafaelsierra/8302384 to your computer and use it in GitHub Desktop.
Script pra TamperMonkey no Chrome pra bloquear conteudo sobre BBB no Facebook. Bem simplão.
This file contains 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 BBBLocker by Rafael Sierra | |
// @namespace http://blog.rafaelsdm.com/ | |
// @version 0.2 | |
// @description Suma com os posts que falem sobre o BBB da sua timeline | |
// @include https://*.facebook.com/* | |
// @include https://*.facebook.com.br/* | |
// @include http://*.facebook.com/* | |
// @include http://*.facebook.com.br/* | |
// @copyright 2014+, Rafael Sierra | |
// ==/UserScript== | |
// TODO: Adicionar botao pra desbloquear o conteudo | |
document.addEventListener('load', function(){ | |
var contentArea = document.getElementById('contentArea'); | |
if(!contentArea) return; | |
function run_bbblocker(){ | |
var post, i, j, userContent, usersContent; | |
var posts = contentArea.getElementsByClassName('_5uch'); | |
for(i=0;i<posts.length;i++){ | |
post = posts[i]; | |
// Nao analisa de novo quem ja foi | |
if('bbblocked' in post.dataset){ continue; } | |
// Checa se tem BBB no conteudo | |
// TODO: Transformar isso numa funcao | |
if(post.innerText.toLowerCase().indexOf('bbb') >= 0){ | |
// Bota umas firula | |
// TODO: Fazer as firula ficar bonita | |
var h5s=post.getElementsByClassName('_5pbw')[0].innerHTML; | |
post.style.backgroundColor = '#d8dfea'; | |
post.innerHTML = h5s+'<div class="item" style="font-size: 12px;color:#333;background-color: #d8dfea">Blá blá blá sobre BBB...</div>'; | |
post.dataset['bbblocked'] = 1; | |
} | |
} | |
} | |
run_bbblocker(); | |
var xman = new MutationObserver(run_bbblocker); | |
xman.observe(document, { | |
subtree:true, | |
childList:true | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment