]> git.rmz.io Git - dotfiles.git/commitdiff
update fbpurity
authorSamir Benmendil <samir.benmendil@gmail.com>
Wed, 2 Oct 2013 08:38:05 +0000 (10:38 +0200)
committerSamir Benmendil <samir.benmendil@gmail.com>
Wed, 2 Oct 2013 08:38:05 +0000 (10:38 +0200)
dwb/greasemonkey/fbpurity.EGTEGTWO.user.js [moved from dwb/greasemonkey/fbpurity.EGTSVNOH.user.js with 93% similarity]

similarity index 93%
rename from dwb/greasemonkey/fbpurity.EGTSVNOH.user.js
rename to dwb/greasemonkey/fbpurity.EGTEGTWO.user.js
index e0f2d7300b28cb5b6fd73177f5083afd01310a3a..5ae6675d3581fc5c7a9d0ebbd0ccfbfc1fa7c109 100644 (file)
@@ -18,7 +18,7 @@
 // @run-at document-start
 // @grant          GM_getValue
 // @grant          GM_setValue
-// @version        8.7.0 - 12th Sep 2013
+// @version        8.8.2 - 1st Oct 2013
 // ==/UserScript==
 
 // these 2 excludes commented out for now, till we investigate which pages we need to exclude, as we need to run on certain "connect" pages for blocking apps.
 // 8.5.3     19thAug2013 Fixed Display of FBP info bar + filtering functionality for some users
 // 8.6.1     23rdAug2013 Faster start up and CSS loading, fixed hide pokes and hide emoticons, fixed intermittent functioning of "restore comment button" option, and intermittent functioning of "fix external link redirection" options
 // 8.7.0     12thSep2013 Updated FB Gift hiding option, Added "hide tagged in status" option, added app and game filtering in the news ticker to the hide "app / game messages" filter, updated hide sponsored box filter to also hide "similar to" box, updated hide gifts option
+// 8.8.2      1stOct2013 Added hide sticker packs functionality to sticker store, Improved the force Sort Most Recent function, Fixed "Block application" button wasnt showing in some situations, added BA links to appcenter app listings, fixed hide trending box option, fixed hide like page button for new newsfeed design
+
 // (C) stephen fernandez 2009-2013   http://www.fbpurity.com
 
 // If you like F.B. Purity please donate, big or small donations, anything is welcome 
 
 (function() {
 
-  var fbpVersion = "v8.7.0";
+  var fbpVersion = "v8.8.2";
   var debug=0; 
 
   var fbpoptsobj = {}; // object to store the preferences etc
@@ -378,7 +380,7 @@ var fbptips=[
 '<br/>&nbsp;<b>FBP Tip</b>: Want to further customise Facebook? <a target="_blank" href="http://fbpurity.com/css.htm?src=fbptips">Check out FBP\'s Custom CSS</a>',
 '<br/>&nbsp;<b>FBP Tip</b>: If you have any questions or problems with FBP <a target="_blank" href="http://fbpurity.com/faq.htm?src=fbptips">Check out FBP\'s FAQ / Help Page</a>',
 '<br/>&nbsp;<b>FBP Tip</b>: Donations help keep the FB Purity project alive, <a href="http://donate.fbpurity.com">Please show your support and Donate</a>.',
-'<br/>&nbsp;<b>FBP Tip</b>: Want to try out new versions of FBP before they are officially released? <a href="http://www.facebook.com/puritytest">Join the FBP Beta Testing Page</a>.',
+'<br/>&nbsp;<b>FBP Tip</b>: Want to help test out new versions of FBP before they are officially released? <a href="http://www.facebook.com/puritytest">Join the FBP Beta Testing Page</a>.',
 '<br/>&nbsp;<b>FBP Tip</b>: Please Help me out by telling all your friends about FB Purity: <a href="http://www.facebook.com/sharer.php?u=http://is.gd/fbpcnet">Share FB Purity</a>.',
 '<br/>&nbsp;<b>FBP Tip</b>: If you hover your mouse over any of the options on the FBP options screen, extra information about that option is usually displayed.'
 ];
@@ -711,7 +713,7 @@ function set_cookie (name,value) {
 var isgmapi, islocstor;
 try {
   if(typeof(GM_setValue)!='undefined') {
-    GM_setValue('test',1);
+    GM_setValue('test',1)
     if ( GM_getValue('test')==1)
       isgmapi=1;
     else
@@ -762,13 +764,13 @@ function fbpsavevalue(name,value){
        else if(isopera) { //window.navigator.userAgent.match(/Opera/)
          widget.preferences[name]=value;
        }
-       /* if i support localstorage and cookie, the user will repeatedly get the new user screen when the cookies are cleared, so lets comment this out*/
-       else if(islocstor) {
+       /* if i support localstorage and cookie, the user will repeatedly get the new user screen when the cookies are cleared, so lets comment this out
+       else if(locstor) {
          window.localStorage[name]=value;
        }
        else
          set_cookie(name,value);
-       
+       */
   }
   catch (e) {
     //console.log(e);
@@ -800,6 +802,7 @@ function fbploadvalue(name,funct){
                        else
                          funct(response.data);
                  }  
+               //}
       });
          val=-999;
          if(debug)
@@ -831,10 +834,6 @@ function fbploadvalue(name,funct){
          }
            else val='';
        }
-    else if(islocstor)
-      val=window.localStorage[name];
-       else
-      val=get_cookie(name); 
   }
   catch (e) {
     console.log(e);
@@ -1342,6 +1341,8 @@ function fbpoptsobjinit() {
   fbpoptsobj.userappwhitelist='';
   fbpoptsobj.fbpcustomcss='';
   
+  fbpoptsobj.stickerpacks='';
+  
 }
 
 // APPLICATION WHITELIST
@@ -1520,14 +1521,66 @@ refreshwhitelist = function () {
   }
   
 fixsortorder = function() {
+  if(debug)
+    console.log('fix sort order function');
   if(fbpoptsobj.sortmostrecent) { // force feed to sort by most recent
+       
     var sortlink=document.getElementsByClassName('sortLink');
     if(sortlink.length) {
-      if(!sortlink[0].textContent.match(/\:/))
+      if(!sortlink[0].textContent.match(/\:/)) {
+           document.getElementById('globalContainer').innerHTML="<div style='text-align:center;font-size:60px;font-weight:bold;'>F.B. Purity:<br/> Switching Sort Order<br/>to Most Recent!</h1>";
         window.location.href=window.location.protocol +'//www.facebook.com/?sk=h_chr';
+         }
     }
+       else { // deal with new newsfeed design
+         sortlink=document.getElementsByClassName('_5eo3');
+         if(sortlink.length) {
+        if(!sortlink[0].textContent.match(/\:/)) {
+                 document.getElementById('globalContainer').innerHTML="<div style='text-align:center;font-size:60px;font-weight:bold;'>F.B. Purity:<br/> Switching Sort Order<br/>to Most Recent!</h1>";
+          window.location.href=window.location.protocol +'//www.facebook.com/feed/recent';
+               }
+         }
+       }
+    /*
+       new newsfeed design, urls                              Old newsfeed
+    https://www.facebook.com/?sk=nf (Top Stories)          https://www.facebook.com/?sk=h_nor  (Top Stories)
+    https://www.facebook.com/feed/recent (Most Recent)     https://www.facebook.com/?sk=h_chr   (Most Recent)
+       */
+       // change newsfeed links to point to most recent feed
+       // the F logo needs to be set whether or not the left side navbar is found, as not all pages have the left navbar, but all pages have the F logo
+       
+    if(document.getElementsByClassName('litestandNavItem').length) { // new newsfeed design
+         document.getElementById('pageLogo').querySelector("a").setAttribute('href','/feed/recent');
+         document.getElementById('navHome').querySelector("a").setAttribute('href','/feed/recent');
+         if(document.querySelector("a[data-id='4748854339']")) {
+           //console.log(document.querySelector("a[data-id='4748854339']").getAttribute('href'));
+           document.querySelector("a[data-id='4748854339']").setAttribute('href','/feed/recent');
+               //console.log(document.querySelector("a[data-id='4748854339']").getAttribute('href'));
+               document.querySelector("a[data-id='4748854339']").setAttribute('data-gt','');
+               
+               // try removing event listeners by cloning the node and replacing it
+               var old_element = document.querySelector("a[data-id='4748854339']");
+        var new_element = old_element.cloneNode(true);
+        old_element.parentNode.replaceChild(new_element, old_element);
+         }
+       }
+       else {  // old newsfeed design
+         document.getElementById('pageLogo').querySelector("a").setAttribute('href','/?sk=h_chr');
+         document.getElementById('navHome').querySelector("a").setAttribute('href','/?sk=h_chr');
+         if(document.getElementById('navItem_app_4748854339') && document.getElementById('navItem_app_4748854339').getElementsByTagName("a").length) {
+           //console.log(document.getElementById('navItem_app_4748854339').getElementsByTagName("a").length);
+               //console.log(document.getElementById('navItem_app_4748854339').querySelector("a[data-gt]").getAttribute('href'));
+           document.getElementById('navItem_app_4748854339').querySelector("a[data-gt]").setAttribute('href','/?sk=h_chr');
+               //console.log(document.getElementById('navItem_app_4748854339').querySelector("a[data-gt]").getAttribute('href'));
+               document.getElementById('navItem_app_4748854339').querySelector("a[data-gt]").setAttribute('data-gt','');
+         }
+       }
+  } // end if sortmostrecent is enabled
+  else {
+    if(debug)
+         console.log('Sort most recent option is not enabled');
   }
-}  
+}
 
 initstage2 = function () {
   if(debug)
@@ -1590,7 +1643,7 @@ initstage2 = function () {
        headerTextFilter += ", is with .*,was tagged at, is in .*\., was in .*\., is at .*\., was at .*\., were at .*\., are at .*\., was with ";
 
   if((typeof fbpoptsobj.likedstatus !=='undefined') && (fbpoptsobj.likedstatus==1))
-       headerTextFilter += ", likes .*\'s status, like .*\'s status, like a status, likes a status, likes a post";
+       headerTextFilter += ", likes .*\'s status, like .*\'s status, like a status, likes h.. own status,likes a status, likes a post";
 
   if((typeof fbpoptsobj.commentedstatus !=='undefined') && (fbpoptsobj.commentedstatus==1))
        headerTextFilter += ",commented on .* status, commented on .* note, commented on .* activity";
@@ -1783,7 +1836,7 @@ youtubevideo
 
 
   if(fbpoptsobj.likepagebutton==1) {
-    fbpfreestyle.textContent +=' div.uiStreamShareLikePageBox  div.uiPageLikeButton, div.genericStreamStory a.PageLikeButton, div[data-dedupekey] span.PageLikeButton, div.shareFooter label.shareLikeButton {display:none} ';
+    fbpfreestyle.textContent +=' div.uiStreamShareLikePageBox  div.uiPageLikeButton, div.genericStreamStory a.PageLikeButton, div[data-dedupekey] span.PageLikeButton, div.shareFooter label.shareLikeButton, #pagelet_litestand_section a.PageLikeButton {display:none} ';
   }
   // single column timeline
   /*
@@ -1991,7 +2044,7 @@ if( headerTextFilter && headerTextFilter.length ) {
   }
 
   if (fbpoptsobj.trendingbox) {
-    fbpboxstyles +=' #pagelet_trending_tags_and_topics {display:none} {display:none}';
+    fbpboxstyles +=' #pagelet_trending_tags_and_topics, #under_composer_trending {display:none}';
   }
   
   if ((typeof fbpoptsobj.smileys !=='undefined') && fbpoptsobj.smileys) {
@@ -2081,7 +2134,7 @@ if(!isasync)
   }*/
   
   function fpInsertedNodeDomHandler(event) {
-
+    //console.dir(event.target);
     if((event.target.nodeName=='LI') ||  (event.target.nodeName=='UL'))  {
       //if ((document.getElementById('pagelet_home_stream')||(document.getElementById('profile_minifeed'))) && (!document.getElementById('fb_multi_friend_selector'))) {  
          if ((document.getElementById('pagelet_home_stream') ) && (!document.getElementById('fb_multi_friend_selector'))) {
@@ -2110,7 +2163,7 @@ if(!isasync)
                addblockbuttontopermreq();
          }
          if(event.target.getAttribute('class') && event.target.getAttribute('class').match('middle_area_content')){
-           if(window.location.href.match(/\/appcenter\//))
+           if(window.location.href.match(/\/appcenter\/?/))
              highlightemailrequest();
          }
          if(fbpoptsobj.fixarticleredirects && event.target.getElementsByTagName('a').length)
@@ -2245,7 +2298,7 @@ if(!isasync)
     var params = "__asyncDialog=1&__user=" + currentuserid + "&__a=1&confirmed=1&fb_dtsg=" + fb_dtsg ;// + phstamp:1658166771106811366130
        
     http.open("POST", url, true);
-    http.setRequestHeader("Referer", window.location.protocol + "//" + window.location.hostname + "/apps/application.php?id=" + appid);
+    //http.setRequestHeader("Referer", window.location.protocol + "//" + window.location.hostname + "/apps/application.php?id=" + appid);
     http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
     //http.setRequestHeader("Content-length", params.length);
     //http.setRequestHeader("Connection", "close");
@@ -2254,7 +2307,7 @@ if(!isasync)
          if(http.readyState == 4 && http.status == 200) {
                    if(!http.responseText.match('\"errorSummary\"')){
                      //unsafeWindow.console.log("successfully blocked app : '" + appname +  "' with id=" +appid + "\n");
-                     if((nodeid!='platform_dialog_content') &&(nodeid!='pagelet_canvas_content'))
+                     if((nodeid!='platform_dialog_content') &&(nodeid!='pagelet_canvas_content') &&(nodeid!='platformDialogForm'))
                            destroyblockedappstories (appid,'kill');
                          else {
                            document.getElementById(nodeid).innerHTML= '<p style="margin-top:20px;font-size:25px"><a title="App was blocked by the F.B. Purity Browser Extension" href="http://www.fbpurity.com"><img style="vertical-align:middle" src="https://sites.google.com/site/st333v/fbp-1/fbp-ghost-lid-icon-48x48.jpg"></a> ' +appname + ' has been BLOCKED!' + '</p>';
@@ -2570,16 +2623,14 @@ if(!isasync)
     for(var j in apparray) {
       i++;
       var functRef = callLater(blockapp,j,apparray[j].split(/,/)[1], apparray[j].split(/,/)[0], 1);
-      setTimeout(functRef, 1600*i);
+      window.setTimeout(functRef, 1600*i);
     }
     
     window.scrollTo(0,0); // scroll up, so user can see its working
-       
     appdump=null;
     apparray=null;
     appnamelist=null;
     return true;
-    
   } // END blockallapps function  
   
   fbptoggleopts=function(e) {
@@ -3475,10 +3526,15 @@ function deleterecentactivitymodule () {
                  setTimeout(deleventbutt,3000);
                }
                */
-               
-               if(arguments[0].match(/\/appcenter\//)) {
-                 setTimeout(highlightemailrequest,2500);
+               if(arguments[0].match(/facebook\.com\/?$|\/\?sk=/)) {
+                 window.setTimeout(fixsortorder,5500); // this  line stops image viewer from working properly if the "if statement" above is not there
                }
+               else if(arguments[0].match(/\/appcenter\/|\/dialog\/oauth\//)) {
+                 window.setTimeout(highlightemailrequest,6500);
+                 window.setTimeout(addblockapplinktoapppage,6500);
+                 window.setTimeout(addblockbuttontopermreq,6500)
+               }
+               
                
                //console.dir(arguments[0]);
         return pushState.apply(window.history, arguments);
@@ -3505,9 +3561,12 @@ addexternallinkfix = function() {
 }
 
 addblockbuttontopermreq = function() {
+  //console.log("in addblockbuttontopermreq function");
   buttbars=document.getElementsByClassName('platform_dialog_buttons');
   if(!buttbars.length)
     buttbars=document.getElementsByClassName('rightContent');
+  if(!buttbars.length)
+    buttbars=document.getElementsByClassName('uiOverlayFooterButtons');
   if(buttbars.length) {
     buttbar=buttbars[0];
        //if(location.href.match(/client_id=/)
@@ -3524,6 +3583,9 @@ addblockbuttontopermreq = function() {
                        break;
                  }
     }
+       else if (document.getElementsByName('app_id').length ){
+         bappid=document.getElementsByName('app_id')[0].getAttribute('value');
+       }
        
        var titleclass=document.getElementsByClassName('fsxl');
        if(titleclass.length)
@@ -3531,6 +3593,8 @@ addblockbuttontopermreq = function() {
        else
          if(document.getElementById('permPanel'))
            bapname=document.getElementById('permPanel').getElementsByTagName('b')[0].textContent;
+       else if (document.getElementsByClassName('permissions_app_name').length)
+         bapname=document.getElementsByClassName('permissions_app_name')[0].textContent;
        else
       var bapname="Application";
        /*
@@ -3568,19 +3632,24 @@ addblockbuttontopermreq = function() {
        /* ---------------------*/
        blahlab=document.createElement('label');
     blahlab.setAttribute('class','uiButton uiButtonConfirm uiButtonLarge');
+       blahlab.style.marginLeft="2px";
        blahlab.setAttribute('id','blockapplab');
        blahlab.setAttribute('appid',bappid);
        blahlab.setAttribute('appname',bapname);
-    blahlab.setAttribute('nodeid','platform_dialog_content');//globalContainer
-       if(!document.getElementById('platform_dialog_content'))
-         if(document.getElementsByClassName('tosPane').length)
-            document.getElementsByClassName('tosPane')[0].setAttribute('id','platform_dialog_content');
-                
+       if(document.getElementById('platform_dialog_content'))
+      blahlab.setAttribute('nodeid','platform_dialog_content');//globalContainer
+       else if(document.getElementsByClassName('tosPane').length)
+         document.getElementsByClassName('tosPane')[0].setAttribute('id','platform_dialog_content');
+       else if (document.getElementById('platformDialogForm'))
+         blahlab.setAttribute('nodeid','platformDialogForm');
+        
     //blahlab.setAttribute('style','position:absolute;top:-15px;left:520px');
        blahlab.setAttribute('title','Block this application with F.B. Purity');
     blahlab.innerHTML='<input value="Block App" name="block" type="button" id="appblocker">';
        //document.getElementById('content').appendChild(blahlab);
-       buttbox=document.getElementsByClassName('rightContent');
+       
+       
+       /*buttbox=document.getElementsByClassName('rightContent');
        if(buttbox.length)
          buttbox[0].appendChild(blahlab);
        else {
@@ -3588,6 +3657,9 @@ addblockbuttontopermreq = function() {
          if(buttbox2.length)
            buttbox2[0].appendChild(blahlab); 
        }        
+       */
+       
+       buttbar.appendChild(blahlab);
        
        if(document.getElementById('appblocker'))
          document.getElementById('blockapplab').addEventListener('click',blockappev,false);
@@ -3606,7 +3678,8 @@ addblockbuttontopermreq = function() {
 }
 
 highlightemailrequest = function() {
-  //console.log('did we get here?')
+  if(debug)
+    console.log('in highlightemailrequest function');
   // if a facebook application is requesting the users email address highlight it
   var appperms=document.getElementsByClassName('gdp_list_item');
   if(appperms.length)
@@ -3642,7 +3715,7 @@ highlightemailrequest = function() {
   //console.log(location.href.match(document.getElementsByClassName('mll').length));
   
   // add prominent block app button to app center app pages
-  if(window.location.href.match(/facebook\.com\/appcenter\//) && document.getElementsByClassName('mll').length) // if theres buttons {
+  if((window.location.href.match(/facebook\.com\/appcenter\//) || document.getElementsByTagName('body')[0].getAttribute('class').match(/app_center/)) && document.getElementsByClassName('mll').length) // if theres buttons {
     if(document.getElementById('block_app_link') && !document.getElementById('block_app_link2')) {
          var aja=document.getElementById('block_app_link').getElementsByTagName('a')[0].getAttribute('ajaxify');
          var ajatext=document.getElementById('block_app_link').getElementsByTagName('a')[0].textContent;
@@ -3662,31 +3735,30 @@ highlightemailrequest = function() {
          document.getElementsByClassName('mll')[0].appendChild(document.createTextNode('  '));
          document.getElementsByClassName('mll')[0].appendChild(ajalink);
        }
- if(window.location.href.match(/facebook\.com\/appcenter\//)) {
+ if(window.location.href.match(/facebook\.com\/appcenter\/?/) || document.getElementsByTagName('body')[0].getAttribute('class').match(/app_center/)) {
    // add BA (and eventually WL) links to all app listings in app center (this part is a work in progress/not completed yet)
    if(document.getElementsByClassName('appsListHeader').length) {
      topspan=document.createElement('span');
         topspan.setAttribute('style','color:red;font-weight:bold;margin-left:10px')
      topspan.setAttribute('id','block_app_link');
      document.getElementsByClassName('appsListHeader')[0].appendChild(topspan);
-        var appslistparent=document.getElementsByClassName('apps_list');
-        if(!appslistparent.length)
-          return;
-        var appslist = appslistparent[0].getElementsByClassName('uiListItem');
-        if(!appslist.length)
-          return;
+
+        var appslist = document.getElementsByClassName('appsListItem');
+        
         for(i=0;i<appslist.length;i++) {
        tspan=document.createElement('div');
        tspan.setAttribute('class','uiPopover appFeedbackMenu');
        tspan.setAttribute('style','top:18px');
-          appid=appslist[i].getAttribute('data-gt').match(/appid":"(\d+)"/)[1]; //match(/appid\&quot;:\&quot;(\d+)\&quot;/)[1]
-          tspan.innerHTML='<a title="Block Application" rel="dialog-post" ajaxify="/ajax/apps/block_app.php?app_id=' + appid + '&amp;type_index=0&amp;source=about&amp;confirm_id=block_app_link" href="#" role="button">BA</a>';
+          if(appslist[i].getAttribute('data-gt'))
+            appid=appslist[i].getAttribute('data-gt').match(/appid":"(\d+)"/)[1]; //match(/appid\&quot;:\&quot;(\d+)\&quot;/)[1]
+          else
+            appid=appslist[i].querySelector('a[data-gt]').getAttribute('data-gt').match(/appid":"(\d+)"/)[1]; //match(/appid\&quot;:\&quot;(\d+)\&quot;/)[1]
+          tspan.innerHTML='<a title="Block Application with FB Purity" rel="dialog-post" ajaxify="/ajax/apps/block_app.php?app_id=' + appid + '&amp;type_index=0&amp;source=about&amp;confirm_id=block_app_link" href="#" role="button">BA</a>';
           appslist[i].getElementsByClassName('appName')[0].appendChild(tspan);
         }
    
    }
  }
- //<div style="top:15px"></div>
 
 } // END highlightemailrequest function
 
@@ -3695,13 +3767,13 @@ Example URLS https://www.facebook.com/connect/uiserver.php?app_id=21669420836807
 Scenarios: oauth page / request permissions page / app page
 */
 if(window.location.href.match(/\/dialog\/oauth/) || window.location.href.match(/dialog\/permissions\.request/) || window.location.href.match(/\/connect\/uiserver\.php\?/) || window.location.href.match(/\/dialog\/plugin\.perms/))
-  if(!window.navigator.userAgent.match(/Opera\//))
-    addblockbuttontopermreq();
-  else
-     setTimeout(addblockbuttontopermreq,2000); // pause because opera runs script b4 page has finished loading
+  //if(!window.navigator.userAgent.match(/Opera\//))
+  //  addblockbuttontopermreq();
+  //else
+  window.setTimeout(addblockbuttontopermreq,10000); // pause a while because we are now running the script before the dom is fully loaded for all browsers...
 
-if(window.location.href.match(/\/appcenter\//))
-  setTimeout(highlightemailrequest,2500);
+if(window.location.href.match(/\/appcenter\/?/))
+  window.setTimeout(highlightemailrequest,10000);
 /* END Check if this page is an authorise app page so we can add a block button */
 
 /* BEGIN add a "block application" link at the bottom left hand corner of all application pages */
@@ -3736,7 +3808,7 @@ if (window.location.href.match(/\:\/\/apps\./)) {
   }
 }
 }
-window.setTimeout(addblockapplinktoapppage,3500);
+window.setTimeout(addblockapplinktoapppage,13000); // needed to make the delay longer, because we are starting the script before the dom has loaded
 /* END Add a block application link at bottom left of all application pages */
 
 function toggletimeline(ev) {
@@ -3841,6 +3913,153 @@ function resetclasses () {
   }
 }
 
+
+////// BEGIN HIDE STICKER PACK FUNCTIONALITY
+
+// Hide sticker packs functionality
+// /* hide Heromals pack*/
+// a[data-id="633721996647110"] {display:none !important}
+       
+function fbpInsertedStickerStoreHandler(records) { //event // mutationObserverRef
+//try{
+  var q,p,tempnode;
+    if(records.length) {
+      for(q=0;q<records.length;q++) {
+        //if(records[q].addedNodes.length)
+           for(p=0;p<records[q].addedNodes.length;p++) {
+             tempnode=records[q].addedNodes[p];
+          if(tempnode.nodeName=='DIV') //console.log(tempnode);
+                 if(tempnode.getAttribute && tempnode.getAttribute("class")=="_10 uiLayer _4-hy _3qw")  {
+                   if(document.getElementById('pagelet_sticker_store_dialog')) {
+                         if(debug)
+                       console.log('found sticker store!!');
+                         managestickerpacks();
+                       }
+                 }
+           }
+         }
+    }
+//} catch(e) {
+//  console.log("something wrong in inserted stickerstorehandler: " + e);
+//}
+}
+       
+function hidestickerpacks() {
+  if(debug) {
+    console.log("\nhidestickerpacks function");
+    console.log("typeof fbpoptsobj:" + typeof(fbpoptsobj));
+    console.log("typeof fbpoptsobj.stickerpacks:" + typeof(fbpoptsobj.stickerpacks));
+       console.log("stickerpack ids in fbpoptsobj:\"" + fbpoptsobj.stickerpacks +"\""); 
+  }
+  if((typeof(fbpoptsobj)=='undefined') || typeof(fbpoptsobj.stickerpacks)=='undefined') {
+    if(debug)
+      console.log("fbpoptsobj is not yet defined");
+       fbpoptsobj.stickerpacks='';
+    //return;
+  }
+  var spar=fbpoptsobj.stickerpacks.split(',');
+  var stickerpackstyles='';
+  if(spar.length && (spar[0]!=''))
+    for(var i=0;i<spar.length;i++)
+      stickerpackstyles+= 'a[data-id="' + spar[i] + '"] {display:none} ';
+  else
+    ; //console.log('array was empty');
+  if(debug)
+    console.log(stickerpackstyles);
+  stickerpackstyle=document.getElementById('stickerpackstyle');
+  stickerpackstyle.textContent=stickerpackstyles;
+}
+
+function hidestickerpackclick(e) {
+  //console.log('clicked it');
+  var spid=e.target.getAttribute('id');
+  if(debug) {
+    console.log("\nhidestickerpackclick function");
+  }
+  
+  if(e.target.checked) {
+    if(!fbpoptsobj.stickerpacks.match("'" + spid +"'")) {
+         if(fbpoptsobj.stickerpacks.length)
+           fbpoptsobj.stickerpacks+=',' + spid;
+         else
+           fbpoptsobj.stickerpacks+= spid;
+       }
+  }
+  else {
+    fbpoptsobj.stickerpacks=fbpoptsobj.stickerpacks.replace(spid,'');
+       fbpoptsobj.stickerpacks=fbpoptsobj.stickerpacks.replace(/,,/,',');
+       fbpoptsobj.stickerpacks=fbpoptsobj.stickerpacks.replace(/(^,|,$)/,'');
+  }
+  //console.log(fbpoptsobj.stickerpacks);
+  
+  //save prefs obj to localstorage
+  fbpsavevalue('fbpoptsjson-' + currentuserid, JSON.stringify(fbpoptsobj));
+  
+  hidestickerpacks();
+}
+
+// BEGIN init stickerpack variables
+var stickerpackstyle;
+var stickyobject={};
+
+function managestickerpacks() {
+
+  // BEGIN cache current stickerpacks
+  if(typeof(stickyobject.ready)=='undefined') { 
+       var stickerpackbar=document.getElementsByClassName('_590r');
+       if(!stickerpackbar.length) {
+         console.log('couldnt find stickerpack bar, maybe the class name has changed');
+         return;
+       }
+
+       var stickypacks=stickerpackbar[0].getElementsByClassName('_55bn')
+       if(!stickypacks.length) {
+         console.log('couldnt find individual sticker packs in stickerpack bar, maybe the class name has changed')
+         return;
+       }
+       for(var i=0;i<stickypacks.length-1;i++) {
+         if(debug)
+           console.log(stickypacks[i].getAttribute('aria-label') + ':' + stickypacks[i].getAttribute('data-id'))
+         stickyobject[stickypacks[i].getAttribute('aria-label')]=stickypacks[i].getAttribute('data-id');
+       }
+  }
+  stickyobject.ready=1;
+  // END cache current stickerpacks
+
+       var spboxes=document.getElementsByClassName('_5b2l');
+    if(!spboxes.length) {
+         console.log('didnt find the stickerpack boxes in the stickerstore')
+         return;
+       }
+       if(!spboxes[0].getElementsByClassName('_5b2r').length) {
+         console.log('we didnt find the stickerpack names in the stickerpack store, maybe the class name has changed.')
+         return;
+       }
+
+       var spcheckboxspan=document.createElement('span');
+       spcheckboxspan.setAttribute('title','Hide sticker pack with with FB Purity.');
+       var sptextnode=document.createTextNode(' Hide');
+       spcheckboxspan.appendChild(sptextnode);
+       var spcheckbox=document.createElement('input');
+       spcheckbox.setAttribute('type','checkbox');
+       spcheckbox.setAttribute('style','vertical-align:middle');
+       spcheckboxspan.appendChild(spcheckbox);
+       
+       for(var i=0;i<spboxes.length;i++) {
+         if(typeof (stickyobject[ spboxes[i].getElementsByClassName('_5b2r')[0].textContent ])!='undefined') {
+           spboxes[i].getElementsByClassName('mts rfloat')[0].appendChild(spcheckboxspan.cloneNode(1));
+           spboxes[i].getElementsByTagName('input')[0].setAttribute('id',stickyobject[spboxes[i].getElementsByClassName('_5b2r')[0].textContent]);
+               spboxes[i].getElementsByTagName('input')[0].addEventListener('click',hidestickerpackclick,false);
+               if(fbpoptsobj && fbpoptsobj.stickerpacks && fbpoptsobj.stickerpacks.length)
+             if(fbpoptsobj.stickerpacks.match(stickyobject[spboxes[i].getElementsByClassName('_5b2r')[0].textContent]))
+                       spboxes[i].getElementsByTagName('input')[0].checked=true;
+         }
+       }
+} // end managestickerpacks function
+
+////// END HIDE STICKER PACK FUNCTIONALITY
+
 function fbpurify() {
   if(debug)
     console.trace();
@@ -3857,16 +4076,6 @@ function fbpurify() {
   fbpStyleNormal= ".fbpblocked {display:none !important} .fbpblockedx {display:none !important} .fbpnormal {display:block !important}";  
   fbpstyle.textContent=fbpStyleNormal;
   
-  /*
-  if(document.getElementsByTagName('head')) {
-    document.getElementsByTagName('head')[0].appendChild(fbpstyle);
-    document.getElementsByTagName('head')[0].appendChild(fbpfreestyle);
-    document.getElementsByTagName('head')[0].appendChild(fbpboxstyle);
-    document.getElementsByTagName('head')[0].appendChild(fbpcssstyle);
-    document.getElementsByTagName('head')[0].appendChild(fbptlstyle);
-  }
-  */
-
   document.addEventListener("DOMNodeInserted", fpInsertedNodeDomHandler, false);
   
   if(document.getElementById('pagelet_home_stream') || document.getElementById('pagelet_litestand_section') || document.getElementById('stream_pagelet'))
@@ -3874,73 +4083,85 @@ function fbpurify() {
  
 } // END fbpurify function
 
-
-var waitfordom1=setInterval(function(){
-    if(document.getElementById('globalContainer')) {
-      clearInterval(waitfordom1);
-         //if(window.navigator.userAgent.match(/Opera/))
-         //  fbpgetprefs(); // grab user prefs if available if not populate them with defaults
-         
-      //bringbacknormalcommenting(); moved these to finalstage function to ensure the prefs have already been read
-         //window.setTimeout(addexternallinkfix,2000);
-      //addexternallinkfix();
-    }
-  }, 500);
-  
 // only run if DOM has loaded
 finalstage=function () {
 // we should check to see if fbpurify is already running...
 
   if(document.getElementsByTagName('head').length) {
+    if(!document.getElementById('stickerpackstyle')) {
+      stickerpackstyle=document.createElement('style');
+      stickerpackstyle.setAttribute('id','stickerpackstyle');
+    }
     document.getElementsByTagName('head')[0].appendChild(fbpstyle);
     document.getElementsByTagName('head')[0].appendChild(fbpfreestyle);
     document.getElementsByTagName('head')[0].appendChild(fbpboxstyle);
     document.getElementsByTagName('head')[0].appendChild(fbpcssstyle);
     document.getElementsByTagName('head')[0].appendChild(fbptlstyle);
+       document.getElementsByTagName('head')[0].appendChild(stickerpackstyle); 
        
        //window.setTimeout(bringbacknormalcommenting,2000); // prefs werent being read in before running this, so i added a short delay
        bringbacknormalcommenting();
        //window.setTimeout(addexternallinkfix,2000);
        addexternallinkfix();
        tlbuttinit(); // initialise the timeline single column button
+       window.setTimeout(fixsortorder,6000);
+       hidestickerpacks();
   }
   else {
     var waitforhead=setInterval(function(){
       if(document.getElementsByTagName('head').length ) {
+           if(!document.getElementById('stickerpackstyle')) {
+          stickerpackstyle=document.createElement('style');
+          stickerpackstyle.setAttribute('id','stickerpackstyle');
+        }
            document.getElementsByTagName('head')[0].appendChild(fbpstyle);
         document.getElementsByTagName('head')[0].appendChild(fbpfreestyle);
         document.getElementsByTagName('head')[0].appendChild(fbpboxstyle);
         document.getElementsByTagName('head')[0].appendChild(fbpcssstyle);
         document.getElementsByTagName('head')[0].appendChild(fbptlstyle);
+               document.getElementsByTagName('head')[0].appendChild(stickerpackstyle); 
                
            //window.setTimeout(bringbacknormalcommenting,2000); // prefs werent being read in before running this, so i added a short delay
            bringbacknormalcommenting();
            //window.setTimeout(addexternallinkfix,2000);
            addexternallinkfix();
-       
            tlbuttinit(); // initialise the timeline single column button
+               hidestickerpacks();
+               window.setTimeout(fixsortorder,6000);
            clearInterval(waitforhead);
-      } 
+      }
     }, 500);
   
   }
   
+  var waitforbody=setInterval(function(){
+    if(document.getElementsByTagName('body').length) {
+      //new (this.MutationObserver || this.MozMutationObserver || this.WebKitMutationObserver)(fbpInsertedStickerStoreHandler).observe(document.getElementsByTagName('body')[0], { childList: true, subtree: true }); //document.body
+         try{
+           new (MutationObserver || MozMutationObserver || WebKitMutationObserver)(fbpInsertedStickerStoreHandler).observe(document.body, { childList: true, subtree: true }); //document.body
+         }
+         catch(e) {
+           console.log('Mutation Observer not supported');
+         }
+         clearInterval(waitforbody);
+        }
+  }, 500);
+  
   if(document.getElementById('pagelet_home_stream') || document.getElementById('pagelet_litestand_section') || document.getElementById('stream_pagelet'))  { // || document.getElementById('pagelet_group_mall') || document.getElementById('timelineNavContent') // || document.getElementById('profile_minifeed')
-    fixsortorder();
     fbpurify();
+       window.setTimeout(fixsortorder,3000);
   }
   else {
     var waitfordom=setInterval(function(){
       if(document.getElementById('pagelet_home_stream') || document.getElementById('pagelet_litestand_section') || document.getElementById('stream_pagelet')) {  // || document.getElementById('pagelet_group_mall') || document.getElementById('timelineNavContent') // || document.getElementById('profile_minifeed') 
         clearInterval(waitfordom);
-               fixsortorder();
         fbpurify();
+               window.setTimeout(fixsortorder,3000);
       }
     }, 500);
   }
 } // end finalstage function;
 
-//if(!window.navigator.userAgent.match(/Opera/))
-  fbpgetprefs(); // opera loads the script before the page has loaded, so we need to delay a bit for opera, and load prefs in the waitfordom1 function instead.
-
-})();
+fbpgetprefs();
+       
+})();
\ No newline at end of file