Skip to content

Instantly share code, notes, and snippets.

@siuying
Created May 21, 2009 13:01
Show Gist options
  • Save siuying/115448 to your computer and use it in GitHub Desktop.
Save siuying/115448 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name FBQuizMuter
// @namespace hk.reality
// @description Mute those quiz!
// @include http://www.facebook.com/home.php*
// @include http://www.facebook.com/profile.php*
// ==/UserScript==
// Add jQuery
var $;
var jQuery;
var GM_JQ = document.createElement('script');
GM_JQ.src = 'http://jquery.com/src/jquery-latest.pack.js';
GM_JQ.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(GM_JQ);
// Check if jQuery's loaded
var checker = setInterval(function() {
if (typeof unsafeWindow.jQuery != 'undefined') {
clearInterval(checker);
jQuery = unsafeWindow.jQuery;
$ = jQuery.noConflict(true);
onLoadComplete();
}
},100);
function FBQuizMuter() {
this.storiesQuery = ".CopyTitle";
this.blackLists = [/測驗,結果是/,/quiz and the result is/,/九型人格測試/];
}
FBQuizMuter.prototype.isBlackListed = function(text){
for(i=0; i<this.blackLists.length; i++) {
if (text.match(this.blackLists[i])) {
return true;
}
}
return false;
}
FBQuizMuter.prototype.getStories = function(text){
return jQuery(".UIStoryAttachment_Copy .CopyTitle");
}
FBQuizMuter.prototype.mute = function() {
var muter = this;
jQuery(this.storiesQuery).each(function(i, ele){
var text = jQuery(ele).text();
if (muter.isBlackListed(text)) {
jQuery(ele).parents(".UIStory").hide();
}
});
}
// // All your GM code must be inside this function
function onLoadComplete() {
new FBQuizMuter().mute();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment