Skip to content

Instantly share code, notes, and snippets.

@aimakun
Created May 16, 2011 07:30
Show Gist options
  • Save aimakun/974046 to your computer and use it in GitHub Desktop.
Save aimakun/974046 to your computer and use it in GitHub Desktop.
[Userscript] Facebook Scan Mass Tagging
// ==UserScript==
// @name Facebook Scan Mass Tagging (spam/ads tag)
// @namespace http://aimakun.exteen.com
// @description Pure javascript for scan tagging which you should not want them.
// @author aimakun
// @include http*://www.facebook.com
// @include http*://www.facebook.com/
// @include http*://www.facebook.com/?*
// @include http*://www.facebook.com/profile.php?*
// @include http*://www.facebook.com/ajax/home/feed.php?*
// @include http*://www.facebook.com/settings/?tab=privacy§ion=block&*
// @version 1.0
// ==/UserScript==
function addJQuery(callback) {
var script = document.createElement("script");
script.setAttribute("src", "http://code.jquery.com/jquery-1.5.1.js");
script.addEventListener('load', function() {
var script = document.createElement("script");
script.textContent = "(" + callback.toString() + ")();";
document.body.appendChild(script);
}, false);
document.body.appendChild(script);
}
// the guts of this userscript
function main() {
jQ = jQuery.noConflict();
jQ(document).ready(function() {
if (window.location.pathname == '/profile.php' && window.location.hash == '#spamtag') {
uri = jQ('#profile_action_report_block a').attr('href').split('?');
path = uri[0].split('/');
path[path.length - 1] = 'report/social.php';
path = path.join('/');
uri = path + '?' + uri[1] + '&__a=1&__d=1';
/*
jQ.getJSON(uri, function(res) {
}).error(function(jqXHR, stat, thrown) { console.log(stat);});
*/
}
else if (window.location.pathname == '/settings/') {
// Autocomplete from url
// Note: user name input could join with '||' symbol.
// Note: need storage for queue blocking users.
//jQ('#block_submit input[type=submit]').click();
}
else {
if (jQ('.uiStream') != null) {
var limit = 10;
streamLoadTimer = setInterval(function() {
if (UIIntentionalStream.instance) {
UIIntentionalStream.instance.loadOlderPosts();
}
if (limit == 0 || jQ('.uiMorePagerPrimary').text().indexOf('There are no more posts to show right now.') != -1) {
clearInterval(streamLoadTimer);
scanTagSpam();
}
limit--;
}, 1000);
}
}
});
function scanTagSpam() {
var countTag = 0;
// Create sandbox
jQ('#pagelet_home_stream').prepend('<div class="UIStream" id="spam-sandbox"><ul class="uiStream"></ul></div>');
jQ('#spam-sandbox').css( {
'border' : '1px solid #cc0000',
'background-color' : '#ff9999',
});
jQ('.uiStream .uiStreamMessage').each( function() {
if (jQ(this).text().indexOf(' was tagged in ') != -1) {
var tagDesc = jQ(this).parent().find('.uiPhotoThumb').attr('title');
var keywords = ['Bangkok Nutrition', 'alturl.com'];
for (i=0; i<keywords.length; i++) {
if (tagDesc.indexOf(keywords[i]) != -1) {
// Move to sandbox
jQ(this).find('a').eq(1).clone().html('Go to spammer\'s profile').appendTo(jQ(this).parents('.storyContent'));
jQ(this).parents('li').appendTo('#spam-sandbox ul.uiStream');
}
}
}
});
}
}
// load jQuery and execute the main function
addJQuery(main);
/* Test purpose only
jQ.post('/privacy/ajax/block.php?__a=1', {
'block' : '100001337659224',
'post_form_id' : jQ('#post_form_id').val(),
'post_form_id_source' : 'AsyncRequest'
}, function(data) {
console.log(data);
});
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment