From: Samir Benmendil Date: Wed, 2 Oct 2013 08:38:05 +0000 (+0200) Subject: update fbpurity X-Git-Url: https://git.rmz.io/dotfiles.git/commitdiff_plain/ba5dbaf17e704206beafc61f8f9f8aa0bcbed876?hp=-c update fbpurity --- ba5dbaf17e704206beafc61f8f9f8aa0bcbed876 diff --git a/dwb/greasemonkey/fbpurity.EGTSVNOH.user.js b/dwb/greasemonkey/fbpurity.EGTEGTWO.user.js similarity index 93% rename from dwb/greasemonkey/fbpurity.EGTSVNOH.user.js rename to dwb/greasemonkey/fbpurity.EGTEGTWO.user.js index e0f2d73..5ae6675 100644 --- a/dwb/greasemonkey/fbpurity.EGTSVNOH.user.js +++ b/dwb/greasemonkey/fbpurity.EGTEGTWO.user.js @@ -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. @@ -249,6 +249,8 @@ // 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 @@ -256,7 +258,7 @@ (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=[ '
 FBP Tip: Want to further customise Facebook? Check out FBP\'s Custom CSS', '
 FBP Tip: If you have any questions or problems with FBP Check out FBP\'s FAQ / Help Page', '
 FBP Tip: Donations help keep the FB Purity project alive, Please show your support and Donate.', -'
 FBP Tip: Want to try out new versions of FBP before they are officially released? Join the FBP Beta Testing Page.', +'
 FBP Tip: Want to help test out new versions of FBP before they are officially released? Join the FBP Beta Testing Page.', '
 FBP Tip: Please Help me out by telling all your friends about FB Purity: Share FB Purity.', '
 FBP Tip: 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="
F.B. Purity:
Switching Sort Order
to Most Recent!"; 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="
F.B. Purity:
Switching Sort Order
to Most Recent!"; + 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= '

' +appname + ' has been BLOCKED!' + '

'; @@ -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=''; //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;iBA'; + if(appslist[i].getAttribute('data-gt')) + appid=appslist[i].getAttribute('data-gt').match(/appid":"(\d+)"/)[1]; //match(/appid\":\"(\d+)\"/)[1] + else + appid=appslist[i].querySelector('a[data-gt]').getAttribute('data-gt').match(/appid":"(\d+)"/)[1]; //match(/appid\":\"(\d+)\"/)[1] + tspan.innerHTML='BA'; appslist[i].getElementsByClassName('appName')[0].appendChild(tspan); } } } - //
} // 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