]> git.rmz.io Git - dotfiles.git/blob - dwb/greasemonkey/fbpurity.EGTEGTWO.user.js
no need for sudo here
[dotfiles.git] / dwb / greasemonkey / fbpurity.EGTEGTWO.user.js
1 // ==UserScript==
2 // @name Facebook Purity
3 // @namespace http://steeev.freehostia.com
4 // @description F.B Purity hides application spam and other clutter from your facebook homepage
5 // @icon http://fbcdn-profile-a.akamaihd.net/hprofile-ak-snc4/373593_408502197558_209872631_q.jpg
6 // @include http://*.facebook.com/*
7 // @include https://*.facebook.com/*
8 // @match http://*.facebook.com/*
9 // @match https://*.facebook.com/*
10 // @exclude http://*.facebook.com/ajax/*
11 // @exclude https://*.facebook.com/ajax/*
12 // @exclude http://*.facebook.com/ai.php*
13 // @exclude https://*.facebook.com/ai.php*
14 // @exclude http://*.channel.facebook.com/*
15 // @exclude https://*.channel.facebook.com/*
16 // @exclude http://*.facebook.com/ai.php?*
17 // @exclude https://*.facebook.com/ai.php?*
18 // @run-at document-start
19 // @grant GM_getValue
20 // @grant GM_setValue
21 // @version 8.8.2 - 1st Oct 2013
22 // ==/UserScript==
23
24 // 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.
25 // @exclude http://*.facebook.com/connect/*
26 // @exclude https://*.facebook.com/connect/*
27
28 //
29 // (C) 2009 - 2013 stephen fernandez - http://www.fbpurity.com
30 //
31
32 // If you like this script please donate, big or small donations, anything is welcome :
33
34 // http://donate.fbpurity.com/
35
36 // ------------------------------------------------------------
37 // F.B. Purity Home Page : http://www.fbpurity.com
38 // F.B Purity Install : http://install.fbpurity.com
39 // F.B. Purity Fan Page : http://fans.fbpurity.com
40 // F.B. Purity UserGuide : http://user-guide.fbpurity.com
41 // F.B. Purity Custom CSS : http://css.fbpurity.com
42 // F.B. Purity FAQ / Help : http://faq.fbpurity.com
43 // F.B. Purity Search : http://search.fbpurity.com
44 // ------------------------------------------------------------
45
46 // ABOUT
47 // -----
48 // This greasemonkey script hides all third party facebook application messages from your fb homepage.
49 // Instructions on how to edit the "whitelist" are available here: http://whitelist.fbpurity.com
50 // Instructions on how to edit the "extras" are available here: http://extras.fbpurity.com
51 // Make donations to F.B. Purity, to show your appreciation here: http://donate.fbpurity.com
52
53 // INSTALLATION
54 // ------------
55 // This script is compatible with the following web browsers: Firefox, Google Chrome, Opera and Safari
56 //
57 // Full installation instructions are available here:
58 // http://install.fbpurity.com
59 //
60 // If you have any problems, please see the Frequently Asked Questions / Help page:
61 // http://faq.fbpurity.com
62
63 // UPDATES
64 // -------
65 // 1.51 30th March 2009 Bug fixed: if there were no pending requests, the script didnt work
66 // 1.52 4th April 2009 removed GM_addStyle command, for better compatibility with other browsers (chrome + opera)
67 // 1.53 26th April 2009 changed insertpoint so its not dependent on suggestions box
68 // 1.54 27th April 2009 script is now compatible with Google Chrome + Opera (and possibly safari, not tested yet)
69 // 1.54a 5th May 2009 fixed a minor bug
70 // 1.54b 24th June 2009 fixed for facebook code change
71 // 1.54c 29th July 2009 fixed for facebook code change
72 // 1.54d 5th Aug 2009 fixed for facebook code change
73 // 1.54e 26th Aug 2009 fixed for facebook code change
74 // 1.60 4th Sep 2009 added application whitelisting capability, the default whitelisted apps are:
75 // FB Iphone, Selective Twitter and Living Social
76 // 1.61 14th Oct 2009 optimised script, it should run faster and more efficiently now
77 // added tumblr, digsby and tweetdeck to whitelist, removed livingsocial from whitelist
78 // 1.8 21st Oct 2009 added "block app" functionality and ability to show just the app messages on the page
79 // added blackberry app to default whitelist
80 // 1.8a 22nd Oct 2009 fixed bug with blocking apps if language was not set to english
81 // 1.8d 23rd Oct 2009 fixed for new facebook update ( "live feed" changes )
82 // fixed if you click "Show x similar posts" on an application message, when you have chosen to display the app messages, the app messages will no longer be automatically hidden
83 // if after you've blocked an app, and there are no more hidden app messages, it now returns to normal homepage view
84 // 1.8e 26th Oct 2009 script now hides more apps (ones that use widgets) and should also now be restricted to running on the homepage
85 // 1.9 28th Oct 2009 added filter for "extra" [joined group, became fan, attending event, became friend] messages
86 // 2.0 31st Oct 2009 fixed Show/Hide Logic, made app+extra filters mutually exclusive, optimised the script a lot
87 // moved fbpurity bar to the left to regain vertical space on the right hand column
88 // newly added elements now obey the current filter
89 // 2.1 2nd Nov 2009 reset show/hide mode to default when user changes fb filter
90 // added workaround for fb still showing apps that you have "blocked", script now "hides" app as well as blocking it, when you click the "block app" link
91 // fixed bug with whitelisted apps being displayed via the "show hidden apps" filter
92 // fixed - block link wasnt showing up on dynamically inserted app messages
93 // 2.1a 4th Nov 2009 fixed - now also hides apps that dont have a mini-icon
94 // 2.1b 7th Nov 2009 added option to hide suggestions box
95 // added facebook for android to whitelist
96 // 2.2 12th Nov 2009 rewrote filter system, should block absolutely all apps now (except whitelisted ones)
97 // added filter for photos posted by applications (eg farmville, top friends etc)
98 // 2.2a 12th Nov 2009 fixed suggestion box filter
99 // 2.2b 20th Nov 2009 added another "became friends" story id to extras list
100 // 2.3 31st Jan 2010 fixed block app function for google chrome v4 + hopefully fixed the random script loading problems too
101 // speeded up script loading time by checking if the DOM is ready, rather than waiting for the whole page to load
102 // added "attended event" messages to blocked extras list
103 // added an option to allow blocking of "commented on status" and "likes status" messages
104 // added facebook for palm to default application whitelist
105 // 2.3a 5th Feb 2010 fixed bug where the show/hide links wouldnt work if you navigated away from the homepage then came back again
106 // 2.3b 7th Feb 2010 fixed script to work with new layout
107 // 2.3c 8th Feb 2010 fixed script to work with custom friends lists
108 // 2.4 13th Feb 2010 fixed hide suggestions box option (wasnt working on custom friends list pages)
109 // fixed app filtering ( some apps were getting around the app filter )
110 // added the following optional extras : tagged/commented/liked photo, tagged in album, commented/liked album, commented/liked link, wall comment, group wall comment
111 // 2.4a 18th Feb 2010 added another app exception (generic status updates posted "via some app" - using widgets)
112 // added motoblur + iphoto uploader to default whitelist
113 // added optional extra : "Page Wall Comments"
114 // added optional extra : "Posted Event"
115 // fixed bug caused by "posted events" + "became friends" sharing same story code
116 // fixed bug caused by "became friends + became fan of" sharing same story code
117 // 2.4b 19th Feb 2010 fixed bug in firefox where sometimes the "show extras" link stopped working
118 // 2.4c 23rd Feb 2010 fixed event/friend/fan story code differentiation
119 // 2.5 25th Feb 2010 added text filter list, so you can specify words or phrases you want to block from your news feeds
120 // separated userappwhitelist from the defaultappwhitelist, for easier copying and pasting of application id lists
121 // added picasa uploader to the default application whitelist
122 // 2.5a 26th Feb 2010 fixed script to work with latest FB code change
123 // 2.7 8th Mar 2010 added options editing screen that lets you save your settings for extras, whitelist, suggestions box, and custom text filter
124 // added sprint/samsung? photo/video uploader, sony/erricson uploader,music player + status shuffle to default whitelist.
125 // added https:// to the list of included pages for those wanting greater security whilst browsing facebook
126 // 2.8 13th Mar 2010 fixed suggestions box wasnt being hidden on the requests page if the hide sb option was selected
127 // fixed options screen occasionally not loading
128 // added hide option to hide the connect with friends box
129 // added facebook exporter for iphoto and flickr app to default whitelist
130 // added "Allow" link to application messages, for auto whitelisting of applications
131 // 2.8a-test 19thMar2010 alpha test of temp fix for fb codechange, basic (show/hide) functionality should be restored
132 // 2.8b-test 20thMar2010 fixed bug in show/hide app code, fixed "block app" and "allow" links on application messages
133 // 2.9 2ndApr2010 Merged 2.8 + 2.8b-test so it doesnt matter which version of the site you are presented with, the script should still work
134 // Fixed bug in chrome where show/hide functions were sometimes not working.
135 // Fixed Block + Allow links that were not showing up for certain applications (apps that post as normal FB stories)
136 // Added LG Mobile, Windows Phone, Twitter and Posterous to the default application whitelist
137 // Added hide "Sponsored box" (ads) option
138 // 2.9a 6thApr2010 Fixed bug that was causing Firefox to lock up
139 // 2.9b 9thApr2010 Fixed after blocking an app, not all the onscreen posts by that app would be hidden
140 // Made some performance tweaks to make the script run better
141 // Blocking app no longer requires "hiding" too so removed hideapp function call
142 // Added Snaptu + SonyEricsson Panel + Nokia to default whitelist
143 // 2.9c 15thApr2010 Added Ping.fm to default whitelist
144 // Added a workaround for the bug in firefox which caused the script to fail when cookies are set to: "Keep until:" - "ask me every time"
145 // 2.9d 15thApr2010 Fixed minor CSS style issue
146 // Fixed friend/fan stories getting mixed up again (due to Facebooks code tinkering)
147 // 2.9e 19thApr2010 Fixed bug where the display extras/apps would get screwed up some times
148 // Fixed "allow" and "block app" buttons were not being hidden by default
149 // 2.9f 26thApr2010 Fixed Display bug on custom friends list page.
150 // 2.9g 4thMay2010 Fixed Extras differentiation (friends/fans)
151 // Added wildcard for included pages
152 // Added Gwibber to default whitelist
153 // 2.9h 20thMay2010 Added new "likes website" type story to "became fan of" option
154 // Fixed differentiation between like+became friends (again)
155 // 2.9i 11thJun2010 Fixed Block App function
156 // Added "changed profile info","changed relationship" and "changed profile pic" to the list of hideable extras
157 // Fixed multiple words/phrases in custom text filter for chrome
158 // 2.9j 22ndJun2010 Added option to hide "beta testers" box
159 // Added HTC Sense + Samsung Mobile apps to default Whitelist
160 // 3.0 30thJun2010 Fixed script for latest FB code change
161 // Added visual feedback for "block app" function
162 // Added extra security on domain name parsing
163 // Stopped script from running in frames
164 // 3.1 30thJun2010 Fixed for unforseen bugs
165 // 3.11 9thJul2010 Fixed hide suggestions box (recommended pages + people you may know)
166 // 3.2 5thAug2010 Fixed "Block" and "Allow" (whitelist) buttons, Added windows live messenger + o2 social link to default whitelist
167 // 3.3 20thAug2010 Added new extra: "Checked in to location", addded LG Phone app to default whitelist
168 // 3.4 3rdSep2010 Fixed script to work with facebook's latest code change, added Bloom photo uploader to default whitelist
169 // 3.4a 11thSep2010 Fixed hide "get connected box" option, fixed freezeup in google chrome when creating a new friends list, fixed regex bug in custom text filter
170 // 3.4b 14thSep2010 Fixed hide "get connected box" option again, fixed compatibility with ff4
171 // 3.4c 22ndSep2010 Fixed hide "get connected box" option again
172 // 3.5 2ndOct2010 The application filter now also hides "friend began using app/game" messages. Custom text filter now tells you which filter was activated when it hides a message
173 // 3.6 7thOct2010 Added new extras "uploaded photo, uploaded video, tagged in video, posted note, tagged in note, posted link"
174 // Added "block app" and "allow app" links for "started using app" type messages
175 // Added Import and Export Settings functionality.
176 // Fixed loss of settings when user clears Firefox's cookies
177 // 3.6a 7thOct2010 Fixed bug with Firefox settings recovery system
178 // 3.7 14thOct2010 Incorporated new "joined group" story type to existing hide "joined group" extra, incorporated new "changed location" story types to existing "changed location" extra, added hide "poke box" option, added new HTC Sense, live journal and hootsuite to default app whitelist
179 // 3.8 20thOct2010 Added options to hide the "questions box", "events box" and "requests box"
180 // 3.8.1 27thOct2010 Fixed: "started using app filter", "hide request box code", added Sony Ericsson X10 mini pro to default application whitelist
181 // 3.8.2 29thOct2010 Fixed: Whitelist + Block App buttons were no longer showing due to a change in facebooks code.
182 // 3.8.3 3rdNov2010 Fixed: Whitelist + Block App buttons were no longer showing due to a change in facebooks code.
183 // Added Yahoo + Sony Ericsson + Vlingo to default whitelist
184 // Added WL (whitelist + BA (Block App) links for messages posted by applications masquerading as "normal" fb status updates
185 // 3.9.0 4thNov2010 Added font size option
186 // 3.9.1 11thNov2010 Streamlined page processing, Fixed font size for group messages, Fixed "needs to access data on all sites" message on google chrome, fixed group wall comments filter, fixed hide questions box option
187 // 3.9.2 15thNov2010 Updated hide sponsored box code, sponsored box should now be hidden on profiles and pages as well as the homepage/newsfeed, added block/whitelist links for photos/notes created uploaded by applications, tidied up code
188 // 3.9.3 19thNov2010 Added script collision detection, to check if 2 versions of the script are running at the same time (script+extension etc)
189 // Altered more font classes to give a more uniform font size across the site. Added Droid + Dell Mobile to default app whitelist
190 // 3.9.4 25thNov2010 Fixed mangled BA + WL links, Fixed "FB-Glitch" error on friends list pages, Hides sponsored box on search pages if option set, Added link to info about AVG clash, Fixed Opera bug with localstorage
191 // 3.9.5 7thDec2010 Added "changed to new profile" stories to "updated profile" filter, added new story code to "updated profile" filter, now hides sponsored box in a few more places, added RockMelt to default app whitelist
192 // 3.9.6 17thDec2010 Added Custom CSS Box, Fixed hide "suggestions" box, Fixed bug with blocking "started using app", Added Friendly for Ipad, Slide, networked blogs, RSS Grafitti, Twitter Feed to default app whitelist
193 // 4.0.0 23rdDec2010 Fixed intermittent app/extra filter problems, fixed bug with "started using app" previously it didnt check if app was in whitelist, added seesmic to app whitelist, fixed autoplay of videos when toggling show/hide
194 // 4.1.0 18thJan2011 NEW: Application message filtering can now be turned off, NEW: Can now block multiple applications at the same time
195 // Hide sponsored box option now hides more ads, Fixed name size on profile pages, Addeed Facebook mobile by Opentech ENG and flipboard to default app whitelist
196 // 4.3.0 27thJan2011 "App + extra" filtering now works on profile pages, tweaked blockallapp function a little bit (scroll to top, single app block)
197 // Added "delete all recent activity" button to profile pages, enabled full screen button for youtube videos, added delete friend request button, added nokia N900,and Ovi by Nokia to default app whitelist
198 // 4.3.1 11thFeb2011 show/hide filters save youtube video's current position, hide sponsored box option now hide ads on new photo lightbox popups, catches more application messages in app filter, fixed del recent activity to work with new https settting, fixed missing info bar on profile pages, fixed anomalous delete button on privacy page, added kodak easyshare,Snaptu for Facebook and Instagram to default app whitelist.
199 // 4.4.0 17thMar2011 fixed commenting ( hitting return/enter in the textarea no longer submits comments, also added comment button back for comments )
200 // fixed filtering on application/profile pages with photo strip at top, fixed intermittent bug with display of block app/whitelist links, added eBuddy, mobileblog + Rockmelt Beta to default whitelist
201 // 4.4.1 24thMar2011 Fixed block app function. Fixed Delete Recent Activity Function. (Known issue: In FF4 profile page needs to be reloaded to get the "del recent activity" button to show up)
202 // 4.5.0 29thMar2011 Added an option to hide the new Facebook Questions. Fixed Delete Recent Activity Button not showing up in FF4. Fixed "extras" dual story type separation for facebook videos and events. Fixed options screen layout problem on wide screens.
203 // 4.5.1 21stApr2011 Fixed for new Relationship stories and new "Is Using Application" stories
204 // 4.5.2 8thJun2011 fixed block application function, Fixed hide sponsored box code, Fixed a bug with the extras filter, added "no longer listed as" to relationship story filter
205 // 4.5.3 23rdJun2011 fixed fb places checkin anomaly, merged new "commented on a website" story type with "commented on link"
206 // 5.0.0 19thJul2011 added "hide chat" option, added "hide happening now" sidebar option, added "hide commented on event wall" extra option, added "hide page updates" extra option, added "hide commented/liked stories on Top News feed" extra option
207 // 5.1.0 20thSep2011 fixed spaces in application whitelist issue. fixed position of WL + BA links. added "updated school" and "relatives" stories to the updated profile extra filter. added "tagged in a post" stories to "commented/liked status" filter. added "subscribed to" stories to "friends with" extra filter. added windows phone 7, and facebook for windows phone 7 to default whitelist. fixed hiding ads on the photo lightbox
208 // 5.2.0 21stSep2011 fixed for new newsfeed
209 // 5.3.0 22ndOct2011 fixed/ish most extra filters (forced to use text filtering, so it only work on english interface), fixed comment button not showing up on ticker and birthday story popups. fixed ticker frame showing when hidden. fixed "meta.match" popup javascript error. fixed hide events box. Fixed BA + WL links not showing up.
210 // 5.5.0 29thOct2011 fixed various issues with extra filtering, added hide "Shared photo" extra option, ff addon is now restartless and also compatible with seamonkey/iceape
211 // 6.0.0 1stDec2011 fixed shared photo filter, fixed fan page stories filter, updated facebook places (checkins) filter, sped up the filtering a bit, fixed "likes page" filter, fixed event story filters, removed redundant box hiding options, added hide "read an article" option, reduced wall options to single "wrote on wall" option, added basic check for updates button, stopped filtering the current user and fbp's updates, FBP firefox extension is now restartless, FBP should now be compatible with the Seamonkey and Iceape browsers, app whitelist and custom text filter are now textareas and each item now needs to be on a separate line, rather than comma separated.
212 // 6.1.1 9thDec2011 fixed too-wide textareas on options screen, fixed fan page story filter + logged in user filter, added "shared an event" to "created event" filter, fixed attending and attended event filters, improved tabbed textareas differentiation, fixed "friend requested" button being erroneously displayed, fixed "fb glitch" error on friends list pages, fixed "shared a link" filter, fixed upload photo button duplication
213 // 6.3.0 22ndDec2011 added font and background colour options, added hide offline friends in chat option, added separate settings per logged in user, fixed "joined group" filter, fixed "regex error" freezing firefox, fixed https issues with options screen, fixed anomalous "delete" button showing up on timeline page, fixed "liked page" filter,improved fb places filter, added welcome message on first run
214 // 6.4.0 24thDec2011 Fixed filtering to work with international versions of FB, various other fixes.
215 // 6.4.1 26thDec2011 Fixed FB for IE7 Spoofing (to help with disabling Timeline)
216 // 6.4.2 6thJan2012 Fixed Application message filtering. Fixed hidden create album button on group pages. Fixed FB Purity Bar not showing on Friends list feeds. Fixed fbp not working for users with default user icon/pic. Improved welcome page.
217 // 6.4.3 19thJan2012 Fixed story filtering
218 // 6.5.0 6thFeb2012 Added an auto update checker, Fixed comment button on new photo lightbox, Fixed birthday comment flyout button, fixed hide ads on photo lightbox, fixed go online/offline chat button when browser is in IE7 spoof mode, fixed hide events box, fixed a memory leak
219 // 6.6.0 7thFeb2012 Added an option to force the newsfeed to be sorted by most recent, fixed photo comment button for "facebook fan pages"
220 // 6.6.1 20thFeb2012 Added links to new FBP Fan Page on Google Plus to options screen. Turned on "Hide sponsored box" option by default. Added CSS to hide footer in Right hand column. Fixed youtube scrollbars issue, fixed hidden info on fb questions and fb insights when colour options are set
221 // 6.6.2 2ndMar2012 Hides "press enter to submit comment" text when comment button enabled, fixes gap on new group pages when in ie7 spoof mode, fixes comment buttons on photo light box, brought back comments/likes on top news stories option
222 // 6.7.0 28thMar2012 Fixed auto update checker in Firefox, Fixed hide ads in message pages, Fixed comment box growing too big in Safari, fixed hide chat box option, fixed force feed to be sorted by "most recent" option, fixed delete recent activity button
223 // 6.7.1 3rdApr2012 Improved game/application and extra filtering, fixed hidden images at top of group pages if background colour had been set, fixed opera extension
224 // 7.0.0 6thApr2012 Added built in IE7 user agent switch for chrome (for disabling timeline), improved CSS fixes for IE7 spoof mode, improved comment button restoration, improved "extra" filters
225 // 7.1.0 28thApr2012 Fixed hide recent activity button, Fixed comment button on birthday and ticker flyout boxes, If hide "read an article" filter is ticked, it now also hides the "trending articles" box
226 // 7.5.0 10thMay2012 Fixed news article redirects for Trending Articles stories also fixed the hide trending articles box option, added "block application" link to bottom of all facebook application pages, and "block application" button to all facebook application permission request pages, Fixed "BA" (Block Application) and "WL" (Whitelist) links on application posts in the newsfeed
227 // Added a single column Timeline layout option, re-added ability to filter "frictionless sharing / FB actions" stories, Fixed hidden comment button in group welcome box
228 // 7.5.1 25thMay2012 Fixed hiding trending articles option, hide sponsored box option now also hides sponsored stories in the newsfeed, various other minor tweaks and fixes
229 // 7.5.2 14thJun2012 Fixed various extra filters including ('shared photo' and 'uploaded photo'), fixed news article redirects and hide "trending articles / trending videos"
230 // 7.6.0 5thJul2012 Removes all external link redirects, so Facebook cant track them or block them. Adds remove event 'x's on events page (chrome + safari only), highlights applications in app center that request email or posting permissions, fixed block application link on application pages
231 // 7.6.1 1stAug2012 Fixed hide sponsored box
232 // 7.6.2 28thAug2012 Stopped New User screen from popping up when Facebook resets the user settings. Fixed external link interception. Fixed display anomalies in message send window, stopped hidden button from showing in "liked a page" message in ticker. Added extra highlighting/clarity on the App Center permissions section.
233 // 7.8.0 7thSep2012 Fixed the user settings, so facebook cant delete them
234 // Altered block app function to let you block just the app you select, it then asks if you also want to block the other apps
235 // 7.9.0 Fixed shared a link filter, Separated FB Actions/Frictionless sharing apps from the Trending Articles filter, FB Actions/ Frictionless sharing apps should now be filtered by the apps filter
236 // Fixed TL button showing incorrect state after login
237 // 7.9.5 18thSep2012 Fixed comment button (now 2 step submit process), fixed settings bug (facebook was resetting users settings, also clearing browser cookies would reset settings), completely hides sponsored stories from the newsfeed, restored new user greeting
238 // 7.9.6 26thOct2012 Fixed hide trending articles, Fixed link and news article redirection/interception, Fixed filtering on interest lists, Fixed Block App link on permission request pages, Fixed inline youtube video playing on timeline pages, fixed missing images in fbp interface, fixed highlighting on application permission request dialogs
239 // 7.9.7 15thNov2012 Fixed for FF17 (extension), Fixed block application function, added a more prominent block app button to appcenter app pages, fixed application filter + instagram whitelisting, Added FBP Info bar and filtering to game and "page feed", Fixed Fan Page filter, so it doesnt affect "Page Feed" or "Interest Lists", fixed emoticons when font size is altered, fixed app blocking for frictionless sharing apps such as netflix, fixed bug with birthday comment flyout (blue box), changed the default "restore comment buton" option to off., updated new user info page to include info about FBP interest list and page notifications. Added "posted an offer" to sponsored story filter
240 // 8.0.1 30thNov2012 Added options for hiding left hand column links, added "upcoming events" to "hide events box" filter, made font options collapsible, improved ad blocking function
241 // 8.2.0 --thJan2013 Added "Recently Released Albums" to sponsored box filter, fixed Questions filter, fixed "block app" on opera, Added create a group, create a page, and find friends to links you can hide in the left column. Added "Recent Articles About" and "Most Shared on" to trending articles filter, added "play with friends" story filter
242 // redesigned options screen, added lots new options, fixed "drag image into box" covering options screen, cleared out lots of dead code, added option to hide smileys, added fix left column in place option
243 // 8.2.2 13thFeb2013 Fixed slowdown on timeline / like/fan pages. Added hide like suggestions bar, to hide sponsored box option (after you like page, it shows a list of other pages to like). Updated welcome screen to 2 step process.
244 // 8.3.0 21stMar2013 Added Hide "Gifts" and hide Notification Popup Box options, fixed bug in news panel on fbp options screen (bug-if feed was too short, surfaced due to fb post deletions), fixed add block link to fb apps sidebar, fixed hide all videos filter, fixed hidden event page buttons in single column timeline layout mode, improves group story filtering, fixed hidden file upload buttons when background color is set
245 // 8.5.0 24thJun2013 Hide sponsored box option now also Hides the page suggestions on page feed, fixed opera specific bug when certain options were selected, fixed hide emoticons for new "feelings" functionality
246 // Updated for new newsfeed design, Added hide links in right hand column options, Fix saving/retrieving settings. Fixed Timeline cover photo issues. Fixed timeline shift to right on personal timeline pages. Fixed hidden comment button when attaching image to comment.
247 // 8.5.1 27thJul2013 Fixed hide "shared photos" when they are part of a "multi post update", fixed hidden group count and image attach icon when background color was set, updated "changed location" filter to include "is in" and "was in" a location
248 // 8.5.2 14thAug2013 Fixed TL button for new search bar, Fixed hide emoticons option, Fixed line-height in ticker and left column when font is set
249 // 8.5.3 19thAug2013 Fixed Display of FBP info bar + filtering functionality for some users
250 // 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
251 // 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
252 // 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
253
254 // (C) stephen fernandez 2009-2013 http://www.fbpurity.com
255
256 // If you like F.B. Purity please donate, big or small donations, anything is welcome
257 // http://donate.fbpurity.com
258
259 (function() {
260
261 var fbpVersion = "v8.8.2";
262 var debug=0;
263
264 var fbpoptsobj = {}; // object to store the preferences etc
265 try {
266 if (window.top!=window.self) // dont run on framed pages
267 if(!window.location.href.match(/connect\/uiserver\.php\?/)) // but allow it to work on embedded permissions pages
268 return;
269 }
270 catch (e) {
271 ; //return;
272 //alert('caught error ' + e.message);
273 //unsafeWindow.console.log(e);
274 }
275
276 // only run on actual facebook pages
277 try {
278 if(!window.location.hostname.match(/facebook\.com$/))
279 return;
280 }
281 catch(e) {
282 ;
283 //alert('caught error ' + e.message);
284 //unsafeWindow.console.log(e);
285 }
286
287 // set browser type
288 var ischrome=(typeof(chrome)!='undefined' && chrome.extension);
289 var issafari=(typeof(window.navigator.vendor)!='undefined') && (window.navigator.vendor.match(/Apple Computer, Inc\./)) && (window.navigator.userAgent.match(/Version\/5\./) || window.navigator.userAgent.match(/Version\/6\./));
290 //var isopera=window.navigator.userAgent.match(/Opera/);
291 try {
292 var isopera=(typeof(widget) && typeof(widget.preferences));
293 }
294 catch(e) {
295 var isopera=0;
296 }
297 var isasync=(ischrome || issafari);
298
299 //if(unsafeWindow)
300 // console.log=unsafeWindow.console.log;
301
302 //check if another version of the script is running at the same time and if so give a warning.
303 if(document.getElementById('fbpoptslink')) {
304 var collisionerrormsg='Error: You seem to be running 2 versions of FB Purity at the same time, perhaps you are running the addon and the script version, you need to uninstall or disable one of them, otherwise FBP wont function correctly. (<a href="http://faq.fbpurity.com/#collision">More Info</a>)';
305 if(document.getElementById('fbperrormsg'))
306 document.getElementById('fbperrormsg').innerHTML=collisionerrormsg;
307 else
308 window.alert(collisionerrormsg);
309 }
310
311 var fbpstyle=document.createElement('style');
312 var hashead=document.getElementsByTagName('head').length;
313
314 var fbpfreestyle=document.createElement('style'); // for setting a "global" font etc
315 fbpfreestyle.setAttribute('id','fbpfreestyler');
316 fbpfreestyle.setAttribute('type','text/css');
317
318 /*if(hashead)
319 document.getElementsByTagName('head')[0].appendChild(fbpfreestyle);
320 */
321 var fbpboxstyle=document.createElement('style'); // for setting whether boxes are on or off
322 fbpboxstyle.setAttribute('id','fbpboxstyler');
323 fbpboxstyle.setAttribute('type','text/css');
324 /* if(hashead)
325 document.getElementsByTagName('head')[0].appendChild(fbpboxstyle);
326 */
327 var fbpcssstyle=document.createElement('style'); // for adding the user's Custom CSS and general css stuff
328 fbpcssstyle.setAttribute('id','fbpcssstyler');
329 fbpcssstyle.setAttribute('type','text/css');
330 /*if(hashead)
331 document.getElementsByTagName('head')[0].appendChild(fbpcssstyle);
332 */
333 var fbptlstyle=document.createElement('style');
334 fbptlstyle.setAttribute('id','fbptlstyle');
335 fbptlstyle.setAttribute('type','text/css');
336 /*if(hashead)
337 document.getElementsByTagName('head')[0].appendChild(fbptlstyle);
338 */
339
340 fbpescaperegex = function(str){
341 // to escape brackets entered in the custom text filter, fixes some problems, but causes others... (users regexes that require brackets wont work, but the number of advanced users who will be using brackets are probably countable on one hand )
342 var replacements = {
343 '(': '\\(',
344 ')': '\\)',
345 '[': '\\[',
346 ']': '\\]',
347 '{': '\\{',
348 '}': '\\}'
349 }
350 var ret = this;
351 try {
352 for(key in replacements) {
353 str = str.replace('' + key, replacements[''+ key],'g');
354 }
355 }
356 catch(e) {
357 ; // do nothing, traps an error found in ff 4.0b5
358 }
359 return str;
360 };
361
362 var fbpoptslist='becamefriends,becamefan,joinedgroup,attendevent,attendedevent,createdevent,commentlikeslink,commentwall,commentgroupwall,commentpagewall,commenteventwall,updatedprofile,changedprofilepic,changedrelationship,suggestionsbox,connectbox,sponsoredbox,pokebox,happeningnowbar,betabox,commentbutton,offlinefriends,requestsbox,eventsbox,questionsbox,checkedin,uploadedphoto,sharedphoto,uploadedvideo,taggedinvideo,postednote,taggedinnote,postedlink,readarticle,fontfix,fontcolourfix,fontbgcolourfix,fbpfont,fbpfontfix,filterappmessages,recentactivity,chatbox,smileys,fixedleftcolumn,pagestory,sortmostrecent,fixarticleredirects,timelineonecol,upcomingevents,sharedevent,likedlink,sharedpage,commentedlink,likepagebutton,hideallphotos,taggedphoto,likedphoto,commentedphoto,sharedvideo,likedvideo,commentedvideo,youtubevideo,sharedstatus,likedstatus,commentedstatus,taggedstatus,hideallvideos,hidealllinks,lcadvertmgr,lcconnect,lcallpages,lcpagesfeed,lclikepages,lcallapps,lcappcenter,lcevents,lcgamesfeed,lcpokes,lcmusic,lcplaceseditor,lcallgroups,lcallinterests,lccreategroup,lccreatepage,lcfindfriends,lcdeveloper,lcfriends,lcgifts,notificationpopup,rcrecommendedpages,rcrelatedgroups,rcpokes,rcbirthdays,rcfriendrequests,rcgamerequests,trendingbox';
363
364 // new left column options = lcadvertmgr,lcconnect,lcallpages,lcpagesfeed,lclikepages,lcallapps,lcappcenter,lcevents,lcgamesfeed,lcpokes,lcmusic,lcplaceseditor,lcallgroups,lcallinterests,lccreategroup,lccreatepage,lcfindfriends,lcdeveloper,lcfriends
365 // new right column options = rcrecommendedpages,rcrelatedgroups,rcpokes,rcbirthdays,rcfriendrequests,rcgamerequests
366 var fbpoptsarr=fbpoptslist.split(',');
367
368 var optsdiv=document.createElement('div');
369 optsdiv.setAttribute('id','fbpoptsdiv');
370 optsdiv.style.zIndex='155'; //99 (change to 155 to go above drag image box
371 optsdiv.style.position='absolute';
372 optsdiv.style.left='100px'; //143 //150px
373 optsdiv.style.top='1px'; //42px
374 optsdiv.style.background='white';
375 optsdiv.style.border='3px solid black';
376 optsdiv.style.display='none';
377
378 var fbptips=[
379 '<br/>&nbsp;<b>FBP Tip</b>: Want some help with using the Custom Text Filter? Visit the <a target="_blank" href="http://www.fbpurity.com/extras.htm?src=fbptips#customtextfilter">Custom Text Filter Help Section</a>',
380 '<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>',
381 '<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>',
382 '<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>.',
383 '<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>.',
384 '<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>.',
385 '<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.'
386 ];
387
388 var fbpoptshtml= '<div style="float:left;"><table style="top:0px"><tr>'+
389 '<td valign="top"><a title="www.fbpurity.com" href="http://www.fbpurity.com"><img width="100" height="100" border="0" alt="F.B. Purity Logo" src="https://sites.google.com/site/st333v/fbp-1/fbp-ghost-lid-icon-100x100.png"></a></td>'+
390 '<td width="800" valign="top">' +
391 '<h2 style="display:inline" class="uiHeaderTitle">F.B. Purity ' + fbpVersion + ' Options</h2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' +
392 '<table cellpadding="0" cellspacing="0" style="margin-top:3px;width:100%"><tr><td><a target="_blank" title="The Home of the FB Purity browser extension" href="http://www.fbpurity.com">FBP Home</a> | <a title="Get the latest news about F.B. Purity" target="_blank" href="http://news.fbpurity.com">News</a> | <a title="Learn how to use F.B. Purity" target="_blank" href="http://user-guide.fbpurity.com">User Guide</a> | <a title="Get Help with F.B. Purity via the FAQ ( Frequently Asked Questions )" target="_blank" href="http://faq.fbpurity.com">Help</a> | <a title="Become a fan of FB Purity and get the latest FBP news directly in your newsfeed" target="_blank" href="http://fans.fbpurity.com">Fan Page</a> | <a title="Get in touch" target="_blank" href="http://contact.fbpurity.com">Contact</a> | <a title="Donate to FB Purity and help support the project" target="_blank" href="http://donate.fbpurity.com/">Donate</a></td><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td>[ <a onclick="document.getElementById(\'fbpoptsdiv\').style.display=\'none\'" id="closeoptslink" title="Close Options Screen" href="javascript:;"><b>X</b></a> ]</td></tr></table>'+
393
394 //'<table><tr><td>Click the Like button on the FBP fan page to ensure you get the latest updates and news from the fan page directly in your newsfeed. <a href="" onclick="document.getElementById(\'updateframe\').src=\'http://www.fbpurity.com/latest.htm\';document.getElementById(\'updateframe\').style.display=\'block\';return false;">Check for latest version</a><iframe style="display:none" height="40" width="220" id="updateframe"></iframe></td><td><object align="middle" type="text/html" data="https://www.facebook.com/connect/connect.php?id=408502197558&connectis=0&stream=0" width="275" height="65"/></td></tr></table></td>'+
395 '<table><tr><td>"Like" the <a target="_blank" href="http://fans.fbpurity.com">FB Purity Fan Page</a> to make sure you get the latest news and updates about F.B. Purity in your feed. (Please note, due to Facebook censorship of the FBP fan page, you now also need to subscribe to notifications from the Fan page, otherwise you wont see the FBP news in your newsfeed. To do this, go to the FBP Fan Page, hover over the "Like" button then select "Get Notifications". <a target="_blank" href="http://www.fbpurity.com/install.htm?v=' + fbpVersion.split(/v/)[1] + '">Check for latest version</a></td><td><iframe src="https://www.facebook.com/plugins/likebox.php?href=http%3A%2F%2Fwww.facebook.com%2Ffluffbustingpurity&amp;width=292&amp;colorscheme=light&amp;show_faces=true&amp;stream=false&amp;header=false&amp;height=62&amp;ref=FBP_OPTIONS_SCREEN" scrolling="no" frameborder="0" marginwidth="0" style="border:none; overflow:hidden; width:200px; height:67px;" allowTransparency="true"></iframe></td></tr></table></td>'+
396 '<td><!--a target="_blank" href="http://donate.fbpurity.com"><img style="margin-top:3px" border="0" src="https://www.paypal.com/en_US/GB/i/btn/btn_donateCC_LG.gif"></a--></td>'+
397 '</tr></table></div>'+
398
399 // <object align="middle" type="text/html" data="https://www.facebook.com/connect/connect.php?id=408502197558&connections=0&stream=0" width="275" height="65"/>
400 // <iframe src="//www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.fbpurity.com&amp;send=false&amp;layout=standard&amp;width=275&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font=arial&amp;height=65" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:275px; height:65px;" allowTransparency="true"></iframe>
401
402 '<div style="clear:both"></div>'+
403 '<table><tr><td valign="top">';
404
405 // add new dynamic opts
406 function optionsbox(mode) {
407 var table, rowstyle;
408 this.rownum=1;
409 if(1) // ischrome doesnt work in safari
410 var openallboxes='<a title="Open All" href="javascript:;" onclick="document.getElementById(\'fbvariousopts\').click();document.getElementById(\'fbstatusopts\').click();document.getElementById(\'fblinkopts\').click();document.getElementById(\'fbphotoopts\').click();document.getElementById(\'fbvideoopts\').click();document.getElementById(\'fbeventopts\').click();return false;">&#9660;</a>';
411 else
412 var openallboxes='';
413 if (typeof mode !='undefined' && mode=='extras') {
414 this.table='<table><tr><td>'+ openallboxes +'&nbsp;<b>Newsfeed Filters</b>&nbsp;&nbsp;<a title="Help with Extra Stories List" target="_blank" href="http://www.fbpurity.com/extras.htm"><b>?</b></a> </td><td><b>Hide</b></td></tr>';
415 }
416 else
417 //this.table="<table width='100%'>";
418 this.table="";
419
420 // Use tbody to group tables instead of divs ! !!! ! :)
421 this.tableHeader = function (title, hint, varname) {
422 //this.table+='<tr title=""><td colspan="2"><p style="margin-top:3px;margin-bottom:3px;font-weight:bold"><a title="' + hint + '" style="margin-top:2px" href="#" onclick="document.getElementById(\'' + varname + '\').style.display==\'block\' ? (function(){document.getElementById(\'' + varname + '\').style.display=\'none\';document.getElementById(\'' + 'fb'+ varname + '\').setAttribute(\'class\',\'fbpclosedlist\')})() : (function(){document.getElementById(\'' + varname + '\').style.display=\'block\';document.getElementById(\'' + 'fb' + varname + '\').setAttribute(\'class\',\'fbpopenlist\')})();"><span id="' + 'fb' + varname + '" class="fbpclosedlist">' + title + '</span></a></p><div id="' + varname + '" style="display:none"><table>';
423 this.table+='<tbody><tr title=""><td><p style="margin-top:3px;margin-bottom:3px;font-weight:bold"><a title="' + hint + '" style="margin-top:2px" href="javascript:;" onclick="document.getElementById(\'' + varname + '\').style.display==\'none\' ? (function(){document.getElementById(\'' + varname + '\').style.display=\'table-row-group\';document.getElementById(\'' + 'fb'+ varname + '\').setAttribute(\'class\',\'fbpopenlist\');return false;})() : (function(){document.getElementById(\'' + varname + '\').style.display=\'none\';document.getElementById(\'' + 'fb' + varname + '\').setAttribute(\'class\',\'fbpclosedlist\');return false;})();"><span id="' + 'fb' + varname + '" class="fbpclosedlist">' + title + '</span></a></p></td><td></td></tr></tbody><tbody id="' + varname + '" style="display:none">';
424 }
425 this.addTableRow = function(title,hint,varname,inputtype) {
426 this.table+="<tr title='" + hint + "' style='" + ((this.rownum++ % 2) ? "background-color:#ECEFF5 !important" : "") + "'><td> <label style='color:black;font-weight:normal' for='" + varname + "'>" + title + "</label></td>" + "<td><input id='" + varname +"' type='" + inputtype + "'/></td></tr>";
427 }
428 this.tableFooter =function(){
429 //this.table+="</table></div></td></tr></table>";
430 this.table+="</tbody>";
431 }
432 this.buildTable =function(endmode){
433 if(typeof endmode=='undefined')
434 return this.table;
435 else
436 return this.table + '</table>';
437 }
438 }
439
440 newoptscolumn='';
441
442 // Various Options
443 v = new optionsbox('extras');
444 v.tableHeader('Various Story Types','Hide Various story types from the newsfeed', 'variousopts');
445 v.addTableRow('Fan Page Stories','Hide stories posted by Pages you have liked from the newsfeed','pagestory', 'checkbox');
446 v.addTableRow('Trending Articles / Videos','Hide Trending Articles / Trending Videos / Most Shared on / Recent Articles About stories from the newsfeed','readarticle', 'checkbox');
447 v.addTableRow('Facebook Questions','Hide Facebook Questions stories','questionsbox','checkbox');
448 v.addTableRow('Became Friends','Hide Became Friends stories from the newsfeed','becamefriends','checkbox');
449 v.addTableRow('Changed Relationship','Hide Changed Relationship stories from the newsfeed','changedrelationship', 'checkbox');
450 v.addTableRow('Changed Location','Hide Changed Location (Check-in) Stories','checkedin','checkbox');
451 v.addTableRow('Updated Profile Info','Hide Updated Profile Stories','updatedprofile','checkbox');
452 v.addTableRow('Joined a Group','Hide Joined Group Stories (and other group related stories)','joinedgroup','checkbox');
453 v.addTableRow('Posted Note','Hide Posted Note Stories','postednote','checkbox');
454 v.addTableRow('Tagged in Note','Hide Tagged in Note Stories','taggedinnote','checkbox');
455 v.tableFooter();
456 newoptscolumn+=v.buildTable();
457
458 // Event Options
459 v=null
460 v= new optionsbox();
461 v.tableHeader('Event Stories','Hide event stories from the newsfeed', 'eventopts');
462 v.addTableRow('Upcoming Events','Hide Upcoming Events / Upcoming Concerts','upcomingevents','checkbox');
463 v.addTableRow('Attending Event','Hide Attending Event','attendevent','checkbox');
464 v.addTableRow('Attended Event','Hide Attended Event','attendedevent','checkbox');
465 v.addTableRow('Created Event','Hide Created Event','createdevent','checkbox');
466 //v.addTableRow('Liked Event','Hide Liked Events','likedevent','checkbox');
467 v.addTableRow('Shared Event','Hide Shared Events','sharedevent','checkbox');
468 v.tableFooter();
469 newoptscolumn+=v.buildTable();
470
471 // Link / Page Options
472 v=null;
473 v = new optionsbox();
474 v.tableHeader('Link / Page Stories','Hide Link / Page stories from the Newsfeed', 'linkopts');
475 //v.addTableRow('Hide All External Links','All External Links from the Newsfeed','hidealllinks', 'checkbox');
476 v.addTableRow('Liked Page','Hide Liked Page Stories','becamefan','checkbox');
477 v.addTableRow('Shared Page','Hide Shared Page Stories','sharedpage','checkbox');
478 v.addTableRow('Liked Link','Hide Liked Link Stories','likedlink','checkbox');
479 v.addTableRow('Shared Link','Hide Shared Link Stories from the Newsfeed','postedlink','checkbox');
480 v.addTableRow('Commented on Link','Hide Commented on Link Stories','commentedlink','checkbox');
481 v.addTableRow('&quotLike Page&quot; buttons','Hide the &quot;Like Page&quot; buttons from shared items in the newsfeed','likepagebutton','checkbox');
482 v.tableFooter();
483 newoptscolumn+=v.buildTable();
484
485 // Photo Options
486 v=null;
487 v = new optionsbox();
488 v.tableHeader('Photo Stories','Hide photo stories from the newsfeed', 'photoopts');
489 v.addTableRow('Hide All Photos','Hide All Photo stories from the newsfeed','hideallphotos', 'checkbox');
490 v.addTableRow('Shared Photo','Hide Shared Photo / Album stories from the newsfeed','sharedphoto','checkbox');
491 v.addTableRow('Changed Profile Photo','Hide Updated Profile Picture / Cover Photo stories from the newsfeed','changedprofilepic', 'checkbox');
492 v.addTableRow('Uploaded Photo','Hide Added Photo Stories','uploadedphoto','checkbox');
493 v.addTableRow('Tagged in Photo','Hide Tagged in Photo / Album stories','taggedphoto','checkbox');
494 v.addTableRow('Liked Photo','Hide Liked Photo / Album stories','likedphoto','checkbox');
495 v.addTableRow('Commented on Photo','Hide Commented on Photo / Album stories','commentedphoto','checkbox');
496 v.tableFooter();
497 newoptscolumn+=v.buildTable();
498
499 // Video Options
500 v=null;
501 v = new optionsbox();
502 v.tableHeader('Video Stories','Hide Video stories from the Newsfeed', 'videoopts');
503 v.addTableRow('Hide All Videos','Hide All Video Stories from the newsfeed','hideallvideos', 'checkbox');
504 v.addTableRow('Shared Video','Hide Shared FB Video Stories from the newsfeed','sharedvideo','checkbox');
505 v.addTableRow('Uploaded Video','Hide Added Video Stories','uploadedvideo','checkbox');
506 v.addTableRow('Tagged in Video','Hide Tagged in Video Stories','taggedinvideo','checkbox');
507 v.addTableRow('Liked Video','Hide Liked Video Stories','likedvideo','checkbox');
508 v.addTableRow('Commented on Video','Hide Commented on Video Stories','commentedvideo','checkbox');
509 v.addTableRow('Youtube / Vimeo Videos','Hide Youtube and Vimeo Stories','youtubevideo','checkbox');
510 v.tableFooter();
511 newoptscolumn+=v.buildTable();
512
513 // Status // Wall Options
514 v=null;
515 v = new optionsbox();
516 v.tableHeader('Status / Wall Stories','Hide Status / Wall stories from the newsfeed', 'statusopts');
517 v.addTableRow('Shared Status','Hide Shared Status Stories','sharedstatus','checkbox');
518 v.addTableRow('Liked Status','Hide Liked Status Stories','likedstatus','checkbox');
519 v.addTableRow('Commented on Status','Hide Commented on Status stories','commentedstatus','checkbox');
520 v.addTableRow('Tagged in Status','Hide Tagged in Status Stories','taggedstatus','checkbox');
521 v.addTableRow('Wrote on Wall','Hide Wrote on Wall Stories (This should work for comments posted to event, page, user and group wall)','commentwall','checkbox');
522 v.tableFooter();
523 newoptscolumn+=v.buildTable('complete');
524
525 // end new options layout
526 fbpoptshtml += newoptscolumn ;
527
528 fbpoptshtml += '</td><td valign="top">'+
529 '<table><tr><td valign="top"><b>More Options</b></td><td valign="top"><b>Hide</b></td><td rowspan="20" width="12"></td><td valign="top" rowspan="20" width="405"> ' +
530 // new custom text filter/ css / app whitelist tabs
531 '<span id="custextheader" title="Click to access the Custom Text Filter" style="font-weight:bold;background:#ECEFF5;border:1 solid"><a href="#">Custom Text Filter</a></span> - ' +
532 '<span id="appwhitelistheader"><a title="Click to access the Application Whitelist" href="#">Application Whitelist</a></span> - ' +
533 '<span id="custcssheader"><a title="Click to access the Custom CSS BOX" href="#">Custom CSS</a></span><br/>' +
534 '<span id="custextdesc" style="background:#ECEFF5;" title="Please note, \'Regular Expressions\' can also be used.">Enter the words or phrases, on separate lines, that you wish to filter from your news feed. (<a title="Help with Custom Text Filter" target="_blank" href="http://www.fbpurity.com/extras.htm#customtextfilter"><b>Text Filter Help</b></a>) <br/></span><span style="display:none" id="custcssdesc">Enter the Custom CSS code you would like applied to your facebook pages. (<a title="Help with Custom CSS" target="_blank" href="http://www.fbpurity.com/css.htm"><b>CSS Help and examples</b></a>)</span><span style="display:none" id="appwhitelistdesc">Enter the numeric application IDs, on separate lines, of the apps whose stories you wish to allow in your news feed (<a title="Help with Application Whitelist" target="_blank" href="http://www.fbpurity.com/whitelist.htm"><b>Whitelist Help</b></a>)</span>' +
535 '<textarea style="width:404px;height:275px" id="custextta">cust text filter</textarea><textarea style="display:none;" id="custcssta">Custom CSS</textarea><textarea style="display:none;" id="appwhitelistta">app whitelist</textarea>' +
536 //(window.navigator.userAgent.match(/Mozilla\/4\.0 \(compatible\; MSIE 7\.0\; Windows/) ? '' : '<br/>&nbsp;FBP Tip: <a target="_blank" href="http://fbpurity.com/disable-timeline">Want to remove Facebook Timeline? Click here.</a>') +
537
538 fbptips[Math.floor(Math.random() * fbptips.length)] +
539
540 '<br/><div id="fbpnewsdiv"></div>'+
541 '</td></tr>'+
542
543 '<tr title="Hiding the sponsored box also hides Sponsored stories in the newsfeed, Suggested Posts, Facebook Offers, the people you may know, people to subscribe to and recommended pages boxes"><td><label style="color:black;font-weight:normal" for="sponsoredbox">Sponsored Box / Stories</label></td><td><input id="sponsoredbox" type="checkbox"></td></tr>'+
544 '<tr style="background-color:#ECEFF5 !important" title="Un-Tick this if you dont want FBP to filter out application and game stories"><td><label style="color:black;font-weight:normal" for="filterappmessages">Application + Game Stories</label></td><td><input id="filterappmessages" type="checkbox"></td></tr>'+
545 '<tr><td title="The ticker bar is the scrolling newsfeed along the right hand side of your page"><label style="color:black;font-weight:normal" for="happeningnowbar">News Ticker Bar</label></td><td><input id="happeningnowbar" type="checkbox" title="The ticker bar is the scrolling newsfeed at the top right of your page"></td></tr>'+
546 //'<tr title="Please note: Choosing this option also hides birthdays and pokes"><td title="This option hides the Events section in the right column beneath the news ticker and also the Events link in the left column. Please note that this option also hides birthdays and pokes in the right hand column"><label style="color:black;font-weight:normal" for="eventsbox">Events Box</label></td><td><input id="eventsbox" type="checkbox"></td></tr>'+
547 '<tr style="background-color:#ECEFF5 !important"><td><label style="color:black;font-weight:normal" for="offlinefriends">Offline Friends in Chat</label></td><td><input id="offlinefriends" type="checkbox"></td></tr>'+
548 '<tr><td><label style="color:black;font-weight:normal" for="chatbox">Chat Box</label></td><td><input id="chatbox" type="checkbox"></td></tr>'+
549 '<tr style="background-color:#ECEFF5 !important" title="This option hides the smileys and replaces them with their text equivalent, if available"><td><label style="color:black;font-weight:normal" for="smileys">Graphical Smileys / Emoticons</label></td><td><input id="smileys" type="checkbox"></td></tr>'+
550 '<tr title="This option hides the Notification box that pops up in the bottom left hand corner"><td><label style="color:black;font-weight:normal" for="notificationpopup">Notification Popup Box</label></td><td><input id="notificationpopup" type="checkbox"></td></tr>'+
551 '<tr style="background-color:#ECEFF5 !important" title="This option hides Facebook Gifts Links"><td><label style="color:black;font-weight:normal" for="lcgifts">Gifts</label></td><td><input id="lcgifts" type="checkbox"></td></tr>'+
552 '<tr title="Hide the Trending Topics / Hashtags box"><td><label style="color:black;font-weight:normal" for="trendingbox">Trending Topics / Hashtags</label></td><td><input id="trendingbox" type="checkbox"></td></tr>'+
553 '<tr style="display:none"><td>Beta Tester Box</td><td><input id="betabox" type="checkbox"></td></tr>'+
554
555 '<tr><td><b>Further Options</b></td><td><b>Set</b></td></tr>'+
556 '<tr style="background-color:#ECEFF5 !important" title="Selecting this option restores the comment button, though submitting a comment will be a 2 step submit process for techical reasons, if you dont like it, untick this box to make it hidden again. Theres a shortcut for submitting a comment when you have the comment button option enabled, and it is to press Tab, then Enter, then Enter again."><td><label style="color:black;font-weight:normal" for="commentbutton">Restore Comment Button</label></td><td><input id="commentbutton" type="checkbox"></td></tr>'+
557 '<tr title="Makes external links go directly to the site rather than being intercepted and tracked by Facebook first"><td><label style="color:black;font-weight:normal" for="fixarticleredirects">Fix External Link Redirection</label></td><td><input id="fixarticleredirects" type="checkbox"></td></tr>'+
558 '<tr style="background-color:#ECEFF5 !important" title="Force the newsfeed to be sorted by \'Most Recent\'"><td><label style="color:black;font-weight:normal" for="sortmostrecent">Sort Feed : Most Recent</label></td><td><input id="sortmostrecent" type="checkbox"></td></tr>'+
559 '<tr title="Freezes the left column of the newsfeed page in place even when you scroll the page down"><td><label style="color:black;font-weight:normal" for="fixedleftcolumn">Freeze Left Column in Place</label></td><td><input id="fixedleftcolumn" type="checkbox"></td></tr>'+
560 '<tr style="background-color:#ECEFF5 !important" title="Lets you view \'Fan Page\' Timeline pages in a single column layout format. N.B. You can also toggle this setting on and off by clicking the \'TL\' button next to the search box"><td><label style="color:black;font-weight:normal" for="timelineonecol">Timeline : Single Column</label></td><td><input id="timelineonecol" type="checkbox"></td></tr>'+
561
562 // right column links options
563 '<tr title=""><td colspan="2"><p style="margin-top:3px;margin-bottom:3px;font-weight:bold"><a title="Click to open/close the Hide Links in Right Hand Column Options" style="margin-top:2px" href="#" onclick="document.getElementById(\'rightcolopts\').style.display==\'block\' ? (function(){document.getElementById(\'rightcolopts\').style.display=\'none\';document.getElementById(\'fbprightcolopts\').setAttribute(\'class\',\'fbpclosedlist\')})() : (function(){document.getElementById(\'rightcolopts\').style.display=\'block\';document.getElementById(\'fbprightcolopts\').setAttribute(\'class\',\'fbpopenlist\')})();"><span id="fbprightcolopts" class="fbpclosedlist">Hide Links in Right Column</span></a></p><div id="rightcolopts" style="display:none"><table width="100%"><tr><td>Game / App Requests</td><td><input type="checkbox" id="rcgamerequests"></td></tr><tr style="background-color:#ECEFF5 !important"><td>Recommended Pages</td><td><input type="checkbox" id="rcrecommendedpages"></td></tr><tr><td>Suggested Groups</td><td><input type="checkbox" id="rcrelatedgroups"></td></tr><tr style="background-color:#ECEFF5 !important"><td>Pokes</td><td><input type="checkbox" id="rcpokes"></td></tr><tr><td>Events</td><td><input type="checkbox" id="eventsbox"></td></tr><tr style="background-color:#ECEFF5 !important"><td>Friend Requests</td><td><input type="checkbox" id="rcfriendrequests"></td></tr><tr><td>Birthdays</td><td><input type="checkbox" id="rcbirthdays"></td></tr></table></div></td></tr>'+
564
565 // left column links options
566 '<tr title=""><td colspan="2"><p style="margin-top:3px;margin-bottom:3px;font-weight:bold"><a title="Click to open/close the Hide Links in Left Hand Column Options" style="margin-top:2px" href="#" onclick="document.getElementById(\'leftcolopts\').style.display==\'block\' ? (function(){document.getElementById(\'leftcolopts\').style.display=\'none\';document.getElementById(\'fbpleftcolopts\').setAttribute(\'class\',\'fbpclosedlist\')})() : (function(){document.getElementById(\'leftcolopts\').style.display=\'block\';document.getElementById(\'fbpleftcolopts\').setAttribute(\'class\',\'fbpopenlist\')})();"><span id="fbpleftcolopts" class="fbpclosedlist">Hide Links in Left Column</span></a></p><div id="leftcolopts" style="display:none"><table width="100%"><tr title="This option will hide all links under the PAGES heading"><td>Pages Section</td><td><input type="checkbox" id="lcallpages"></td></tr><tr style="background-color:#ECEFF5 !important"><td>Pages Feed</td><td><input type="checkbox" id="lcpagesfeed"></td></tr><tr><td>Like Pages</td><td><input type="checkbox" id="lclikepages"></td></tr><tr style="background-color:#ECEFF5 !important"><td>Create a Page</td><td><input type="checkbox" id="lccreatepage"></td></tr><tr title="This option will hide all links under the APPS heading"><td>Apps Section</td><td><input type="checkbox" id="lcallapps"></td></tr><tr style="background-color:#ECEFF5 !important"><td>App Center</td><td><input type="checkbox" id="lcappcenter"></td></tr><tr><td>Events</td><td><input type="checkbox" id="lcevents"></td></tr><tr style="background-color:#ECEFF5 !important"><td>Games Feed</td><td><input type="checkbox" id="lcgamesfeed"></td></tr><tr><td>Pokes</td><td><input type="checkbox" id="lcpokes"></td></tr><tr style="background-color:#ECEFF5 !important"><td>Music</td><td><input type="checkbox" id="lcmusic"></td></tr><tr><td>Places Editor</td><td><input type="checkbox" id="lcplaceseditor"></td></tr><tr style="background-color:#ECEFF5 !important" title="This option will hide all links under the GROUPS heading"><td>Groups Section</td><td><input type="checkbox" id="lcallgroups"></td></tr><tr><td>Create Group</td><td><input type="checkbox" id="lccreategroup"></td></tr><tr style="background-color:#ECEFF5 !important" title="This option will hide all links under the INTERESTS heading"><td>Interests Section</td><td><input type="checkbox" id="lcallinterests"></td></tr><tr title="Hide Create Advert / Adverts Manager"><td>Create Advert</td><td><input type="checkbox" id="lcadvertmgr"></td></tr><tr style="background-color:#ECEFF5 !important" title="This option will hide all links under the CONNECT heading" ><td>Connect Section</td><td><input type="checkbox" id="lcconnect"></td></tr><tr><td>Find Friends</td><td><input type="checkbox" id="lcfindfriends"></td></tr><tr style="background-color:#ECEFF5 !important" title="This option will hide all links under the FRIENDS section"><td>Friends Section</td><td><input type="checkbox" id="lcfriends"></td></tr></tr><tr title="This option will hide all links under the DEVELOPER section including Manage Apps"><td>Developer Section</td><td><input type="checkbox" id="lcdeveloper"></td></tr></table></div></td></tr>'+
567
568 // fonts and colours section
569 '<tr><td colspan="2" align="center"><p style="margin-top:3px;margin-bottom:3px;font-weight:bold"><a title="Click to open/close Font and Colour Options" href="#" style="margin-top:2px" onclick="document.getElementById(\'fontColorSection\').style.display==\'block\' ? (function(){document.getElementById(\'fontColorSection\').style.display=\'none\';document.getElementById(\'fbpfacopts\').setAttribute(\'class\',\'fbpclosedlist\')})() : (function(){document.getElementById(\'fontColorSection\').style.display=\'block\';document.getElementById(\'fbpfacopts\').setAttribute(\'class\',\'fbpopenlist\')})()"><span id="fbpfacopts" class="fbpclosedlist">Font and Colour Options</span></a></p>'+
570 '<table id="fontColorSection" style="display:none">' +
571 '<tr><td><b>Background Colour</b></td><td><b>Set</b></td></tr><tr style="background-color:#ECEFF5 !important"><td title="Enter a colour name e.g Black,White,Blue,Red,Green etc (You can also use CSS/HTML colour codes)"><input style="width:90px" id="fontbgcolour" value="black" type="color"></td><td><input id="fontbgcolourfix" type="checkbox"></td></tr>' +
572 '<tr><td><b>Font Colour</b></td><td><b>Set</b></td></tr><tr style="background-color:#ECEFF5 !important" title="Enter a colour name e.g Black,White,Blue,Red,Green etc (You can also use CSS/HTML colour codes)"><td><input style="width:90px" id="fontcolour" value="white" type="color"></td><td><input id="fontcolourfix" type="checkbox"></td></tr>' +
573 '<tr><td><b>Font</b></td><td><b>Set</b></td></tr><tr style="background-color:#ECEFF5 !important" title="Enter a font name e.g Arial,Helvetica,Verdana,Courier, etc of a font you have installed on your computer. (If the font name has a space in it, put quote marks around the name)"><td><input style="width:90px" id="fbpfont" value="verdana"></td><td><input id="fbpfontfix" type="checkbox"></td></tr>' +
574 '<tr><td><b>Font Size</b></td><td><b>Set</b></td></tr><tr style="background-color:#ECEFF5 !important"><td><input style="text-align:right;width:40px" id="fontsize" type="number" value="14" min="8" max="60"> px</td><td><input id="fontfix" type="checkbox"></td></tr>' +
575 '</table></td></tr>'+
576
577 '</table>' +
578
579 '<p/><p/><input id="fbpsavesettings" type="button" onclick="this.disabled=1;" value="Save and Close" class="inputsubmit uiButton uiButtonConfirm uiButtonMedium"> <input onclick="document.getElementById(\'fbpoptsdiv\').style.display=\'none\'" id="closefbpsettings" type="button" value="Cancel" class="inputsubmit uiButton uiButtonConfirm uiButtonMedium">'+
580 '<p>If you like F.B. Purity and would like to show your appreciation for all the work<br/>I have put into it and also support future development, please <a href="http://donate.fbpurity.com/">make a donation</a>.<br/></p>' +
581
582 '<table><tr><td><a target="_blank" href="http://donate.fbpurity.com"><img style="margin-top:3px" border="0" height="47" width="160" src="https://www.paypal.com/en_US/GB/i/btn/btn_donateCC_LG.gif"></a></td><td>&nbsp;</td><td>Please tell all your friends about FBP too</td><td><a href="http://www.facebook.com/sharer.php?u=http://is.gd/fbpcnet" title="Share on Facebook" target="_blank"><img style="vertical-align:bottom" width="123" height="22" border="0" src="https://sites.google.com/site/st333v/fbp-1/shareonfacebook.gif" alt="Share on Facebook"></a></td></tr></table>'+
583 '<br/><form><textarea id="fbpsettingstext" style="display:none"></textarea></form></td></tr></table>'+
584 '<div><div style="float:left;margin:10px"><a id="exportsettingslink" href="javascript:;">Export Settings</a> / <a id="importsettingslink" href="javascript:;">Import Settings</a> / <a title="Help with Exporting and Importing Settings" target="_blank" href="http://www.fbpurity.com/faq.htm#importexport"><b>?</b></a></div><div style="float:right;margin:10px"></div></div>';
585
586 var fbpfirstrunhtml='<div id="fbpfirstrundiv" style="width:600px;border:solid 3px;margin-left:150px;padding:8px;font-size:14px;font-family:verdana;background:white !important">'+
587 '<table width="100%"><tr><td width="66%" style="text-align:right"><a target="_blank" href="http://www.fbpurity.com"><img style="margin-left:auto;margin-right:auto" border="0" src="https://fbcdn-photos-a.akamaihd.net/hphotos-ak-ash4/379777_10150515557207559_408502197558_10866589_209695435_a.jpg"></a></td><td width="33%" valign="top" style="text-align:right"><a href="#" title="Close" onclick="document.getElementById(\'fbpfirstrundiv\').style.display=\'none\'"><b>X</b></a></td></tr></table>'+
588 '<br/>'+
589 '<div id="firstpara"><p>Hello there! It looks like this is your first time running F.B. Purity <a title="If you are repeatedly seeing this message, then it means FBP cannot save its settings due to a browser restriction, please click here for the solution" href="http://www.fbpurity.com/faq.htm#troubleshooting"><b>*</b></a></p>'+
590 '<p>The functionality of this extension is closely linked to the current design of the Facebook website. When Facebook change the design or functionality of the site, this can sometimes stop F.B. Purity from working correctly.</p>' +
591 '<p>In order to keep up to date with news of any changes that may break F.B. Purity and for news of new versions of F.B Purity that fix any problems or add new functionality, it is extremely important that you click the like button for the F.B. Purity Fan page on Facebook (below). By doing this you should receive news of updates directly in your newsfeed, and you will also be able to leave feedback about the extension there too.<p/><p><b>Update:</b> Please note, due to Facebook censorship of the FBP fan page, you now also need to subscribe to notifications from the Fan page, otherwise you wont see the FBP news in your newsfeed. To do this, go to the FBP Fan Page, hover over the "Like" button then select "Get Notifications" and you will be notified whenever there is an important update.</p>'+
592 '<div><p><b>First Step:</b> Click Like: <iframe src="https://www.facebook.com/plugins/likebox.php?href=http%3A%2F%2Fwww.facebook.com%2Ffluffbustingpurity&amp;width=292&amp;colorscheme=light&amp;show_faces=true&amp;stream=false&amp;header=false&amp;height=62&amp;ref=FBP_WELCOME_POPUP" scrolling="no" frameborder="0" marginwidth="0" style="border:none; overflow:hidden; width:295px; height:67px;" allowTransparency="true"></iframe></p></div>'+
593 '<p></p><p><b>Next Step:</b> <a onclick="document.getElementById(\'firstpara\').style.display=\'none\';document.getElementById(\'secondpara\').style.display=\'block\';" href="javascript:;">Click here for instructions on how to use F.B. Purity</a></p></div>'+
594
595 '<div id="secondpara" style="display:none"><p>To change F.B. Purity&apos;s settings, click the &apos;<b>F.B. Purity</b>&apos; link at the top of your newsfeed and to learn more about how F.B. Purity works, please read the <a target="_blank" href="http://www.fbpurity.com/user-guide.htm">F.B. Purity User Guide</a><p/>'+
596 '<p>If you have any problems with F.B. Purity, please check out the <a target="_blank" href="http://www.fbpurity.com/#troubleshooting">F.B. Purity Troubleshooting Guide / Help Page</a></p>'+
597 '<p>If you have any questions about F.B. Purity, please first read the <a target="_blank" href="http://www.fbpurity.com/faq.htm">F.B. Purity FAQ (Frequently Asked Questions)</a> as your questions are most likely answered there.</p>'+
598
599 '<p>If you like F.B. Purity, please show your support by <a target="_blank" href="http://www.fbpurity.com/donate.htm">Donating</a>, as developing, maintaining and supporting this project is an awful lot of work, and I dont get paid for this. Please also tell all your friends about F.B. Purity too.</p>'+
600 '<p>Thanks!</p>'+
601 '<p>Steve - The Developer of <a target="_blank" href="http://www.fbpurity.com">F.B. (Fluff Busting) Purity</a></p>'+
602 '<table width="100%"><tr><td style="text-align:center"><a onclick="document.getElementById(\'fbpfirstrundiv\').style.display=\'none\'" href="#">Close</a></td></tr></table></div>'+
603 '</div>';
604
605 function hideotherdivs(e) {
606 divname=e.target.parentNode.id.split(/header/)[0];
607 var boxlist="custext,appwhitelist,custcss";
608 boxarr=boxlist.split(',');
609 for (i in boxarr)
610 if(boxarr[i]==divname) {
611 document.getElementById(divname + "header").setAttribute('style','background:#ECEFF5; font-weight:bold; font-size:15; border:1 solid');
612 document.getElementById(divname + "desc").setAttribute('style','display:block;background:#ECEFF5;');
613 document.getElementById(divname + "ta").setAttribute('style','display:block;width:404px;height:275px');
614 }
615 else {
616 document.getElementById(boxarr[i] + 'header').setAttribute('style','background:white;font-weight:normal;font-size:14;border:0');
617 document.getElementById(boxarr[i] + 'desc').setAttribute('style','display:none');
618 document.getElementById(boxarr[i] + 'ta').setAttribute('style','display:none;');
619 }
620 }
621
622 function importsettingsbasic(ev) {
623
624 ev.preventDefault();
625 fbpsettingstext=prompt('F.B. Purity Settings Importer\n\nPaste in your saved FBP settings text, then click OK.')
626
627 if(fbpsettingstext==null)
628 return;
629
630 if(!fbpsettingstext.length) {
631 window.alert('You didnt enter valid settings text');
632 return;
633 }
634 else {
635 try {
636 JSON.parse(fbpsettingstext);
637 }
638 catch(e) {
639 window.alert('Error, settings text malformed, not valid. Import failed!');
640 return;
641 }
642 fbpsavevalue('fbpoptsjson-' + currentuserid,fbpsettingstext);
643
644 window.alert('Import Successful. FBP Settings have been updated! Page will now reload.');
645
646 //close prefs screen
647 document.getElementById('fbpoptsdiv').style.display='none';
648
649 //reload page to refresh preferences
650 window.location.reload(true);
651 }
652 }
653
654 function exportsettingsbasic(ev) {
655 ev.preventDefault();
656 exportsettingsbasic2();
657 }
658
659 // figure out how to use callbacks, may be a better solution here....
660
661 function exportsettingsbasic2(opts) {
662 document.getElementById('fbpsettingstext').setAttribute('style','display:block;width:600px;height:220px');
663 var exporttext;
664 if(!opts && opts!='') {
665 exporttext=fbploadvalue('fbpoptsjson-' + currentuserid,exportsettingsbasic2);
666 if(exporttext==-999)
667 return
668 }
669 else
670 exporttext=opts;
671
672 if ((typeof(exporttext)=='undefined') || (exporttext.length =="")) {
673 exporttext=fbploadvalue('fbpoptsjson',exportsettingsbasic2);
674 if(exporttext==-999)
675 return;
676 }
677 document.getElementById('fbpsettingstext').textContent=exporttext;
678
679 window.alert('Copy the FBP settings text from the text box below and save it in a document or text file. If you ever need to restore your settings from that file, simply copy the text from the file, click the Import Settings link and paste the text in.');
680 // autoselect the text in the textarea
681 el=document.getElementById('fbpsettingstext');
682 var range;
683 if ((/textarea/i.test(el.tagName)) || ((/input/i.test(el.tagName)) && (/text/i.test(el.type)))) {
684 el.select();
685 } else if (!!window.getSelection) { // FF, Safari, Chrome, Opera
686 var sel = window.getSelection();
687 range = document.createRange();
688 range.selectNodeContents(el);
689 sel.removeAllRanges();
690 sel.addRange(range);
691 } else if (!!document.selection) { // IE
692 document.selection.empty();
693 range = document.body.createTextRange();
694 range.moveToElementText(el);
695 range.select();
696 }
697 }
698
699 function get_cookie ( cookie_name )
700 {
701 var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );
702 if ( results )
703 return ( unescape ( results[2] ) );
704 else
705 return null;
706 }
707
708 function set_cookie (name,value) {
709 document.cookie = name+ "=" + escape(value)+ ';expires=01/04/2099 00:00:00';
710 }
711
712 // check for GM_set/get API
713 var isgmapi, islocstor;
714 try {
715 if(typeof(GM_setValue)!='undefined') {
716 GM_setValue('test',1)
717 if ( GM_getValue('test')==1)
718 isgmapi=1;
719 else
720 isgmapi=0;
721 }
722 else
723 isgmapi=0;
724 }
725 catch (e) {
726 console.log(e);
727 isgmapi=0;
728 }
729 // check for localstorage
730 try {
731 if(typeof(window.localStorage)!='undefined')
732 islocstor=1;
733 else
734 islocstor=0;
735 }
736 catch(e) {
737 islocstor=0;
738 }
739
740 function fbpsavevalue(name,value){
741 try {
742 if(isgmapi) {
743 GM_setValue(name,value);
744 }
745 else if(ischrome) { // ischrome
746 chrome.extension.sendRequest({method: "setLocalStorage", key: name, value: value}, function(response) {
747 ;//console.log(response.data);
748 });
749 }
750 else if(issafari) { //(typeof(window.navigator.vendor)!='undefined') && (window.navigator.vendor.match(/Apple Computer, Inc\./)) && window.navigator.userAgent.match(/Version\/5\./)
751 safari.self.tab.dispatchMessage("setLocalStorage",{key: name, value: value});
752 /*function replyToMessage(response) {
753 if (response.name === "data") {
754 console.log('safari save value response:' + response.message);
755 //if((typeof(response.message) !='undefined') && response.message.match(/\"filterappmessages\"/)) {
756 // window.localStorage[name]=response.message;
757 // window.location.reload();
758 //}
759 }
760 }*/
761 // register for message events
762 //safari.self.addEventListener("message", replyToMessage, false);
763 }
764 else if(isopera) { //window.navigator.userAgent.match(/Opera/)
765 widget.preferences[name]=value;
766 }
767 /* 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
768 else if(locstor) {
769 window.localStorage[name]=value;
770 }
771 else
772 set_cookie(name,value);
773 */
774 }
775 catch (e) {
776 //console.log(e);
777 if(islocstor)
778 window.localStorage[name]=value;
779 else
780 set_cookie(name,value);
781 }
782 }
783
784 function fbploadvalue(name,funct){
785 if(debug)
786 console.trace();
787 //console.log('entering function : ' + arguments.callee.name);
788
789 try {
790 if(isgmapi) {
791 val = GM_getValue(name);
792 }
793 else if(ischrome) {
794 // Chrome Extension
795 chrome.extension.sendRequest({method: "getLocalStorage", key: name}, function(response) {
796 //fbpdynamicreload(response.data); // we should maybe figure a way of doing this event driven
797 if(funct) {
798 if(debug)
799 console.log("we in call back, and heres the data: " + response.data);
800 if((typeof(response)=='undefined') || (typeof(response.data)=='undefined'))
801 funct('');
802 else
803 funct(response.data);
804 }
805 //}
806 });
807 val=-999;
808 if(debug)
809 console.log('name: ' + name + ' value' + val);
810 }
811 else if(issafari) {
812 // Safari Extension
813 safari.self.tab.dispatchMessage("getLocalStorage",name);
814 function replyToMessage(response) {
815 if(debug)
816 console.log(response.message);
817 if(funct) {
818 if(debug)
819 console.log("we in call back, and heres the data: " + response.message);
820 if(typeof(response.message)=='undefined')
821 funct('');
822 else
823 funct(response.message);
824 }
825 }
826 // register for message events
827 safari.self.addEventListener("message", replyToMessage, false);
828 val=-999;
829 }
830 else if(isopera) {
831 if((typeof(widget.preferences[name]) !='undefined') ) {
832 val = widget.preferences[name];
833 //fbpdynamicreload();
834 }
835 else val='';
836 }
837 }
838 catch (e) {
839 console.log(e);
840 if(islocstor)
841 val=window.localStorage[name];
842 else
843 val=get_cookie(name);
844 }
845 return val;
846 }
847
848 function initundef() {
849 if(typeof (fbpoptsobj.filterappmessages) =='undefined')
850 fbpoptsobj.filterappmessages=1;
851 if(typeof (fbpoptsobj.sortmostrecent) =='undefined')
852 fbpoptsobj.sortmostrecent=0;
853 if(typeof (fbpoptsobj.fixarticleredirects) =='undefined')
854 fbpoptsobj.fixarticleredirects=1;
855 }
856
857 function fbpgetprefs(opts) {
858 if(debug) {
859 console.trace();
860 console.log(arguments.callee.length);
861 console.log(opts);
862 //console.log('entering function : ' + arguments.callee.name);
863 }
864
865 var optsdump;
866 if(typeof(opts)!='undefined') {
867 if(opts && opts.length) {
868 if(debug)
869 console.log("opts=" + opts);
870 optsdump=opts;
871 try {
872 fbpoptsobj=JSON.parse(optsdump);
873 }
874 catch(e) {
875 console.log('error reading json in fbpgetprefs');
876 console.dir(e);
877 return;
878 }
879 initundef();
880 initstage2();
881 finalstage();
882 }
883 else {
884 if(debug)
885 console.log('are we at the top?');
886 if(!issafari) // because getting vars out of localstorage is not working in safari, we not checking for first run
887 fbpfirstruncheck();
888 fbpoptsobjinit();
889 initundef();
890 initstage2();
891 finalstage();
892 }
893 }
894 else {
895 //console.log("user" + currentuserid);
896 optsdump = fbploadvalue('fbpoptsjson-' + currentuserid,fbpgetprefs);//'fbpgetprefs'
897 if(optsdump!=-999) { //if(!isasync) {
898 if(optsdump && optsdump.length) {
899 try{
900 fbpoptsobj=JSON.parse(optsdump);
901 }
902 catch(e) {
903 fbpoptsobj=JSON.parse(decodeURIComponent(optsdump)); // this line is to make it compatible with older firefox extension which urlencoded/decoded saved values inside the extension
904 }
905 initundef();
906 initstage2();
907 finalstage();
908 }
909 else {
910 if(debug)
911 console.log('are we at the bottom?');
912 if(!issafari) // because getting vars out of localstorage is not working in safari, we not checking for first run
913 fbpfirstruncheck();
914 fbpoptsobjinit();
915 initundef();
916 initstage2();
917 finalstage();
918 }
919 }
920 }
921 //unsafeWindow.console.log(typeof(optsdump) + ' xxx ' + optsdump + 'xxx' + optsdump.length);
922 }
923
924 function fbpfirstruncheck(result) {
925
926 if(debug) {
927 console.trace();
928 console.log('firstrun? ' + result);
929 }
930 //console.log('entering function : ' + arguments.callee.name);
931 var fbpfirstrun;
932 //alert("firstres = " + result);
933 //if(result || (result=='')) { was working on chrome and firefox and opera?
934 if(typeof(result)!='undefined') {
935 fbpfirstrun=result;
936 }
937 else
938 fbpfirstrun=fbploadvalue('fbpfirstrun',fbpfirstruncheck);
939 if(fbpfirstrun==-999)
940 return;
941
942 //alert("secondres = " + fbpfirstrun); // make sure user is logged in (pageLogo element is there)
943 if (((fbpfirstrun=='') || (typeof(fbpfirstrun)=='undefined') || (fbpfirstrun==null)) && (!(window.location.href.match(/^https?:\/\/apps\.facebook|^https?:\/\/blog\.facebook|^https?:\/\/secure\.facebook/)))) {
944 if(!document.getElementById('fbpfirstrundiv') && document.getElementById('blueBar') && document.getElementById('pageLogo')) {
945 ph=document.getElementById('blueBar'); //pageHead
946 firstrundiv=document.createElement('div');
947 firstrundiv.innerHTML=fbpfirstrunhtml;
948 if(ph.firstChild)
949 ph.firstChild.parentNode.insertBefore(firstrundiv, ph.firstChild.nextSibling);
950 fbpsavevalue('fbpfirstrun',new Date() + "");
951 }
952 }
953 }
954
955 function checkifupdaterequired(currver,latestver) {
956 if(debug)
957 console.trace();
958 //console.log('entering function : ' + arguments.callee.name);
959
960 if (currver && latestver) {
961 var fbpupdatehtml = "**<a title='An update is available for F.B. Purity (v" + latestver +").\nClick here to begin the upgrade process' href='http://www.fbpurity.com/install.htm?v=" + currver + "'><b>Update</b></a>** ";
962 if (currver==latestver)
963 return; //window.alert('Congrats! You have the latest version of FB Purity :)');
964 else {
965 cvpart1=currver.split(/\./)[0];
966 cvpart2=currver.split(/\./)[1];
967 cvpart3=currver.split(/\./)[2];
968 lvpart1=latestver.split(/\./)[0];
969 lvpart2=latestver.split(/\./)[1];
970 lvpart3=latestver.split(/\./)[2];
971 if(cvpart1<lvpart1) {
972 if(document.getElementById('fbpupgradeinfo'))
973 document.getElementById('fbpupgradeinfo').innerHTML=fbpupdatehtml;
974 }
975 else if (cvpart1 == lvpart1) {
976 if(cvpart2 < lvpart2) {
977 if(document.getElementById('fbpupgradeinfo'))
978 document.getElementById('fbpupgradeinfo').innerHTML=fbpupdatehtml;
979 }
980 else if (cvpart2 == lvpart2) {
981 if(cvpart3 < lvpart3)
982 if(document.getElementById('fbpupgradeinfo'))
983 document.getElementById('fbpupgradeinfo').innerHTML=fbpupdatehtml;
984 }
985 }
986
987 }
988 }
989 }
990
991 function checkupdatefeed(result) {
992 if(debug)
993 console.trace();
994 //console.log('entering function : ' + arguments.callee.name);
995
996 var fbplastupdatecheck;
997 if(result || (result=='')) {
998 if(debug)
999 console.log('fbplastupdatecheck val = ' + result);
1000 fbplastupdatecheck=result;
1001 if(typeof(fbplastupdatecheck)=='undefined')
1002 fbplastupdatecheck='';
1003 }
1004 else
1005 fbplastupdatecheck=fbploadvalue('fbplastupdatecheck',checkupdatefeed);
1006 if(fbplastupdatecheck==-999)
1007 return;
1008
1009 if(debug)
1010 console.log('fbplastupdate=' + fbplastupdatecheck);
1011
1012 var currtime = new Date().getTime(); // creates a new Date representing today
1013 var currver = fbpVersion.replace('v','');
1014
1015 if( (typeof(fbplastupdatecheck)!='undefined') && (fbplastupdatecheck != '') && (fbplastupdatecheck!=null)) {
1016 var fbplastupdatecheckdate=fbplastupdatecheck.split(/\:/)[0];
1017 var fbplastupdatecheckver=fbplastupdatecheck.split(/\:/)[1];
1018 if((typeof(fbplastupdatecheckver) !='undefined') && (!fbplastupdatecheckver.match(/\./)))
1019 fbplastupdatecheckver='';
1020 if(debug)
1021 console.log('lastupdate check version= '+ fbplastupdatecheckver);
1022 if((typeof(fbplastupdatecheckdate) !='undefined') && fbplastupdatecheckdate.match(/^\d+$/)) {
1023 //To compute the difference, convert both to their millisecond representations and subtract:
1024 var diff = currtime - fbplastupdatecheckdate;
1025 //In this case the difference will be negative, as d1 preceeds d2.
1026 var num_days = (((diff / 1000) / 60) / 60) / 24;
1027 if(num_days < 1) {
1028 //var cachedupdatever=fbploadvalue(fbpupdatever);
1029 if((typeof(fbplastupdatecheckver)!='undefined') && (fbplastupdatecheckver != ''))
1030 checkifupdaterequired(currver,fbplastupdatecheckver);
1031 return;
1032 }
1033 }
1034 else {
1035 // time value is corrupted somehow?
1036 if (typeof(unsafeWindow) =='undefined')
1037 ;//console.log('error: fbplastupdatecheck= ' + fbplastupdatecheck);
1038 else
1039 ;//unsafeWindow.console.log('error: fbplastupdatecheck= ' + fbplastupdatecheck);
1040 return;
1041 }
1042 }
1043
1044 //fbpsavevalue('fbplastupdatecheck',currtime + '');
1045 var http = new window.XMLHttpRequest();
1046 var url = window.location.protocol + "//www.facebook.com/feeds/page.php?id=186105101490362&format=json"; // https://www.facebook.com/pages/FB-Purity-Updates/186105101490362
1047 http.open("GET", url, true);
1048 //http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
1049 //http.setRequestHeader("Content-length", params.length);
1050 //http.setRequestHeader("Connection", "close");
1051
1052 http.onreadystatechange = function() {
1053 if(http.readyState == 4 && http.status == 200) {
1054 //console.log(http.responseText);
1055 try {
1056 var fbpfeed = JSON.parse(http.responseText);
1057 }
1058 catch (e) {
1059 http=fbpfeed=null;
1060 return;
1061 }
1062 if(fbpfeed.entries[0].title.length && fbpfeed.entries[0].title.match(/F.B. Purity v(\d{1,}\.\d{1,}\.\d{1,}) /))
1063 latestver=fbpfeed.entries[0].title.match(/F.B. Purity v(\d{1,}\.\d{1,}\.\d{1,}) /)[1];
1064 else
1065 return;
1066 //var x = new Date (fbpfeed.entries[0].published);
1067 //newsa.setAttribute('title', "Published - " + x.toLocaleDateString());
1068 //alert(currver + ' ' + latestver);
1069 fbpsavevalue('fbplastupdatecheck', currtime + ':' + latestver);
1070 checkifupdaterequired(currver,latestver);
1071 http=null;
1072 }
1073 }
1074 http.send();
1075 }
1076
1077 if (!issafari) // workaround for bug in message passing in safari extension for getting fbpprefs (the messages were crossing over to the wrong locations)
1078 window.setTimeout(function() {
1079 checkupdatefeed();
1080 }, 3000); // wait a bit, to insure fbpinfobar will be there...
1081
1082
1083 function fbppopulateprefs() {
1084 if(debug)
1085 console.trace();
1086 //console.log('entering function : ' + arguments.callee.name);
1087
1088 // if options screen has been wiped out, re-insert it
1089 if(!document.getElementById('fbpoptsdiv') && document.getElementById('content') ) {
1090 document.getElementById('content').appendChild(optsdiv);
1091 document.getElementById('fbpsavesettings').addEventListener('click',fbpsavesettings,false);
1092
1093 document.getElementById('exportsettingslink').addEventListener('click',exportsettingsbasic,false);
1094 document.getElementById('importsettingslink').addEventListener('click',importsettingsbasic,false);
1095
1096 document.getElementById('custextheader').addEventListener('click',hideotherdivs,false);
1097 document.getElementById('appwhitelistheader').addEventListener('click',hideotherdivs,false);
1098 document.getElementById('custcssheader').addEventListener('click',hideotherdivs,false);
1099 }
1100
1101 // fill out the preferences form with current settings
1102 for(var i=0;i<fbpoptsarr.length;i++) {
1103 if(document.getElementById(fbpoptsarr[i])) {
1104 if(fbpoptsobj[fbpoptsarr[i]]==1) {
1105 document.getElementById(fbpoptsarr[i]).checked=true;
1106 //unsafeWindow.console.log (filterapptext, fbpoptsarr[i] + ' ' + ' ' + fbpoptsobj[fbpoptsarr[i]]);
1107 }
1108 else
1109 document.getElementById(fbpoptsarr[i]).checked=false;
1110 }
1111 }
1112 if(fbpoptsobj.customtextfilter && fbpoptsobj.customtextfilter.length) {
1113 document.getElementById('custextta').value=fbpoptsobj.customtextfilter.replace(/\,/g,"\n");
1114 //unsafeWindow.console.log(fbpoptsobj.customtextfilter);
1115 }
1116 else
1117 document.getElementById('custextta').value='';
1118
1119 if(fbpoptsobj.userappwhitelist && fbpoptsobj.userappwhitelist.length) {
1120 document.getElementById('appwhitelistta').value=fbpoptsobj.userappwhitelist.replace(/\,/g,"\n");
1121 //unsafeWindow.console.log(fbpoptsobj.userappwhitelist);
1122 }
1123 else {
1124 document.getElementById('appwhitelistta').value='';
1125 }
1126
1127 if(fbpoptsobj.fontsize)
1128 document.getElementById('fontsize').value=fbpoptsobj.fontsize;
1129
1130 if(fbpoptsobj.fontcolour)
1131 document.getElementById('fontcolour').value=fbpoptsobj.fontcolour;
1132
1133 if(fbpoptsobj.fontbgcolour)
1134 document.getElementById('fontbgcolour').value=fbpoptsobj.fontbgcolour;
1135
1136 if(fbpoptsobj.fbpfont)
1137 document.getElementById('fbpfont').value=fbpoptsobj.fbpfont;
1138
1139 if(fbpoptsobj.fbpcustomcss && (typeof(fbpoptsobj.fbpcustomcss) != 'undefined')) {
1140 document.getElementById('custcssta').value=fbpoptsobj.fbpcustomcss;
1141 //unsafeWindow.console.log(fbpoptsobj.fbpcustomcss);
1142 }
1143 else
1144 document.getElementById('custcssta').value='';
1145 }
1146
1147 function fbpsavesettings(ev) {
1148
1149 for(var i=0;i<fbpoptsarr.length;i++) {
1150
1151 if(document.getElementById(fbpoptsarr[i]) && document.getElementById(fbpoptsarr[i]).checked==true)
1152 fbpoptsobj[fbpoptsarr[i]]=1;
1153 else
1154 fbpoptsobj[fbpoptsarr[i]]=0;
1155 }
1156
1157 if(document.getElementById('custextta').value.length) {
1158 //fbpoptsobj.customtextfilter=document.getElementById('customtextfilter').value.replace(/, *$/,'','g'); // replace trailing comma and spaces
1159 tempcustomtextfilter=document.getElementById('custextta').value.replace(/[\r\n|\r|\n]/g,"\,").replace(/\,{1,}/g,'\,').replace(/,$/,'').replace(/^,/,'');
1160 fbpoptsobj.customtextfilter='';
1161 ctfarr=tempcustomtextfilter.split(',');
1162 //for(i=ctfarr.length-1;i>=0;i--)
1163 for(i=0;i<ctfarr.length;i++)
1164 if (ctfarr[i].replace(/^ {1,}$/,'')!='')
1165 fbpoptsobj.customtextfilter+=ctfarr[i] + ','; // strip out lines that are just spaces.
1166
1167 fbpoptsobj.customtextfilter=fbpoptsobj.customtextfilter.replace(/,$/,''); // strip trailing comma
1168 // alert(fbpoptsobj.customtextfilter);
1169 }
1170 else
1171 fbpoptsobj.customtextfilter='';
1172
1173 if(document.getElementById('appwhitelistta').value.length) {
1174 fbpoptsobj.userappwhitelist=document.getElementById('appwhitelistta').value.replace(/ /g,'').replace(/[\r\n|\r|\n]/g,"\,").replace(/\,{1,}/g,'\,').replace(/,$/,'').replace(/^,/,'');
1175 //alert(fbpoptsobj.userappwhitelist);
1176 }
1177 else
1178 fbpoptsobj.userappwhitelist='';
1179
1180 // begin new custom css box
1181 if(document.getElementById('custcssta').value.length) {
1182 fbpoptsobj.fbpcustomcss=document.getElementById('custcssta').value;
1183 }
1184 else
1185 fbpoptsobj.fbpcustomcss='';
1186 // end new custom css box
1187
1188 fbpoptsobj.fontsize=document.getElementById('fontsize').value;
1189 fbpoptsobj.fontcolour=document.getElementById('fontcolour').value;
1190 fbpoptsobj.fontbgcolour=document.getElementById('fontbgcolour').value;
1191 fbpoptsobj.fbpfont=document.getElementById('fbpfont').value;
1192
1193 //save to prefs obj to localstorage
1194 fbpsavevalue('fbpoptsjson-' + currentuserid, JSON.stringify(fbpoptsobj));
1195
1196 //console.log(JSON.stringify(fbpoptsobj));
1197
1198 //close prefs screen
1199 document.getElementById('fbpoptsdiv').style.display='none';
1200
1201 //reload page to refresh preferences
1202 window.location.reload(true);
1203
1204 // Dynamically update the page instead of reloading the whole page, only problem is if the page contains many posts, this is very slow.
1205 /*
1206 document.getElementById("fbpsavesettings").disabled=false;
1207 fbpgetprefs();
1208 resetclasses(); // need to also reset other filters and css
1209 initstage2();
1210 //updateblockedcount(); // doesnt seem to do anything and clear the shizzle, should automatically update it. (we are getting nodes with 2 classes fbpnormal and fbpblocked
1211 cleartheshizzle(document);
1212 */
1213 }
1214
1215 function fbpoptsobjinit() {
1216 if(debug)
1217 console.trace();
1218 //console.log('entering function : ' + arguments.callee.name);
1219
1220 // set up default options
1221 fbpoptsobj.filterappmessages=1;
1222 fbpoptsobj.becamefriends=1;
1223 fbpoptsobj.becamefan=1;
1224 fbpoptsobj.joinedgroup=1;
1225 fbpoptsobj.attendevent=1;
1226 fbpoptsobj.attendedevent=1;
1227 fbpoptsobj.createdevent=0;
1228
1229 fbpoptsobj.commentlikeslink=0;
1230 fbpoptsobj.commentwall=0;
1231 fbpoptsobj.commentgroupwall=0;
1232 fbpoptsobj.commentpagewall=0;
1233 fbpoptsobj.commenteventwall=0;
1234 fbpoptsobj.updatedprofile=0;
1235 fbpoptsobj.changedprofilepic=0;
1236 fbpoptsobj.changedrelationship=0;
1237
1238 fbpoptsobj.uploadedphoto=0;
1239 fbpoptsobj.sharedphoto=0;
1240 fbpoptsobj.uploadedvideo=0;
1241 fbpoptsobj.taggedinvideo=0;
1242 fbpoptsobj.postednote=0;
1243 fbpoptsobj.taggedinnote=0;
1244 fbpoptsobj.postedlink=0;
1245 fbpoptsobj.readarticle=0;
1246 fbpoptsobj.checkedin=0;
1247
1248 fbpoptsobj.suggestionsbox=0;
1249 fbpoptsobj.connectbox=0;
1250 fbpoptsobj.sponsoredbox=1;
1251 fbpoptsobj.pokebox=0;
1252 fbpoptsobj.happeningnowbar=0;
1253 fbpoptsobj.betabox=0;
1254 fbpoptsobj.commentbutton=0;
1255 fbpoptsobj.offlinefriends=1;
1256
1257 fbpoptsobj.requestsbox=0;
1258 fbpoptsobj.eventsbox=0;
1259 fbpoptsobj.questionsbox=0;
1260 fbpoptsobj.chatbox=0;
1261 fbpoptsobj.pagestory=0;
1262 fbpoptsobj.trendingbox=0;
1263
1264 //fbpoptsobj.commentslikestopnews=0;
1265 fbpoptsobj.recentactivity=0;
1266
1267 fbpoptsobj.fontsize='13';
1268 fbpoptsobj.fontfix='0';
1269 fbpoptsobj.fontcolour='';
1270 fbpoptsobj.fontcolourfix=0;
1271 fbpoptsobj.fontbgcolour='';
1272 fbpoptsobj.fontbgcolourfix=0;
1273 fbpoptsobj.fbpfont='';
1274 fbpoptsobj.fbpfontfix=0;
1275
1276 fbpoptsobj.sortmostrecent=0;
1277 fbpoptsobj.fixarticleredirects=1;
1278 fbpoptsobj.timelineonecol=0;
1279
1280 // left hand column options
1281 fbpoptsobj.lcadvertmgr=0;
1282 fbpoptsobj.lcconnect=0;
1283 fbpoptsobj.lcallpages=0;
1284 fbpoptsobj.lcpagesfeed=0;
1285 fbpoptsobj.lclikepages=0;
1286 fbpoptsobj.lcallapps=0;
1287 fbpoptsobj.lcappcenter=0;
1288 fbpoptsobj.lcevents=0;
1289 fbpoptsobj.lcgamesfeed=0;
1290 fbpoptsobj.lcpokes=0;
1291 fbpoptsobj.lcmusic=0;
1292 fbpoptsobj.lcplaceseditor=0;
1293 fbpoptsobj.lcallgroups=0;
1294 fbpoptsobj.lcallinterests=0;
1295 fbpoptsobj.lcfindfriends=0;
1296 fbpoptsobj.lccreatepage=0;
1297 fbpoptsobj.lccreategroup=0;
1298 fbpoptsobj.lcdeveloper=0;
1299 fbpoptsobj.lcfriends=0;
1300 fbpoptsobj.lcgifts=0;
1301
1302 // right hand column options
1303 fbpoptsobj.rcrecommendedpages=0;
1304 fbpoptsobj.rcrelatedgroups=1;
1305 fbpoptsobj.rcpokes=0;
1306 fbpoptsobj.rcbirthdays=0;
1307 fbpoptsobj.rcfriendrequests=0;
1308 fbpoptsobj.rcgamerequests=0;
1309
1310 // Begin new options 28th jan 2013
1311 fbpoptsobj.upcomingevents=0;
1312 fbpoptsobj.sharedevent=0;
1313
1314 fbpoptsobj.sharedpage=0;
1315 fbpoptsobj.likedlink=0;
1316 fbpoptsobj.commentedlink=0;
1317 fbpoptsobj.likepagebutton=0;
1318 fbpoptsobj.hideallphotos=0;
1319 fbpoptsobj.taggedphoto=0;
1320 fbpoptsobj.likedphoto=0;
1321 fbpoptsobj.commentedphoto=0;
1322
1323 fbpoptsobj.sharedvideo=0;
1324 fbpoptsobj.likedvideo=0;
1325 fbpoptsobj.commentedvideo=0;
1326 fbpoptsobj.youtubevideo=0;
1327
1328 fbpoptsobj.sharedstatus=0;
1329 fbpoptsobj.likedstatus=0;
1330 fbpoptsobj.commentedstatus=0;
1331 fbpoptsobj.taggedstatus=0;
1332 fbpoptsobj.smileys=0;
1333 fbpoptsobj.notificationpopup=0;
1334
1335 fbpoptsobj.hidealllinks=0;
1336 fbpoptsobj.hideallvideos=0;
1337 fbpoptsobj.fixedleftcolumn=1;
1338 // End new options 28th jan 2013
1339
1340 fbpoptsobj.customtextfilter='';
1341 fbpoptsobj.userappwhitelist='';
1342 fbpoptsobj.fbpcustomcss='';
1343
1344 fbpoptsobj.stickerpacks='';
1345
1346 }
1347
1348 // APPLICATION WHITELIST
1349 // ---------------------
1350
1351 // If you would like to edit the list of applications in the user whitelist,
1352 // theres detailed instructions here: http://whitelist.fbpurity.com
1353
1354 var defaultappwhitelist = "6628568379,115463795461,48119224995,5895217474,56212371378,146139331013,2254487659,2915120374,74769995908,4620273157,14405921260,10754253724,2483740875,22950410511,43769862066,2550392059,8109791468,2238752371,21370137768,6195724695,6694405826,2231777543,53702860994,20407635301,38125372145,56137638329,10732101402,16297770890,2877035514,41158896424,72687635881,350685531728,30713015083,111527682205237,121958126090,2330519541,49340319393,26463759431,21810043296,24420472648,183319479511,189818072392,302006227267,90376669494,108160725869250,39010226174,247431880944,66746580154,96105046534,143907478979139,146563558702544,131289390231340,9953271133,45439413586,131732509879,23723376453,76456527540,105130332854716,27694818115,67878695711,124024574287414,79763977758,139682082719810,122580857763901,24553799497,159348674082705,112618498804176,148061315211358,104142802965358,149588628439275,7933375107,135892916448833,48505437520,198446803501767,193278124048833,165907476854626,213546525407071,531615603522381,149859461799466,178645865537776,220353874751486";
1355
1356 // the application ids in the default app whitelist above belong to, in order:
1357 // 6628568379 = facebook iphone application
1358 // 115463795461 = selective twitter
1359 // 48119224995 = tumblr
1360 // 5895217474 = digsby
1361 // 56212371378 = tweetdeck
1362 // 146139331013 = tweetdeck for iphone
1363 // 2254487659 = facebook for blackberry
1364 // 2915120374 = facebook mobile widget
1365 // 74769995908 = facebook for android
1366 // 4620273157 = facebook for palm
1367 // 14405921260 = facebook for motorola (motoblur)
1368 // 10754253724 = iphoto uploader
1369 // 2483740875 = picasa uploader
1370 // 22950410511 = sprint/samsung? photo/video uploader
1371 // 43769862066 = SonyEricsson
1372 // 2550392059 = MusicPlayer
1373 // 8109791468 = Status Shuffle
1374 // 2238752371 = Facebook Exporter for iPhoto
1375 // 21370137768 = official flickr application
1376 // 6195724695 = Windows Phone
1377 // 6694405826 = Posterous
1378 // 2231777543 = Twitter
1379 // 53702860994 = LG Mobile
1380 // 20407635301 = Snaptu
1381 // 38125372145 = SonyEricsson Panel
1382 // 56137638329 = Nokia
1383 // 10732101402 = ping.fm
1384 // 16297770890 = 3Skypephone 'S2'
1385 // 2877035514 = Gwibber
1386 // 41158896424 = HTC Sense
1387 // 24420472648 = HTC Sense
1388 // 72687635881 = Samsung Mobile
1389 // 350685531728 = facebook for android
1390 // 30713015083 = windows live messenger
1391 // 111527682205237 = O2 social link
1392 // 121958126090 = LG Phone
1393 // 2330519541 = Bloom photo uploader
1394 // 49340319393 = Ovi by Nokia
1395 // 26463759431 = My INQ Mobile
1396 // 21810043296 = Facebook for the T-Mobile Sidekick
1397 // 183319479511 = HootSuite
1398 // 189818072392 = live journal
1399 // 302006227267 = Sony Ericsson X10 mini pro
1400 // 90376669494 = Yahoo
1401 // 108160725869250 = Sony Ericsson
1402 // 39010226174 = Vlingo
1403 // 247431880944 = Droid
1404 // 66746580154 = Dell Mobile
1405 // 96105046534 = RockMelt
1406 // 143907478979139 = RockMelt Beta
1407 // 146563558702544 = Friendly for Ipad
1408 // 131289390231340 = Slide
1409 // 9953271133 = networked blogs
1410 // 45439413586 = RSS Grafitti
1411 // 131732509879 = Twitter Feed
1412 // 23723376453 = Seesmic
1413 // 76456527540 = Facebook mobile by Opentech ENG
1414 // 105130332854716 = flipboard
1415 // 27694818115 = Ovi by Nokia
1416 // 67878695711 = Nokia N900
1417 // 124024574287414 = Instagram
1418 // 79763977758 = Kodak Easy Share
1419 // 139682082719810 = Snaptu for Facebook
1420 // 122580857763901 = eBuddy
1421 // 24553799497 = mobileblog
1422 // 159348674082705 = Photoloader
1423 // 112618498804176 = FriendCaster for Android
1424 // 148061315211358 = Friendcaster Pro for android
1425 // 104142802965358 = My INQ Mobile
1426 // 149588628439275 = Twidroyd for Twitter
1427 // 7933375107 = Windows Phone
1428 // 135892916448833 = Facebook for Windows Phone
1429 // 48505437520 = Sony Ericsson Web Albums
1430 // 198446803501767 = HTC ChaCha
1431 // 193278124048833 = HTC Sense
1432 // 165907476854626 = Facebook Pages Manager
1433 // 213546525407071 = iOS
1434 // 531615603522381 = Facebook Site Governance voting app
1435 // 149859461799466 = Sony Xperia Smartphone
1436 // 178645865537776 = Blackberry
1437 // 220353874751486 = Facebook for Blackberry 10
1438 // --193048140809145-- = Facebook Likes (built in facebook app? this is a weird one, ive actually removed it for now, will investigate further. just leaving this here as a reminder)
1439
1440 // EXTRA STORIES ( see http://extras.fbpurity.com for more info )
1441 // Read option settings and set extra story codes
1442
1443 ////////////////////////
1444 /// BEGIN opts
1445 ////////////////////////
1446
1447 var arrwhitelist2={}; // this is the main application whitelist array
1448 var extraTextFilter;
1449 var headerTextFilter;
1450 var cleancustomtextfilter='';
1451 var headertextfilterRX;
1452 var textfilterRX;
1453 var filterapptext;
1454 var fbpboxstyles;
1455 var fbpfanpageid="408502197558";
1456 var fbpdevpageid="464154953615751";
1457
1458 function getuserid(){
1459 var userid='';
1460 var currentuser=document.getElementsByClassName('headerTinymanPhoto');
1461 if(currentuser.length && currentuser[0].src && currentuser[0].src.match(/_/))
1462 userid=currentuser[0].src.split('_')[1];
1463 else
1464 try {
1465 userid=document.cookie.match(/c_user=(\d+)/)[1];
1466 }
1467 catch(e) {
1468 console.log('problem getting logged in user id: ' + e);
1469 }
1470 return userid;
1471 }
1472
1473 var currentuserid=getuserid();
1474
1475 if (!currentuserid.length)
1476 var useridwhitelistRX=new RegExp(fbpfanpageid);
1477 else
1478 var useridwhitelistRX=new RegExp(fbpfanpageid + "|" + fbpdevpageid + "|" + currentuserid);
1479
1480 refreshwhitelist = function () {
1481 var whitelist;
1482 if (fbpoptsobj.userappwhitelist && fbpoptsobj.userappwhitelist.length)
1483 whitelist = defaultappwhitelist + "," + fbpoptsobj.userappwhitelist;
1484 else
1485 whitelist = defaultappwhitelist;
1486
1487 whitelist = whitelist.replace(/,,/g,''); // remove blanks (if any)
1488 whitelist = whitelist.replace(/ /g,''); // remove spaces (if any)
1489 whitelist = whitelist.replace(/,$/,''); // remove trailing comma (if any)
1490
1491 var arrwhitelist=whitelist.split(',');
1492
1493 for (i in arrwhitelist)
1494 arrwhitelist2[arrwhitelist[i]]=true; // create hashmap
1495 }
1496
1497 fbptimelinerestyle=function (tloff) {
1498 var tlstyle='';
1499 if (tloff) {
1500 //fix group cover image links
1501 tlstyle += ' .groupsCoverPhoto img.coverPhotoImg, .groupsCoverPhoto a.coverWrap {height:100px !important}'+
1502 // make the Timeline Cover Photo Shorter (not doing this any more as it interfers with changing cover photo)
1503 // ' .cover {height:100px !important} .coverWrap {height:150px !important} #pagelet_timeline_nav {margin-top:-10px} #fbTimelineHeadline .name h2, .fbEventHeadline {text-shadow: 1px 1px grey;} #fbTimelineHeadline .name h2 .fsm {text-shadow: 0px 0px;} #fbTimelineHeadline {top:8px} '+
1504
1505 // fix save and cancel and drag to reposition
1506 ' #coverEditSaveCancelArea .saveAndCancel {margin-top:40px} a.coverWrap .instructionWrap {top:120px !important}'+
1507 // hide the 'Coming Soon: Timeline' section at the top of Timeline pages
1508 ' #pagelet_above_header_timeline {display:none}'+
1509 // hide the "escape hatch" (friends / about / interests picture squares section)
1510 ' #pagelet_escape_hatch {display:none}'+
1511 // single column timeline
1512 ' .fbTimelineUnit { float:left !important; clear:left !important; width:540px; border-top:1px solid #ccc !important; border-bottom:1px solid #ccc !important;} .fbTimelineUnit .topBorder { display:none} .fbTimelineUnit .spinePointer { display:none } .fbTimelineUnit .bottomBorder { display:none } .timelineUnitContainer { width:auto !important} .timelineUnitContainer .uiCommentContainer { width:auto !important; } .fbTimelineCapsule { background:none !important; background-color:white !important; } .fbTimelineIndeterminateContent { float:right !important; width:280px !important; margin-right:10px; } .tlTxFe { font-size:inherit !important; line-height:inherit !important} #timelineNavContent .fbTimelineNavigation {width:849px}' +
1513 // fix left margin and cover image size for personal timeline versus fan page timeline
1514 ' .pagesTimelineLayout .fbTimelineUnit {margin-left:150px !important} '+
1515 //div[itemtype="http://data-vocabulary.org/Person"] #fbProfileCover .coverWrap { {height: 150px !important} div[itemtype="http://data-vocabulary.org/Person"] .coverWrap {height:150px !important}' +
1516 // event page with cover image
1517 ' div.fbEventLeftNav {position:relative;top:20px !important} div.fbEventHeaderBlock {position:relative;top:25px !important;left:0px !important }';
1518 }
1519 if (document.getElementById('fbptlstyle'))
1520 document.getElementById('fbptlstyle').textContent=tlstyle;
1521 }
1522
1523 fixsortorder = function() {
1524 if(debug)
1525 console.log('fix sort order function');
1526 if(fbpoptsobj.sortmostrecent) { // force feed to sort by most recent
1527
1528 var sortlink=document.getElementsByClassName('sortLink');
1529 if(sortlink.length) {
1530 if(!sortlink[0].textContent.match(/\:/)) {
1531 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>";
1532 window.location.href=window.location.protocol +'//www.facebook.com/?sk=h_chr';
1533 }
1534 }
1535 else { // deal with new newsfeed design
1536 sortlink=document.getElementsByClassName('_5eo3');
1537 if(sortlink.length) {
1538 if(!sortlink[0].textContent.match(/\:/)) {
1539 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>";
1540 window.location.href=window.location.protocol +'//www.facebook.com/feed/recent';
1541 }
1542 }
1543 }
1544 /*
1545 new newsfeed design, urls Old newsfeed
1546 https://www.facebook.com/?sk=nf (Top Stories) https://www.facebook.com/?sk=h_nor (Top Stories)
1547 https://www.facebook.com/feed/recent (Most Recent) https://www.facebook.com/?sk=h_chr (Most Recent)
1548 */
1549 // change newsfeed links to point to most recent feed
1550 // 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
1551
1552 if(document.getElementsByClassName('litestandNavItem').length) { // new newsfeed design
1553 document.getElementById('pageLogo').querySelector("a").setAttribute('href','/feed/recent');
1554 document.getElementById('navHome').querySelector("a").setAttribute('href','/feed/recent');
1555 if(document.querySelector("a[data-id='4748854339']")) {
1556 //console.log(document.querySelector("a[data-id='4748854339']").getAttribute('href'));
1557 document.querySelector("a[data-id='4748854339']").setAttribute('href','/feed/recent');
1558 //console.log(document.querySelector("a[data-id='4748854339']").getAttribute('href'));
1559 document.querySelector("a[data-id='4748854339']").setAttribute('data-gt','');
1560
1561 // try removing event listeners by cloning the node and replacing it
1562 var old_element = document.querySelector("a[data-id='4748854339']");
1563 var new_element = old_element.cloneNode(true);
1564 old_element.parentNode.replaceChild(new_element, old_element);
1565 }
1566 }
1567 else { // old newsfeed design
1568 document.getElementById('pageLogo').querySelector("a").setAttribute('href','/?sk=h_chr');
1569 document.getElementById('navHome').querySelector("a").setAttribute('href','/?sk=h_chr');
1570 if(document.getElementById('navItem_app_4748854339') && document.getElementById('navItem_app_4748854339').getElementsByTagName("a").length) {
1571 //console.log(document.getElementById('navItem_app_4748854339').getElementsByTagName("a").length);
1572 //console.log(document.getElementById('navItem_app_4748854339').querySelector("a[data-gt]").getAttribute('href'));
1573 document.getElementById('navItem_app_4748854339').querySelector("a[data-gt]").setAttribute('href','/?sk=h_chr');
1574 //console.log(document.getElementById('navItem_app_4748854339').querySelector("a[data-gt]").getAttribute('href'));
1575 document.getElementById('navItem_app_4748854339').querySelector("a[data-gt]").setAttribute('data-gt','');
1576 }
1577 }
1578 } // end if sortmostrecent is enabled
1579 else {
1580 if(debug)
1581 console.log('Sort most recent option is not enabled');
1582 }
1583 }
1584
1585 initstage2 = function () {
1586 if(debug)
1587 console.trace();
1588 //console.log('entering function : ' + arguments.callee.name);
1589
1590 /* moved this to separate function
1591 if(fbpoptsobj.sortmostrecent) { // force feed to sort by most recent
1592 var sortlink=document.getElementsByClassName('sortLink');
1593 if(sortlink.length) {
1594 if(!sortlink[0].textContent.match(/\:/))
1595 window.location.href=window.location.protocol +'//www.facebook.com/?sk=h_chr';
1596 }
1597 }
1598 */
1599
1600 extraTextFilter=''; // init extraTextFilter
1601 headerTextFilter=''; // init headerTextFilter
1602 if(fbpoptsobj.filterappmessages==1) {
1603 filterapptext=' fbpblocked';
1604 headerTextFilter += ', played .*,started playing,started using';
1605 extraTextFilter += ',games your friends are playing,Games You May Like';
1606 }
1607 else
1608 filterapptext=' fbpnormal';
1609
1610 if(fbpoptsobj.becamefriends==1)
1611 headerTextFilter += ',are now friends,is now friends with,now allows subscribers,subscribed to updates from,subscribed to .*\'s updates,subscribed to the list, followed .*\.'; // can probably get rid of subscribed to now (as they switched to follow)
1612
1613 if(fbpoptsobj.becamefan==1){
1614 headerTextFilter += ', recommends, likes .* and \\d* other pages,wrote a recommendation for, rated .*';
1615 extraTextFilter += ',like page,Like this Page,Find More Pages ·, Write a recommendation ';
1616 }
1617
1618 if(fbpoptsobj.joinedgroup==1) {
1619 headerTextFilter += ",.* was added to ,uploaded a .* in the group, was invited to, were invited to, invited .* to ,updated the description of the group,updated the group";
1620 extraTextFilter += ",· Join Group";
1621 }
1622
1623 if(fbpoptsobj.attendevent==1)
1624 headerTextFilter += ",is attending, is going to";
1625
1626 if(fbpoptsobj.attendedevent==1)
1627 headerTextFilter += ", attended the event, went to .*\.";
1628
1629 if(fbpoptsobj.createdevent==1)
1630 headerTextFilter += ",created an event,updated the event photo";
1631
1632 if((typeof fbpoptsobj.upcomingevents !=='undefined') && (fbpoptsobj.upcomingevents==1))
1633 extraTextFilter += ",Upcoming Events,Upcoming Concerts";
1634
1635 if((typeof fbpoptsobj.sharedevent !=='undefined') && (fbpoptsobj.sharedevent==1))
1636 headerTextFilter += ",shared an event, shared .*\\'s event, posted an event";
1637 //extraTextFilter += ",people are goingjoin" // may also filter out "created an event" stories
1638
1639 if (typeof fbpoptsobj.checkedin == "undefined")
1640 fbpoptsobj.checkedin = 0;
1641
1642 if(fbpoptsobj.checkedin==1)
1643 headerTextFilter += ", is with .*,was tagged at, is in .*\., was in .*\., is at .*\., was at .*\., were at .*\., are at .*\., was with ";
1644
1645 if((typeof fbpoptsobj.likedstatus !=='undefined') && (fbpoptsobj.likedstatus==1))
1646 headerTextFilter += ", likes .*\'s status, like .*\'s status, like a status, likes h.. own status,likes a status, likes a post";
1647
1648 if((typeof fbpoptsobj.commentedstatus !=='undefined') && (fbpoptsobj.commentedstatus==1))
1649 headerTextFilter += ",commented on .* status, commented on .* note, commented on .* activity";
1650
1651 if((typeof fbpoptsobj.taggedstatus !=='undefined') && fbpoptsobj.taggedstatus==1)
1652 headerTextFilter += ", tagged .* status\.";
1653
1654 if((typeof fbpoptsobj.sharedstatus !=='undefined') && (fbpoptsobj.sharedstatus==1))
1655 headerTextFilter += ", shared .*\'s status, shared a status, shared .*\'s post";
1656
1657 if((typeof fbpoptsobj.taggedphoto !=='undefined') && (fbpoptsobj.taggedphoto==1))
1658 headerTextFilter += ",tagged in h.. own photo,tagged in a photo,tagged in .*\'s photo,tagged in h.. own album, tagged in .*\'s album";
1659
1660 if((typeof fbpoptsobj.likedphoto !=='undefined') && (fbpoptsobj.likedphoto==1))
1661 headerTextFilter += ",likes .* photo\.,likes? a photo,likes .*\'s album";
1662
1663 if((typeof fbpoptsobj.commentedphoto !=='undefined') && (fbpoptsobj.commentedphoto==1))
1664 headerTextFilter += ",commented on .*\'s photo,commented on h.. own photo,commented on h.. own album,commented on a photo,commented on .*\'s album";
1665
1666 if((fbpoptsobj.commentedlink !== 'undefined') && (fbpoptsobj.commentedlink==1)) {
1667 headerTextFilter += ",commented on .*\'s link,commented on a link,commented on h.. own link,commented on .*\.com\.";
1668 }
1669 // maybe move "likes an article" to the trending articles filter...
1670 if((fbpoptsobj.likedlink !== 'undefined') && (fbpoptsobj.likedlink==1)) {
1671 headerTextFilter += ",likes an article,recommends a link,likes a link,like a link,likes .*\'s link,likes \\d+ links";
1672 }
1673
1674 if((fbpoptsobj.sharedpage !== 'undefined') && (fbpoptsobj.sharedpage==1)) {
1675 headerTextFilter += ",shared a Page";
1676 }
1677
1678 if(fbpoptsobj.commentwall==1)
1679 headerTextFilter += ",commented on .* post,wrote on .*\'s timeline,posted .* to .*\'s timeline"; //commented on h.. own post,commented on .*\'s post in,commented on a Post,
1680
1681 // updated profile
1682 if (typeof fbpoptsobj.updatedprofile == "undefined")
1683 fbpoptsobj.updatedprofile = 0;
1684
1685 if(fbpoptsobj.updatedprofile==1)
1686 headerTextFilter += ",added .* to h.. education\.,updated h.. education,added .* to h.. work\.,has worked on,updated h.. current .* to .*\\.,added .* as h.. hometown\\.,updated h.. work and education,added .* to h.. list of inspirational people\\.,to the inspirational people,added .* to h.. favourite sports\\.,added .* to h.. favourite teams\\.,added .* to h.. favourite athletes\\.,added .* to h.. activities\\.,added .* to h.. interests\\.,added .* to h.. profile\\.,to .* previous employers,added .* to h.. timeline,added a job at , now works at , took .* at .*,added details about,added a life event";
1687
1688 // changed profile pic
1689 if (typeof fbpoptsobj.changedprofilepic == "undefined")
1690 fbpoptsobj.changedprofilepic = 0;
1691
1692 if(fbpoptsobj.changedprofilepic==1)
1693 headerTextFilter += ",changed their profile picture,changed h.. profile picture,updated h.. cover photo\.,updated their cover photo";
1694
1695 // changed relationship
1696 if (typeof fbpoptsobj.changedrelationship == "undefined")
1697 fbpoptsobj.changedrelationship = 0;
1698
1699 if(fbpoptsobj.changedrelationship==1)
1700 headerTextFilter += ',went from being \".*\" to \".*\",went from being \".*\" to being \".*\",is in a relationship,complicated relationship,is single,is married,is engaged,is in a domestic partnership';
1701
1702 // uploaded photo
1703 if (typeof fbpoptsobj.uploadedphoto == "undefined")
1704 fbpoptsobj.uploadedphoto = 0;
1705
1706 if(fbpoptsobj.uploadedphoto==1){
1707 headerTextFilter += ",added a photo,posted a photo to,added a new photo,added \\d* new photos,added \\d* photos,took a photo with,took \\d* photos with";
1708 extraTextFilter +=', (\\d+ photos)';
1709 }
1710
1711 // shared photo
1712 if (typeof fbpoptsobj.sharedphoto == "undefined")
1713 fbpoptsobj.sharedphoto = 0;
1714
1715 if(fbpoptsobj.sharedphoto==1){
1716 headerTextFilter += ",shared a photo,shared .*\'s album";//shared .*\'s photo,
1717 extraTextFilter += ",by\:,shared .*?'s photo";
1718 }
1719
1720 // uploaded video
1721 if (typeof fbpoptsobj.uploadedvideo == "undefined")
1722 fbpoptsobj.uploadedvideo = 0;
1723
1724 if(fbpoptsobj.uploadedvideo==1){
1725 headerTextFilter += ",posted A video,added a video,uploaded.* video";
1726 //extraTextFilter +=",Length: ‎?\\d+:\\d\\d"; // this filter doesnt seem to work...
1727 }
1728
1729 // tagged in video
1730 if (typeof fbpoptsobj.taggedinvideo == "undefined")
1731 fbpoptsobj.taggedinvideo = 0;
1732
1733 if(fbpoptsobj.taggedinvideo==1)
1734 headerTextFilter += ",tagged in .*\'s video ";
1735
1736 /* new video options 28th jan
1737 sharedvideo
1738 likedvideo
1739 commentedvideo
1740 youtubevideo
1741 */
1742 if((typeof fbpoptsobj.sharedvideo!=='undefined') && (fbpoptsobj.sharedvideo==1))
1743 // we also add a check for classname "shareMediaVideo" to improve filter coverage
1744 headerTextFilter += ",shared a video,shared .*\'s video";
1745
1746 if((typeof fbpoptsobj.likedvideo!=='undefined') && (fbpoptsobj.likedvideo==1))
1747 headerTextFilter += ",liked a video,liked .*\'s video,likes .*\'s video";
1748
1749 if((typeof fbpoptsobj.commentedvideo!=='undefined') && (fbpoptsobj.commentedvideo==1))
1750 headerTextFilter += ",commented on a video,commented on .*'s video";
1751
1752 if((typeof fbpoptsobj.youtubevideo!=='undefined') && (fbpoptsobj.youtubevideo==1))
1753 extraTextFilter += ",youtube\.com,youtu\.be,vimeo\.com";
1754
1755 //if(fbpoptsobj.hideallvideos==1)
1756 // ; // we are dealing wtih this by running a check on the node for the "shareMediaVideo" class
1757
1758 //if(fbpoptsobj.hidealllinks==1)
1759 // Need to Add all links filter here?
1760
1761 // posted note
1762 if (typeof fbpoptsobj.postednote == "undefined")
1763 fbpoptsobj.postednote = 0;
1764
1765 if(fbpoptsobj.postednote==1)
1766 headerTextFilter += ",posted a note";
1767
1768 // tagged in note
1769 if (typeof fbpoptsobj.taggedinnote == "undefined")
1770 fbpoptsobj.taggedinnote = 0;
1771
1772 if(fbpoptsobj.taggedinnote==1)
1773 headerTextFilter += ",tagged in a note,tagged in a Post,tagged in .* life event";
1774
1775 // posted link
1776 if (typeof fbpoptsobj.postedlink == "undefined")
1777 fbpoptsobj.postedlink = 0;
1778
1779 if(fbpoptsobj.postedlink==1)
1780 headerTextFilter += ",shared link\\.,shared a link\\.";
1781
1782 // read an article
1783 if (typeof fbpoptsobj.readarticle == "undefined")
1784 fbpoptsobj.readarticle = 0;
1785
1786 if(fbpoptsobj.readarticle==1) {
1787 headerTextFilter += ",read an article, recently read articles\\., read \\d* articles\\.";
1788 extraTextFilter += ",Trending Articles,Trending Videos,Most Shared on ,Recent Articles About ";
1789 }
1790
1791 // facebook questions
1792 if(fbpoptsobj.questionsbox==1) {
1793 headerTextFilter += ", replied to: , asked: ,answered .*'s question,asked.*a question";
1794 extraTextFilter += ",· Ask friends ·";
1795 }
1796
1797 // hide sponsored stories in newsfeed
1798 if(fbpoptsobj.sponsoredbox==1) {
1799 extraTextFilter += ",Recently Released Albums,Get Offer ·"; //· Sponsored
1800 headerTextFilter += ", claimed an offer from, posted an offer";
1801 }
1802
1803 if (fbpoptsobj.trendingbox) {
1804 headerTextFilter += ', is trending\\.';
1805 }
1806
1807 // fix font size
1808 if(fbpoptsobj.fontfix==1) {
1809 /*if(document.getElementById('fbpfreestyler'))
1810 document.getElementById('fbpfreestyler').textContent='div.actorName{display:inline;margin-right:3px !important} a.subject,div.preview,.mall_post_body_text,div,span,p,textarea,input,td,label,h3,h4,h5,h6{font-size:' + fbpoptsobj.fontsize + 'px !important} ' + 'div.commentContent {font-size:' + (fbpoptsobj.fontsize-1) +'px !important}' + ' .ginormousProfileName { font-size: 20px !important} ' + ' .emote_text {display:none}' + ' div.tickerFeedMessage, div.linkWrap {line-height:' + fbpoptsobj.fontsize + 'px !important} ' + 'li.uiStreamHeader {margin-bottom:' + (fbpoptsobj.fontsize-6) + 'px !important}';
1811 */
1812 fbpfreestyle.textContent='div.actorName{display:inline;margin-right:3px !important} a.subject,div.preview,.mall_post_body_text,div,span,p,textarea,input,td,label,h3,h4,h5,h6{font-size:' + fbpoptsobj.fontsize + 'px !important} ' + 'div.commentContent {font-size:' + (fbpoptsobj.fontsize-1) +'px !important}' + ' .ginormousProfileName { font-size: 20px !important} ' + ' .emote_text {display:none}' + ' div.tickerFeedMessage, div.linkWrap {line-height:' + fbpoptsobj.fontsize + 'px !important} ' + 'li.uiStreamHeader {margin-bottom:' + (fbpoptsobj.fontsize-6) + 'px !important}';
1813 }
1814
1815 // fix font colour
1816 if(fbpoptsobj.fontcolourfix==1) {
1817 /*if(document.getElementById('fbpfreestyler'))
1818 document.getElementById('fbpfreestyler').textContent +=' * {color:' + fbpoptsobj.fontcolour + ' !important}'; //span.fwb {color:' + fbpoptsobj.fontcolour + ' !important}';
1819 */
1820 fbpfreestyle.textContent+=' * {color:' + fbpoptsobj.fontcolour + ' !important}'; //span.fwb {color:' + fbpoptsobj.fontcolour + ' !important}';
1821 }
1822
1823 // fix font background colour
1824 if(fbpoptsobj.fontbgcolourfix==1) {
1825 //if(document.getElementById('fbpfreestyler'))
1826 // document.getElementById('fbpfreestyler')
1827 fbpfreestyle.textContent +=' * {background-color:' + fbpoptsobj.fontbgcolour + ' !important} .uiListLight { border-color: #333; } textarea, .inputtext, .inputpassword { border: 1px solid #555} .uiUfi .ufiItem { border-bottom: 1px dotted darkgray} n.tagsWrapper *, #fbPhotoTheaterTags, .tagsWrapper, .fbPhotosPhotoTagboxes *, #fbPhotoTheaterStageActions, .fbQuestionsPollClickTarget, .fbPhotosPhotoTagboxes, .flashUploaderOverlayButton, .fluploader_swfdiv, .coverBorder, .frame, .mat, .graph-canvas, .overlay, span.label, div.label, span.fwb ,#snowliftStageActions, .fbPhotoTagger, .faceBox, .typeaheadWrapper, .groupsJumpCoverBorder, .-cx-PRIVATE-uiFileInput__wrap, #fullScreenSwitch, #fbProfileCoverPhotoSelector, #fbProfileCoverPhotoSelector .wrap, #fbProfilePicSelector, #fbProfilePicSelector .wrap, .snowliftPager, .snowliftPager i, a.fbPhotoViewLarger, div._7m4 {background-color:transparent !important} .fbQuestionsPollResultsBar .shaded, .bar {background-color: #6C83B2 !important} .tagName, ol.balancingCapsule, div.fbTimelineFilters, ol.fbTimelineCapsule {background-color: ' + fbpoptsobj.fontbgcolour + ' !important} .hasSmurfbar #blueBarHolder #blueBar {background-image:url("") !important} /* like button: */ div._55k4, /*camera icon under composer*/ div._3jk , /* profile pic*/ i._96h, /* group count in left column*/ div.-cx-PRIVATE-blendedBookmarksNonLitestand__bookmark, div._5duc {background-color:transparent !important} /* attach image to comment icon*/ i.UFICommentPhotoIcon {background-color:grey !important}';
1828 }
1829
1830 // fix font
1831 if(fbpoptsobj.fbpfontfix==1) {
1832 //if(document.getElementById('fbpfreestyler'))
1833 // document.getElementById('fbpfreestyler')
1834 fbpfreestyle.textContent +=' * {font-family:' + fbpoptsobj.fbpfont + ' !important} ';
1835 }
1836
1837
1838 if(fbpoptsobj.likepagebutton==1) {
1839 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} ';
1840 }
1841 // single column timeline
1842 /*
1843 if(fbpoptsobj.timelineonecol==1)
1844 fbptimelinerestyle(1);
1845 else
1846 fbptimelinerestyle(0);
1847 */
1848
1849 lcoptsarr="lcadvertmgr,lcconnect,lcallpages,lcpagesfeed,lclikepages,lcallapps,lcappcenter,lcevents,lcgamesfeed,lcpokes,lcmusic,lcplaceseditor,lcallgroups,lcallinterests,lccreategroup,lccreatepage,lcfindfriends,lcdeveloper,lcfriends,lcgifts,rcrecommendedpages,rcrelatedgroups,rcpokes,rcbirthdays,rcfriendrequests,rcgamerequests".split(',');
1850 for(b=0;b<lcoptsarr.length;b++)
1851 if (typeof fbpoptsobj[lcoptsarr[b]] == "undefined")
1852 fbpoptsobj[lcoptsarr[b]]=0;
1853
1854 //var fbpfreestyler=document.getElementById('fbpfreestyler');
1855 //if (fbpfreestyler) {
1856
1857
1858
1859 // start left column options
1860 if(fbpoptsobj.lcconnect==1)
1861 fbpfreestyle.textContent +=' #connectNav {display:none}';
1862
1863 if(fbpoptsobj.lcallpages==1)
1864 fbpfreestyle.textContent +=' #pagesNav {display:none}';
1865
1866 if(fbpoptsobj.lcallapps==1)
1867 fbpfreestyle.textContent +=' #appsNav {display:none}';
1868
1869 if(fbpoptsobj.lcallgroups==1)
1870 fbpfreestyle.textContent +=' #groupsNav {display:none}';
1871
1872 if(fbpoptsobj.lcallinterests==1)
1873 fbpfreestyle.textContent +=' #interestsNav { display:none }';
1874
1875 if(fbpoptsobj.lcfriends==1)
1876 fbpfreestyle.textContent +=' #listsNav { display:none}';
1877
1878 // items beginning with #navItem_app_ are for the old newsfeed, and those with #sidebar_navigation_top are the new newsfeed
1879 if(fbpoptsobj.lcadvertmgr==1)
1880 fbpfreestyle.textContent +=' #adsNav, #navItem_app_6802152230, #navItem_app_400915586638539, #sidebar_navigation_top a[data-id="6802152230"], #sidebar_navigation_top a[data-id="400915586638539"] {display:none}';
1881
1882 if(fbpoptsobj.lcpagesfeed==1)
1883 fbpfreestyle.textContent +=' #navItem_app_140472815972081, #sidebar_navigation_top a[data-id="140472815972081"] {display:none}';
1884
1885 if(fbpoptsobj.lclikepages==1)
1886 fbpfreestyle.textContent +=' #navItem_app_357937250942127, #navFindFriends, #sidebar_navigation_top a[data-id="357937250942127"] {display:none}';
1887
1888 if(fbpoptsobj.lcappcenter==1)
1889 fbpfreestyle.textContent +=' #navItem_app_140332009231, #sidebar_navigation_top a[data-id="140332009231"] {display:none}';
1890
1891 if(fbpoptsobj.lcevents==1)
1892 fbpfreestyle.textContent +=' #navItem_app_2344061033, #sidebar_navigation_top a[data-id="2344061033"] {display:none}';
1893
1894 if(fbpoptsobj.lcgamesfeed==1)
1895 fbpfreestyle.textContent +=' #navItem_app_261369767293002, #sidebar_navigation_top a[data-id="261369767293002"] {display:none}';
1896
1897 if(fbpoptsobj.lcpokes==1)
1898 fbpfreestyle.textContent +=' #navItem_app_183217215062060, #sidebar_navigation_top a[data-id="183217215062060"] {display:none}';
1899
1900 if(fbpoptsobj.lcmusic==1)
1901 fbpfreestyle.textContent +=' #navItem_app_119960514742544, #sidebar_navigation_top a[data-id="119960514742544"] {display:none}';
1902
1903 if(fbpoptsobj.lcplaceseditor==1)
1904 fbpfreestyle.textContent +=' #navItem_app_219124168114356, #sidebar_navigation_top a[data-id="219124168114356"] {display:none}';
1905
1906 if(fbpoptsobj.lccreategroup==1)
1907 fbpfreestyle.textContent +=' #navItem_app_230259100322928, #sidebar_navigation_top a[data-id="230259100322928"] {display:none}';
1908
1909 if(fbpoptsobj.lccreatepage==1)
1910 fbpfreestyle.textContent +=' #navItem_app_188619144602540, #sidebar_navigation_top a[data-id="188619144602540"] {display:none}';
1911
1912 if(fbpoptsobj.lcfindfriends==1)
1913 fbpfreestyle.textContent +=' #navItem_app_2356318349, #sidebar_navigation_top a[data-id="2356318349"], #findFriendsNav {display:none !important}';
1914
1915 if(fbpoptsobj.lcdeveloper==1)
1916 fbpfreestyle.textContent +=' #developerNav, #navItem_app_2345053339, #sidebar_navigation_top a[data-id="2345053339"] {display:none}';
1917
1918 if(fbpoptsobj.lcgifts==1)
1919 fbpfreestyle.textContent +=' #navItem_app_329122197162272, a[data-endpoint="/ajax/composerx/attachment/gift/"], a[ajaxify^="/ajax/gifts/send?recipient_id="], div.fbRemindersContent div.uiBoxLightblue, #sidebar_navigation_top a[data-id="329122197162272"], a[href^="/gifts?recipient_id="], div.timelineReportContainer[data-gt*=\'"timeline_unit_type":"BirthdayGiftUnit"\'],a.uiButton[href^="/gifts?recipient_id="] {display:none}';
1920
1921 if(fbpoptsobj.rcrecommendedpages==1)
1922 fbpfreestyle.textContent +=' #pages_reminders_link {display:none}';
1923
1924 if(fbpoptsobj.rcbirthdays==1)
1925 fbpfreestyle.textContent +=' #birthday_reminders_link {display:none}';
1926
1927 if(fbpoptsobj.rcgamerequests==1)
1928 fbpfreestyle.textContent +=' #custom_reminders_link {display:none}';
1929
1930 if(fbpoptsobj.rcfriendrequests==1)
1931 fbpfreestyle.textContent +=' #friends_reminders_link {display:none}';
1932
1933 if(fbpoptsobj.rcpokes==1)
1934 fbpfreestyle.textContent +=' #poke_reminders_link, #pagelet_pokes {display:none}';
1935
1936 if(fbpoptsobj.rcrelatedgroups==1)
1937 fbpfreestyle.textContent +=' #pagelet_ego_contextual_group {display:none !important}';
1938
1939 // hide useless bottom right footer + ads on login + logout screen + useless links in top nav bar
1940 fbpfreestyle.textContent += 'div.fbIndexFeaturedRegistration > div.lfloat, .-cx-PRIVATE-fbAdUnit__root, #pagelet_rhc_footer, #SetAsHomepage_Callout, .gradientContent > div[data-ad^="{"], #findFriendsNav, #navFindFriends {display:none !important}';
1941
1942 // hide contact importer at bottom of feed
1943 fbpfreestyle.textContent += ' .contact_importer_widget {display:none} #ci_compact_right {display:none}';
1944
1945 // add red border to publish permissions request and make light grey blurb black and bold
1946 fbpfreestyle.textContent += ' .permissionsPublishActionsBadge {border:4px solid red} .gdpBlurb {color:black !important ; font-weight:bold !important} .tosPane > .sectionContent, .fcb > div, .tosPane .legalese, .tosPane .sectionHeader {color:black !important} .tosPane .mbm {color:black; border: 4px red solid}';
1947
1948 // add open and close list styles
1949 fbpfreestyle.textContent += ' span.fbpopenlist:before {content:"▼ "} span.fbpclosedlist:before {content:"► "}';
1950
1951
1952 ////////////////////////
1953 /// END opts
1954 ////////////////////////
1955
1956 refreshwhitelist();
1957
1958 //unsafeWindow.console.log("etf= " + extraTextFilter);
1959
1960 var tmptextfilter='';
1961 tmptextfilter=fbpoptsobj.customtextfilter;
1962 if (tmptextfilter)
1963 tmptextfilter += ',' + extraTextFilter; // add emergency extra text filter
1964 else
1965 tmptextfilter = extraTextFilter;
1966
1967 if( tmptextfilter.length ) {
1968 tmptextfilter=tmptextfilter.replace(/,,/g,','); // remove blanks (if any)
1969 tmptextfilter=tmptextfilter.replace(/,+$|^,+/g,''); // remove trailing or leading commas
1970 cleancustomtextfilter=fbpescaperegex(tmptextfilter); // escape regex special chars (brackets)
1971
1972 try {
1973 textfilterRX = new RegExp(cleancustomtextfilter.replace(/,/g,'|'),"gi");
1974 }
1975 catch (e) {
1976 window.alert('F.B. Purity: Error building Custom Text Filter RegEx: ' + fbpoptsobj.customtextfilter + "\n\nHave you pasted CSS code into the Custom Text filter by mistake? If yes, go to the FBP options sceen, remove it and put it into the Custom CSS Box.")
1977 //textfilterRX=null;
1978 textfilterRX=new RegExp("fbpurity1234567890xyz"); // set a dummy regex, so firefox browser doesnt freeze, and user can go and reset the fbp options
1979 }
1980 }
1981
1982 //unsafeWindow.console.log('htf=' + headerTextFilter);
1983
1984 headerTextFilter=headerTextFilter.replace(/^,/,''); // remove leading comma (if any)
1985
1986 if( headerTextFilter && headerTextFilter.length ) {
1987 try {
1988 headertextfilterRX = new RegExp(headerTextFilter.replace(/,/g,'|'),"gi");
1989 }
1990 catch (e) {
1991 window.alert('F.B. Purity: regex error building header text filter : ' + headerTextFilter);
1992 headertextfilterRX=null;
1993 }
1994 }
1995
1996 //unsafeWindow.console.log(fbpoptsobj.customtextfilter);
1997
1998 fbpboxstyles='';
1999
2000 // hide suggestions box if option has been set
2001 if (fbpoptsobj.suggestionsbox) {
2002 fbpboxstyles +=' #ego_pane {display:none} #netego_organic {display:none} #pagelet_tips_box {display:none}';
2003 }
2004 // hide Get Connected (was: connect with friends) box if option has been set
2005 if (fbpoptsobj.connectbox) {
2006 fbpboxstyles +=' #pagelet_netego_lower {display:none} #pagelet_connectbox {display:none}';
2007 }
2008
2009 if (fbpoptsobj.betabox) {
2010 fbpboxstyles +=' #pagelet_betabox {display:none}';
2011 }
2012
2013 if (fbpoptsobj.pokebox) {
2014 fbpboxstyles +=' #pagelet_netego_pokes, #pagelet_pokes, #navItem_app_183217215062060 {display:none}';
2015 }
2016
2017 if (fbpoptsobj.happeningnowbar) {
2018 fbpboxstyles +=' .ticker_stream, #pagelet_ticker, #pagelet_rhc_ticker {display:none}';
2019 }
2020
2021 if (fbpoptsobj.questionsbox) {
2022 fbpboxstyles +=' #pagelet_netego_questions, #pagelet_questionsbox {display:none}';
2023 }
2024
2025 if (fbpoptsobj.eventsbox) {
2026 fbpboxstyles +=' #event_reminders_link {display:none}'; // hide left column events too #navItem_app_2344061033 {display:none} just hide create event link #pagelet_reminders [ajaxify="/ajax/plans/create/dialog.php"] * { display: none !important;}
2027 }
2028
2029 if (fbpoptsobj.requestsbox) {
2030 fbpboxstyles +=' #pagelet_netego_requests {display:none}';
2031 }
2032
2033 if (fbpoptsobj.sponsoredbox) {
2034 fbpboxstyles +=' div._5j5u,div[data-adblock-hash],div.megaphone_location_pages_feed, #pagelet_canvas_storybox, #pagelet_canvas_nav_content, .applifier, #side_ad_frame, .-cx-PRIVATE-suggestionOnLiking__body, .canvasRecommended, li.ownsection, li[aria-label="Sponsored"], #pagelet_adbox, #pagelet_search_ads2, #adcolumn_advertise, #ssponsor, #adcolumn_more_ads, #pagelet_friendship_netego_ads, #pagelet_ego_pane, .fbPhotosSideColumn, #pagelete_ego_pane_home_ads, #pagelet_ad_page_upsell, #fbPhotoSnowboxAdsBottom, .fbPhotoSnowboxAdsSponsored, .fbTimelineSideAds, #pagelet_ego_pane_m, #pagelet_organic_ego_pane, #pagelet_ego_pane_w, #pagelet_ads_when_no_friend_list_suggestion, #pagelet_side_ads, #fbPhotoSnowliftAdsSide, #MessagingNetegoSidebar, .-cx-PRIVATE-fbTimelineStyleAds__vertical, .-cx-PRIVATE-fbTimelineStyleAds__root, .-cx-PRIVATE-snowliftAds__root, ._24q, .rhcFooter, div[data-ad^="{"],.-cx-PRIVATE-suggestionOnSourceLiking__body, #endOfFeedPymlContainer {display:none !important} #sidebar_ads, #pagelet_ads, #pagelet_netego_ads, .UIStandardFrame_SidebarAds, #gb_muffin_area, .adsContainer, .fbPhotoAdsCol {visibility:hidden !important} ';
2035 }
2036 //div._5j5u = current code for hiding "similar to" box.
2037
2038 if (fbpoptsobj.filterappmessages) { // hide app and game messages from the ticker
2039 fbpboxstyles +=' div.fbFeedTickerStory[data-gt*=\'"appid":\'] {display:none} ';
2040 }
2041
2042 if (fbpoptsobj.chatbox) {
2043 fbpboxstyles +=' #pagelet_presence, #pagelet_friends_online, #pagelet_chat, #BuddylistPagelet, div.fbChatSidebarBody {display:none}';
2044 }
2045
2046 if (fbpoptsobj.trendingbox) {
2047 fbpboxstyles +=' #pagelet_trending_tags_and_topics, #under_composer_trending {display:none}';
2048 }
2049
2050 if ((typeof fbpoptsobj.smileys !=='undefined') && fbpoptsobj.smileys) {
2051 fbpboxstyles +=' img.wallArrowIcon, .emoticon_text {display:inline !important} .emoticon {display:none !important} i.-cx-PRIVATE-fbEntstreamEmoji__image, i.-cx-PRIVATE-ogAttachedSentenceToken__icon, span.-cx-PRIVATE-fbEmoji__icon, h5.uiStreamMessage img, span.userContent i.img, .userContentSecondary i.img, span.hasCaption i.img, div.shareSubtext i.img, div.uiStreamAttachments i.img, div.UFICommentContent span._1a-, div.userContentWrapper i.img, h5.uiStreamMessage i.img, span.userContentSecondary img[height="16"] {display:none} ';
2052 }
2053
2054 if ((typeof fbpoptsobj.notificationpopup !=='undefined') && fbpoptsobj.notificationpopup) {
2055 fbpboxstyles +=" ul[data-gt^='{\"ref\":\"beeper\"'] {display:none}";
2056 }
2057
2058 if ((typeof fbpoptsobj.fixedleftcolumn !=='undefined') && fbpoptsobj.fixedleftcolumn) {
2059 fbpboxstyles +=' .home #leftCol {position:fixed !important}';
2060 }
2061
2062 if(fbpoptsobj.offlinefriends) {
2063 // hide offline friends in chat
2064 fbpboxstyles +=" .fbChatOrderedList li {display: none;} .fbChatOrderedList .active {display: block;}";
2065 }
2066
2067 //if(document.getElementById('fbpboxstyler'))
2068 // document.getElementById('fbpboxstyler').textContent = fbpboxstyles;
2069 fbpboxstyle.textContent = fbpboxstyles;
2070
2071 // set custom css (if user has specified any styles)
2072 if (fbpoptsobj.fbpcustomcss) {
2073 //if(document.getElementById('fbpcssstyler'))
2074 // document.getElementById('fbpcssstyler').textContent = fbpoptsobj.fbpcustomcss;
2075 fbpcssstyle.textContent = fbpoptsobj.fbpcustomcss;
2076 }
2077
2078 if(debug)
2079 console.log('are we here at the end of initstage 2?');
2080
2081 } //END FUNCTION INITSTAGE2
2082
2083 fbpdynamicreload = function (opts) {
2084 fbpgetprefs(opts);
2085 if(document.getElementById('fbpoptsdiv') && document.getElementById('fbpoptsdiv').style.display=='block') {
2086 document.getElementById('fbpoptsdiv').style.display='none';
2087 fbptoggleopts();
2088 }
2089 resetclasses();
2090 initstage2();
2091 //tlbuttinit(); // reset TL button state
2092 if(fbpoptsobj.timelineonecol==false)
2093 window.setTimeout(function(){document.getElementById('FBTLX').style.display='none';},1500);
2094 else
2095 window.setTimeout(function(){document.getElementById('FBTLX').style.display='block';},1500);
2096
2097 cleartheshizzle(document);
2098 }
2099
2100 /*
2101 if(!isasync)
2102 initstage2(); // run it once to finish initialisation
2103 have moved this call into fbpgetprefs...
2104
2105 */
2106 // function to add delete friend request buttons
2107 /*function adddelreqbuttons(node) {
2108 // for adding delete request button to main friend request indicator panel and also the list at https://www.facebook.com/friends/requests/
2109 commented out for now as was causing errors in line 1991
2110 actiondivs=node.getElementsByClassName('actions');
2111 if(!actiondivs.length || !node.getElementsByClassName('uiButtonConfirm').length || node.getElementsByClassName('privacyPlan').length || document.getElementById('questions_stories'))
2112 return;
2113 for(var i=0;i<actiondivs.length;i++) {
2114 //unsafeWindow.console.log(actiondivs[i].childNodes[0].getAttribute('class'));
2115 if((actiondivs[i].childNodes.length && actiondivs[i].childNodes[0].getAttribute && actiondivs[i].childNodes[0].getAttribute('class').match(/Timeline|actionsDropdown/gi)) || (actiondivs[i].childNodes[1] && actiondivs[i].childNodes[1].getAttribute('id') && actiondivs[i].childNodes[1].getAttribute('id').match(/pagelet_timeline_profile_actions/)) || (actiondivs[i].getElementsByTagName('input').length==0) || actiondivs[i].parentNode.getAttribute('class').match(/stickyHeaderWrap/)) {
2116 //unsafeWindow.console.log('timeline page');
2117 continue;
2118 }
2119 foundreject=0;
2120 binps=actiondivs[i].getElementsByTagName('input');
2121 for(j=0;j<binps.length;j++)
2122 if(binps[j].getAttribute && binps[j].getAttribute('name') && binps[j].getAttribute('name').match(/actions\[reject\]|Admin Panel/)) {
2123 foundreject=1;
2124 break;
2125 }
2126 if(!foundreject) {
2127 delreqbutt=document.createElement('label');
2128 delreqbutt.className='uiButton uiButtonDefault uiButtonMedium';
2129 delreqbutt.innerHTML='<input type="submit" title="Delete this request. (The sender wont know.)" name="actions[reject]" value="Delete">';
2130 actiondivs[i].appendChild(delreqbutt);
2131 }
2132 }
2133
2134 }*/
2135
2136 function fpInsertedNodeDomHandler(event) {
2137 //console.dir(event.target);
2138 if((event.target.nodeName=='LI') || (event.target.nodeName=='UL')) {
2139 //if ((document.getElementById('pagelet_home_stream')||(document.getElementById('profile_minifeed'))) && (!document.getElementById('fb_multi_friend_selector'))) {
2140 if ((document.getElementById('pagelet_home_stream') ) && (!document.getElementById('fb_multi_friend_selector'))) {
2141 //console.log(event.target.nodeName);
2142 cleartheshizzle(event.target);
2143 //unmanglelinks(event.target);
2144 }
2145 else {
2146 ; // not doing anything at the mo
2147 }
2148 if(fbpoptsobj.fixarticleredirects && event.target.getElementsByTagName('a').length)
2149 unmanglelinks(event.target);
2150 }
2151 else if(event.target.nodeName=='DIV') {
2152 //var functRef = callLater(adddelreqbuttons,event.target);
2153 //setTimeout(functRef, 1500);
2154 if (document.getElementById('pagelet_litestand_section') || document.getElementById('stream_pagelet')) {
2155 //console.log(event.target.nodeName);
2156 cleartheshizzle(event.target);
2157 //unmanglelinks(event.target);
2158 }
2159 if((event.target.getAttribute('id')=='platform_dialog_content') || (event.target.getElementsByClassName('tosPane').length) || (event.target.getAttribute('class') && event.target.getAttribute('class').match(/tosPane/))) {
2160 //its most likely a facebook application requesting permissions
2161 highlightemailrequest();
2162 //appid=document.getElementById('input_app_id').getAttribute('value');
2163 addblockbuttontopermreq();
2164 }
2165 if(event.target.getAttribute('class') && event.target.getAttribute('class').match('middle_area_content')){
2166 if(window.location.href.match(/\/appcenter\/?/))
2167 highlightemailrequest();
2168 }
2169 if(fbpoptsobj.fixarticleredirects && event.target.getElementsByTagName('a').length)
2170 unmanglelinks(event.target);
2171 //fixie7spoof();
2172 //setTimeout(function(){adddelreqbuttons(event.target)},1000); // add delete friend request buttons if required
2173 }
2174 else if((event.target.nodeName=='SPAN') && (event.target.getAttribute && event.target.getAttribute('class') && event.target.getAttribute('class').match(/hasCaption/))) {
2175 //console.log('hit a spanner');
2176 unmanglelinks(event.target);
2177 }
2178 } // END fpInsertedNodeDomHandler function
2179
2180 function updateblockedcount() {
2181 crappyappmsgcounter=document.getElementsByClassName('fbpblocked').length;
2182 var fbpblockcountspan=document.getElementById('fbpblockcount');
2183 if(fbpblockcountspan)
2184 fbpblockcountspan.innerHTML=crappyappmsgcounter;
2185
2186 xtramsgcounter=document.getElementsByClassName('fbpblockedx').length;
2187 var fbpblockxcountspan=document.getElementById('fbpblockxcount');
2188 if(fbpblockxcountspan)
2189 fbpblockxcountspan.innerHTML=xtramsgcounter;
2190 }
2191
2192 function destroyblockedappstories (appid,killmode) {
2193
2194 var appnodes=document.getElementsByClassName('aid_' + appid);
2195 var appnodeslength=appnodes.length;
2196 for (var i=0;i<appnodeslength;i++){
2197 //appnodes=document.getElementsByClassName('aid_' + appid);
2198 if(killmode=='kill')
2199 appnodes[0].parentNode.removeChild(appnodes[0]);
2200 else if(killmode=='allow')
2201 appnodes[i].className = appnodes[i].className.replace(/\bfbpblocked\b/,'fbpnormal');
2202
2203 if(fpbblockcountspan)
2204 fpbblockcountspan.innerHTML=--crappyappmsgcounter;
2205 }
2206 updateblockedcount();
2207 //check if there are any blocked msgs left and if not, return to normal homepage view
2208 blockedmsgs=document.getElementsByClassName('fbpblocked');
2209 if(!blockedmsgs.length)
2210 fbpshowblocked();
2211 appnodes=null;
2212
2213 }// END destroyblockedappstories function
2214
2215 function getdtsg() {
2216 var fb_dtsg='';
2217 if(document.getElementsByClassName('autoexpand_mode').length) {
2218 if(document.getElementsByClassName('autoexpand_mode')[0].wrappedJSObject)
2219 fb_dtsg = document.getElementsByClassName('autoexpand_mode')[0].wrappedJSObject.fb_dtsg.value;
2220 else
2221 fb_dtsg = document.getElementsByClassName('autoexpand_mode')[0].fb_dtsg.value;
2222 }
2223 else {
2224 navinps=document.getElementsByTagName('input');
2225 for(var i=0;i<navinps.length;i++)
2226 if(navinps[i].getAttribute('name')=='fb_dtsg') {
2227 fb_dtsg=navinps[i].getAttribute('value');
2228 break;
2229 }
2230 }
2231 return fb_dtsg;
2232 }
2233
2234 function allowapp(appid, appname) {
2235
2236 if (confirm("Do you want to whitelist application : '" + appname +"'" + ".\n\nApplication ID: " + appid)) {
2237 if(fbpoptsobj.userappwhitelist.length) {
2238 // theres already value/s in userwhitelist
2239 try {
2240 fbpoptsobj.userappwhitelist+=','+appid;
2241 fbpsavevalue('fbpoptsjson-' + currentuserid, JSON.stringify(fbpoptsobj));
2242 //document.getElementById("MyElement").className = document.getElementById("MyElement").className.replace(/\bMyClass\b/','')
2243 window.alert(appname + ' has been Saved to your whitelist');
2244 refreshwhitelist();
2245 destroyblockedappstories(appid,'allow');
2246 }
2247 catch(e) {
2248 window.alert('error saving id to whitelist');
2249 }
2250
2251 }
2252 else {
2253 // userwhitelist is blank
2254 try {
2255 fbpoptsobj.userappwhitelist=appid;
2256 fbpsavevalue('fbpoptsjson-' + currentuserid, JSON.stringify(fbpoptsobj));
2257 window.alert(appname + ' has been Saved to your whitelist');
2258 refreshwhitelist();
2259 destroyblockedappstories(appid,'allow');
2260 }
2261 catch(e) {
2262 window.alert('error saving id to whitelist');
2263 }
2264 }
2265 }
2266 else
2267 return;
2268
2269 } // END allowapp function
2270
2271 function blockapp(appid, appname, nodeid, autoblock) {
2272 //var post_form_id = document.getElementById('post_form_id').getAttribute('value');
2273 var fb_dtsg = getdtsg();
2274 if(typeof currentuserid=='undefined' || currentuserid=='')
2275 currentuserid=getuserid();
2276
2277 //unsafeWindow.pages_show_block_app("49572793475", "block", "about");
2278
2279 // if not autoblocking - check if there are multiple apps to block, if so ask if user wants to block all at once
2280 if(typeof(autoblock)=='undefined') {
2281 var app2bcount=document.getElementsByClassName('fbpblocked').length;
2282 if (!confirm("Do you want to block application : '" + appname +"'"))
2283 return;
2284 if (app2bcount>1) // check if user wants to block all the currently shown applications
2285 if(blockallapps())
2286 return;
2287 }
2288 if(document.getElementById('blockapplab'))
2289 document.getElementById('blockapplab').style.display='none';
2290
2291 document.getElementById(nodeid).setAttribute('style','background:#DCDCDC !important;text-align:center');
2292 document.getElementById(nodeid).innerHTML='<b>F.B. Purity</b> : Blocking Application : "<span style="color:red">' + appname + '</span>"&nbsp;&nbsp;&nbsp;&nbsp;<img style="text-align:middle" src="http://i289.photobucket.com/albums/ll237/bitingbiting/fb-loading-anim.gif">';
2293
2294 var http = new window.XMLHttpRequest();
2295 //var url = window.location.protocol + "//" + window.location.hostname + "/ajax/apps/block_app.php?" + "app_id=" + appid + "&type_index=0&source=about&confirm_id=block_" + appid + "&__a=1";
2296 //var params = "__d=1&confirm=1&fb_dtsg=" + fb_dtsg + "&ok=Okay" ;
2297 var url = window.location.protocol + "//" + window.location.hostname + "/ajax/apps/block_app.php?" + "app_id=" + appid + "&type_index=0&source=about&confirm_id=block_" + appid;
2298 var params = "__asyncDialog=1&__user=" + currentuserid + "&__a=1&confirmed=1&fb_dtsg=" + fb_dtsg ;// + phstamp:1658166771106811366130
2299
2300 http.open("POST", url, true);
2301 //http.setRequestHeader("Referer", window.location.protocol + "//" + window.location.hostname + "/apps/application.php?id=" + appid);
2302 http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
2303 //http.setRequestHeader("Content-length", params.length);
2304 //http.setRequestHeader("Connection", "close");
2305
2306 http.onreadystatechange = function() {
2307 if(http.readyState == 4 && http.status == 200) {
2308 if(!http.responseText.match('\"errorSummary\"')){
2309 //unsafeWindow.console.log("successfully blocked app : '" + appname + "' with id=" +appid + "\n");
2310 if((nodeid!='platform_dialog_content') &&(nodeid!='pagelet_canvas_content') &&(nodeid!='platformDialogForm'))
2311 destroyblockedappstories (appid,'kill');
2312 else {
2313 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>';
2314 if(document.getElementsByClassName('platform_dialog_bottom_bar_table').length)
2315 document.getElementsByClassName('platform_dialog_bottom_bar_table')[0].style.display='none';
2316 }
2317
2318 }
2319 else {
2320 if(http.responseText.match(/\"errorSummary\"\:/))
2321 var errorsum=http.responseText.match(/\"errorSummary\"\:\"(.*)\",\"error/)[1];
2322 else
2323 var errorsum="";
2324 if(http.responseText.match(/\"errorDescription\"\:/))
2325 var errordesc=http.responseText.match(/\"errorDescription\"\:\"(.*)\",/)[1];
2326 else
2327 var errordesc="";
2328 if( errorsum.length && errordesc.length )
2329 var wholeerror = errorsum + ' : ' + errordesc;
2330 else
2331 var wholeerror = http.responseText;
2332 window.alert('app block failed for some reason:\n\n' + wholeerror);
2333 }
2334 http=null;
2335 }
2336 }
2337 http.send(params);
2338
2339 } // END blockapp function
2340
2341 function blockappev(ev) {
2342
2343 ev.preventDefault();
2344 var appname=this.getAttribute('appname');
2345 var appid=this.getAttribute('appid');
2346 var nodeid=this.getAttribute('nodeid');
2347 blockapp(appid,appname,nodeid);
2348 } // END blockappev function
2349
2350 function allowappev(ev) {
2351
2352 ev.preventDefault();
2353 var appname=this.getAttribute('appname');
2354 var appid=this.getAttribute('appid');
2355 var nodeid=this.getAttribute('nodeid');
2356 document.getElementById(nodeid).setAttribute('class', document.getElementById(nodeid).getAttribute('class') + ' aid_' + appid);
2357 allowapp(appid,appname);
2358 } // END allowappev function
2359
2360 function fbpshowblocked() {
2361
2362 var showhidelink=document.getElementById('fbpshowblockedlink');
2363 var showorhidetext=showhidelink.textContent;
2364
2365 var showhidelinkx=document.getElementById('fbpshowblockedxlink');
2366 var showorhidetextx=showhidelinkx.textContent;
2367
2368 var blockedmsgs=document.getElementsByClassName('fbpblocked');
2369
2370 if (showorhidetext=='Show') {
2371 if(!blockedmsgs.length)
2372 return;
2373 showhidelink.innerHTML='Hide';
2374 showhidelink.title='Hide Application + Game Stories';
2375 showhidelinkx.innerHTML='Show';
2376 showhidelinkx.title='Show Extras (Friend/Group/Fan/Event etc Stories)';
2377 fbpstyle.textContent=fbpStyleApps;
2378 }
2379 else {
2380 showhidelink.innerHTML='Show';
2381 showhidelink.title='Show Application + Game Stories';
2382 fbpstyle.textContent=fbpStyleNormal;
2383 }
2384
2385 //works better in reverse order
2386 for(i=(blockedmsgs.length-1); i>=0; i--) {
2387 //unsafeWindow.console.log("show block link: " + i);
2388 dspBlockLink(blockedmsgs[i]);
2389 }
2390
2391 blockedmsgs=null;
2392
2393 } // END fbpshowblocked function
2394
2395 function fbpshowblockedx() {
2396
2397 var showhidelinkx=document.getElementById('fbpshowblockedxlink');
2398 var showorhidetextx=showhidelinkx.textContent;
2399
2400 var showhidelink=document.getElementById('fbpshowblockedlink');
2401 var showorhidetext=showhidelink.textContent;
2402
2403 var blockedmsgs=document.getElementsByClassName('fbpblockedx');
2404
2405 if (showorhidetextx=='Show') {
2406 if(!blockedmsgs.length)
2407 return;
2408 showhidelinkx.innerHTML='Hide';
2409 showhidelinkx.title='Hide Extras (Friend/Group/Fan/Event etc Stories)';
2410 showhidelink.innerHTML='Show';
2411 showhidelink.title='Show Application + Game Stories';
2412 fbpstyle.textContent=fbpStyleExtras;
2413 }
2414 else {
2415 showhidelinkx.innerHTML='Show';
2416 showhidelinkx.title='Show Extras (Friend/Group/Fan/Event etc Stories)';
2417 fbpstyle.textContent=fbpStyleNormal;
2418 }
2419
2420 blockedmsgs=null;
2421
2422 } // END fbpshowblockedx
2423
2424 fbpshowblockedev = function (ev) {
2425 ev.preventDefault();
2426 fbpshowblocked();
2427 }
2428
2429 fbpshowblockedxev = function(ev) {
2430 ev.preventDefault();
2431 fbpshowblockedx();
2432 }
2433
2434 function dspBlockLink(node, blockmode) {
2435 if (node.getElementsByClassName('blocklink').length)
2436 return;
2437
2438 var appid;
2439 var appname='';
2440 // check if its a new FB Actions / Frictionless sharing app
2441 //uism =node.getElementsByClassName('uiStreamMessage');
2442 //if(uism.length)
2443 // if (uism[0].innerHTML.match(/\/hovercard\/application\.php\?id\=(\d*)|\/hovercard\/hovercard\.php\?id=(\d*)/))
2444 // blockmode='sua';
2445
2446 if (typeof(blockmode)=='undefined') {
2447 var footernode, headernode;
2448 headernode=node.getElementsByClassName('uiStreamMessage');
2449
2450 if(document.getElementsByClassName('uiStreamFooter') && document.getElementsByClassName('uiStreamFooter').length) {
2451 footernode=node.getElementsByClassName('uiStreamFooter')[0];
2452 }
2453 else
2454 if(document.getElementsByClassName('UIActionLinks_bottom') && document.getElementsByClassName('UIActionLinks_bottom').length) {
2455 footernode=node.getElementsByClassName('UIActionLinks_bottom')[0];
2456 }
2457 else {
2458 footernode='x'; //invalid node will cause exception, luckily we have an exception handler isnt it ;-)
2459 }
2460
2461 //its possibly an app posing as a normal facebook message, so lets try and get the appid from the footer
2462 if(headernode.length && headernode[0].innerHTML.match(/application\.php\?id=(\d+)/)) {
2463 appid=headernode[0].innerHTML.match(/application\.php\?id=(\d+)/)[1];
2464 }
2465 else if(footernode.innerHTML.match(/php\?id=(\d+)\"|\&quot\;app_id\&quot\;\:(\d+)\,/)) {
2466 if(typeof footernode.innerHTML.match(/php\?id=(\d+)\"|\&quot\;app_id\&quot\;\:(\d+)\,/)[1] !='undefined')
2467 appid=footernode.innerHTML.match(/php\?id=(\d+)\"|\&quot\;app_id\&quot\;\:(\d+)\,/)[1];
2468 else if(typeof footernode.innerHTML.match(/php\?id=(\d+)\"|\&quot\;app_id\&quot\;\:(\d+)\,/)[2] !='undefined')
2469 appid=footernode.innerHTML.match(/php\?id=(\d+)\"|\&quot\;app_id\&quot\;\:(\d+)\,/)[2];
2470 }
2471 else
2472 if(footernode.innerHTML.match(/application\.php\?id=(\d+)/)) {
2473 if(footernode.innerHTML.match(/application\.php\?id=(\d+)/)[1]!='undefined')
2474 appid=footernode.innerHTML.match(/application\.php\?id=(\d+)/)[1];
2475 }
2476 else
2477 return;
2478
2479 try {
2480 //appname=footernode.getElementsByClassName("GenericStory_BottomAttribution")[0].getElementsByTagName('a')[0].textContent;
2481 if(footernode.innerHTML.match(/data-appname=/))
2482 appname=footernode.innerHTML.match(/data-appname="([^"]*)"/)[1] ;
2483 else if (headernode[0].innerHTML.match(/application.php/)){
2484 appname=headernode[0].innerHTML.match(/application\.php\?id=.*\>(.*)<\/\a\>/)[1];
2485 }
2486 else
2487 {
2488 flinks=footernode.getElementsByTagName('a');
2489 appname=flinks[flinks.length-1].textContent;
2490 if(appname=='')
2491 appname=flinks[flinks.length-2].textContent;
2492 }
2493 } catch (e) {
2494 appname='mystery app x';
2495 //unsafeWindow.console.log('error getting application name');
2496 }
2497
2498 } // END if blockmode=normal (if !blockmode.length)
2499 else {
2500 // we are doing this for "started using app/game" (sua) type posts
2501 var uism = node.getElementsByClassName('uiStreamMessage')
2502 var alinks=uism[0].getElementsByTagName('a');
2503 for(var i=0;i<alinks.length;i++){
2504 var datahover=alinks[i].getAttribute('data-hovercard');
2505 if(datahover) {
2506 var datahovermatch=datahover.match(/\/hovercard\/application\.php\?id\=(\d*)/);
2507 //var datahovermatch2=datahover.match(/\/hovercard\/hovercard\.php\?id=(\d*)/);
2508 if(datahovermatch) {
2509 appid=datahovermatch[1];
2510 appname=alinks[i].textContent;
2511 break;
2512 }
2513 /* else if(datahovermatch2) {
2514 appname=alinks[i].textContent;
2515 var nodnod=node.getElementsByTagName('a');
2516 for(var q=0;q<nodnod.length;i++)
2517 if(nodnod[q].textContent.match(appname)) {
2518 appidmatch=nodnod[q].getAttribute('data-hovercard').match(/\/hovercard\/application\.php\?id\=(\d*)/);
2519 if(appidmatch) {
2520 appid=appidmatch[1];
2521 break;
2522 }
2523 }
2524 nodnod=null;
2525 } */
2526 }
2527 }
2528 if(typeof(appid)=='undefined' || appid =='') { // dealing with frictionless sharing apps such as netflix
2529 if(node.getAttribute('data-gt')) {
2530 //"appid":"163114453728333"
2531 if(node.getAttribute('data-gt').match(/\"appid\":\"\d+\"/)) {
2532 appid=node.getAttribute('data-gt').match(/\"appid\":\"(\d+)\"/)[1];
2533 //appname=alinks[alinks.length-1].textContent;
2534 footerstuff=node.getElementsByClassName("uiStreamFooter");
2535 if(footerstuff.length){
2536 footerimagelink=footerstuff[0].getElementsByTagName('a');
2537 if(footerimagelink.length)
2538 if(footerimagelink[0].getAttribute('data-appname'))
2539 appname=footerimagelink[0].getAttribute('data-appname');
2540 }
2541 }
2542 }
2543 }
2544 alinks=null;
2545 }
2546 //console.log(appid + ' ' + appname);
2547
2548 if (document.getElementsByClassName('uiStreamHide') && document.getElementsByClassName('uiStreamHide').length) {
2549 hidebuttonclass='uiStreamHide';
2550 hidebuttonclasses='uiStreamHide';
2551 linkclasses='blocklink uiStreamContextButton uiPopoverTriggerElem';
2552 }
2553 else {
2554 hidebuttonclass='hideButton';
2555 hidebuttonclasses='mlm hideButton';
2556 linkclasses='blocklink mlm hideButton';
2557 }
2558
2559 hidebuttonclasses='uiStreamContextButton uiPopoverTriggerElem';
2560
2561 var blinkinsertpoint=node.getElementsByClassName(hidebuttonclass)[0];
2562
2563 if(typeof blinkinsertpoint == 'undefined') {
2564 //alert('hohoho');
2565 var uism=node.getElementsByClassName('uiStreamMessage');
2566 if(uism && uism.length)
2567 blinkinsertpoint=uism[0];
2568 else
2569 return;
2570 }
2571
2572 node.setAttribute('class', node.getAttribute('class') + ' aid_' + appid); // lets do it for all apps (cos on profile pages apps sometimes dont include this class)
2573 var blinkspan=document.createElement('div');
2574
2575 blinkspan.setAttribute('style',"position:relative;opacity:0.5; top : 23px");
2576 blinkspan.className=hidebuttonclasses;
2577
2578 blinkspan.innerHTML="<a class='" + linkclasses +"' style='text-decoration: none;' onmouseover='this.style.background=\"red\";this.style.color=\"white\";this.parentNode.style.opacity=\"1\"' onmouseout='this.style.background=\"white\";this.style.color=\"#3B5998\";this.parentNode.style.opacity=\"0.5\"' title='FBP - Block this application' nodeid='" + node.getAttribute('id') + "' appid='" + appid + "' appname='" + appname.replace('"','','g').replace("'",'','g') + "' href='javascript:;'><b><nobr>BA</nobr></b></a>";
2579 blinkspan.getElementsByTagName('a')[0].addEventListener("click", blockappev, false);
2580 //blinkinsertpoint.parentNode.insertBefore(blinkspan, blinkinsertpoint); //(insert before pattern)
2581 blinkinsertpoint.appendChild(blinkspan);
2582 blinkinsertpoint.appendChild(document.createElement('br')); // separate the 2 links
2583
2584 var alinkspan=document.createElement('div');
2585 alinkspan.setAttribute('style',"position:relative; opacity:0.5; top : 23px;");
2586 alinkspan.className=hidebuttonclasses;
2587
2588 alinkspan.innerHTML="<a class='" + linkclasses + "'style='text-decoration: none;' onmouseover='this.style.background=\"green\";this.style.color=\"white\";this.parentNode.style.opacity=\"1\"' onmouseout='this.style.background=\"white\";this.style.color=\"#3B5998\";this.parentNode.style.opacity=\"0.5\"' title='FBP - Whitelist this application' nodeid='" + node.getAttribute('id') + "' appid='" + appid + "' appname='" + appname.replace('"','','g').replace("'",'','g') + "' href='javascript:;'><b><nobr>WL</nobr></b></a>";
2589 alinkspan.getElementsByTagName('a')[0].addEventListener("click", allowappev, false);
2590 //blinkinsertpoint.parentNode.insertBefore(alinkspan, blinkinsertpoint); //(insert before pattern)
2591 blinkinsertpoint.appendChild(alinkspan);
2592
2593 } // END dspBlockLink function
2594
2595 function callLater(paramA, paramB, paramC, paramD, paramE){
2596 return (function(){
2597 //blockapp(appid, appname, nodeid, auto);
2598 paramA(paramB, paramC, paramD, paramE);
2599 //unsafeWindow.console.log(paramA,paramB, paramC, paramD)
2600 });
2601 }
2602
2603 blockallapps = function() {
2604 var appdump=document.getElementsByClassName('fbpblocked');
2605 var apparray=[];
2606 var appnamelist='';
2607 var applength=0;
2608 for(var i=0;i<appdump.length;i++) {
2609 if(appdump[i].getElementsByClassName('blocklink').length && !apparray[appdump[i].getElementsByClassName('blocklink')[0].getAttribute('appid')]) {
2610 apparray[appdump[i].getElementsByClassName('blocklink')[0].getAttribute('appid')] = appdump[i].getAttribute('id') + ',' + appdump[i].getElementsByClassName('blocklink')[0].getAttribute('appname');
2611 appnamelist+= appdump[i].getElementsByClassName('blocklink')[0].getAttribute('appname') + '\n';
2612 applength++;
2613 }
2614 }
2615
2616 if(applength==1)
2617 return false; // return and use normal block app function
2618
2619 if(!confirm('Would you also like to block *ALL* ' + applength + ' of the following facebook applications?\n' + '-------------------------------------------------------------------------------\n\n' + appnamelist.replace(/\n$/,'')))
2620 return false;
2621
2622 i=0;
2623 for(var j in apparray) {
2624 i++;
2625 var functRef = callLater(blockapp,j,apparray[j].split(/,/)[1], apparray[j].split(/,/)[0], 1);
2626 window.setTimeout(functRef, 1600*i);
2627 }
2628
2629 window.scrollTo(0,0); // scroll up, so user can see its working
2630 appdump=null;
2631 apparray=null;
2632 appnamelist=null;
2633 return true;
2634 } // END blockallapps function
2635
2636 fbptoggleopts=function(e) {
2637 if(e)
2638 e.preventDefault();
2639 if(!document.getElementById('fbpoptsdiv') && document.getElementById('content') ) {
2640 optsdiv.innerHTML=fbpoptshtml;
2641 document.getElementById('content').appendChild(optsdiv);
2642 document.getElementById('fbpsavesettings').addEventListener('click',fbpsavesettings,false);
2643
2644 document.getElementById('exportsettingslink').addEventListener('click',exportsettingsbasic,false);
2645 document.getElementById('importsettingslink').addEventListener('click',importsettingsbasic,false);
2646
2647 document.getElementById('custextheader').addEventListener('click',hideotherdivs,false);
2648 document.getElementById('appwhitelistheader').addEventListener('click',hideotherdivs,false);
2649 document.getElementById('custcssheader').addEventListener('click',hideotherdivs,false);
2650 }
2651
2652 //fbpgetprefs(); // is this call really neccessary? opts obj should already be populated, though perhaps opts have changed in another tab/window
2653 fbppopulateprefs();
2654 document.getElementById('fbpoptsdiv').style.display='block';
2655 // get latest fbp news
2656 //grabjsonfeed('https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q=http%3A//feeds.feedburner.com/facebookpurity&callback=publishjsonnews'); // cant use till we update to manifest 2
2657 getfbpnews();
2658 }
2659
2660 getfbpnews=function() {
2661 //var FBP_FEED = "https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=5&q=http://feeds.feedburner.com/FacebookPurity";
2662 var FBP_FEED = "www.facebook.com/feeds/page.php?id=408502197558&format=json";
2663 // set a callback function
2664 // https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q=http%3A//api.flickr.com/services/feeds/photos_public.gne%3Fid%3D17472213@N00%26lang%3Den-us%26format%3Drss_200&v=1.0&callback=processResults
2665 var FBP_FEED_URL = window.location.protocol +"\/\/" + FBP_FEED ; //
2666 var fbpnewsdiv=document.getElementById('fbpnewsdiv');
2667 fbpnewsdiv.style.marginLeft='4px';
2668 fbpnewsdiv.style.marginTop='4px';
2669 if(fbpnewsdiv.innerHTML.length)
2670 return;
2671 fbpnewsdiv.innerHTML+='<h4 style="margin-top:4px"><a title="news.fbpurity.com" href="http://www.fbpurity.com/news.htm">F.B. Purity Latest News</a></h4>';
2672
2673 //fbpnewsdiv.innerHTML+='<span style="color:red">Without warning or explanation, Facebook have disabled the personal account of the developer of F.B. Purity and also the F.B. Purity fan page, which had over 36,000 fans. [ <a href="http://news.fbpurity.com">Please click here for the full story</a> ] </span>';
2674
2675 var http = new window.XMLHttpRequest();
2676 http.open("GET", FBP_FEED_URL, true);
2677 //http.setRequestHeader("Connection", "close");
2678 http.onreadystatechange = function() {
2679 if(http.readyState == 4 && http.status == 200) {
2680 try {
2681 var fbpfeed = JSON.parse(http.responseText);
2682 }
2683 catch (e) {
2684 fbpnewsdiv.innerHTML+='Error : Cant get the news. This can occur if you are logged in to FB as a page Admin.' ;
2685 http=fbpfeed=null;
2686 return;
2687 }
2688 if(fbpfeed.entries.length<4)
2689 feedlength=fbpfeed.entries.length;
2690 else
2691 feedlength=4;
2692
2693 var newsul=document.createElement('ul');
2694 newsul.style.marginTop='3px';
2695 newsul.style.marginLeft='5px';
2696 var newsli = document.createElement('li');
2697 for(i=0;i<feedlength;i++) {
2698 if (!fbpfeed.entries[i].title.replace(/^\ /,'').length) // deal with stupid facebook bug (pics + polls in the json feed dont have titles)
2699 continue;
2700 x =new Date (fbpfeed.entries[i].published);
2701 newsli = document.createElement('li');
2702 newsli.style.marginBottom="2px";
2703 newsli.style.listStyleType="disc";
2704 newsa = document.createElement('a');
2705 newsa.setAttribute('title', "Published - " + x.toLocaleDateString());
2706 newsa.setAttribute('target', "_blank");
2707 newsa.setAttribute('href', fbpfeed.entries[i].alternate);
2708 newsa.appendChild(document.createTextNode(fbpfeed.entries[i].title.replace(/&#039;/g,"'").replace(/&quot;/g,'"')));
2709 newsli.appendChild(newsa);
2710 newsul.appendChild(newsli);
2711 }
2712 fbpnewsdiv.appendChild(newsul);
2713 http=fbpfeed=newsul=newsli=newsa=null;
2714 }
2715 }
2716 http.send();
2717 } // END getfbpnews function
2718
2719 /*
2720 Commented out because code wont work with latest chrome, unless we update to manifest v2
2721
2722 function jsoncallbackwrapper() {
2723
2724 publishjsonnews=function(json) {
2725
2726 var fbpnewsdiv=document.getElementById('fbpnewsdiv');
2727
2728 if(fbpnewsdiv.innerHTML.length)
2729 return;
2730 fbpnewsdiv.innerHTML+='<h4 style="margin-top:4px"><a title="news.fbpurity.com" href="http://www.fbpurity.com/news.htm">F.B. Purity Latest News</a></h4>';
2731 if(!json.responseData.feed.entries.length){
2732 fbpnewsdiv.innerHTML+='Error : Cant get the news.' ;
2733 return;
2734 }
2735 //console.log(json.responseData);
2736 fbpfeed=json.responseData.feed;
2737 var newsul=document.createElement('ul');
2738 newsul.style.marginTop='3px';
2739 newsul.style.marginLeft='5px';
2740 var newsli = document.createElement('li');
2741 for(var i=0;i<4;i++) {
2742 x =new Date (fbpfeed.entries[i].publishedDate);
2743 newsli = document.createElement('li');
2744 newsli.style.marginBottom="2px";
2745 newsli.style.listStyleType="disc";
2746 newsa = document.createElement('a');
2747 newsa.setAttribute('title', "Published - " + x.toLocaleDateString());
2748 newsa.setAttribute('target', "_blank");
2749 newsa.setAttribute('href', fbpfeed.entries[i].link);
2750 newsa.appendChild(document.createTextNode(fbpfeed.entries[i].title.replace(/&#039;/,"'")));
2751 newsli.appendChild(newsa);
2752 newsul.appendChild(newsli);
2753 }
2754 if(fbpnewsdiv)
2755 fbpnewsdiv.appendChild(newsul);
2756 fbpfeed=newsul=newsli=newsa=null;
2757 //document.getElementsByTagName('body')[0].appendChild(fbpnewsdiv);
2758 } // END publishjsonnews function
2759
2760 } // END jsoncallbackwrapper
2761
2762 // BEGIN inject code inside jsoncallbackwrapper function into fb page
2763 var script = document.createElement('script');
2764 script.appendChild(document.createTextNode('('+ jsoncallbackwrapper +')();'));
2765 try {
2766 (document.head || document.body || document.documentElement).appendChild(script);
2767 }
2768 catch(e) {
2769 ;//console.log(e , location.href);
2770 }
2771 // END inject jsoncallbackwrapper code into fb page
2772
2773 function grabjsonfeed(url){
2774 //console.log(url);
2775 var script=document.createElement('script');
2776 script.src=url;
2777 script.type="text/javascript";
2778 if(document.getElementsByTagName('head').length)
2779 document.getElementsByTagName('head')[0].appendChild(script);
2780 }
2781 */
2782
2783 function fixarticleredirects (node) {
2784 try {
2785 //console.log('fixarticleredriects');
2786 var xtmp=node.getElementsByTagName('a');
2787 //console.log(node.textContent + xtmp.length);
2788 for (var i=0;i<xtmp.length;i++)
2789 if(xtmp[i].getAttribute('href')){
2790 //console.log(xtmp[i].getAttribute('href'));
2791 if(xtmp[i].getAttribute('href').match(/redirect_uri=(.*)\&/)) { // matches independent and yahoo
2792 //console.log('indep yahoo' + xtmp[i].getAttribute('href'));
2793 xtmp[i].setAttribute('href', decodeURIComponent(xtmp[i].getAttribute('href').match(/redirect_uri=(.*?)\&/)[1].split(/fb_action_ids/)[0]));
2794 xtmp[i].setAttribute('rel','');
2795 xtmp[i].setAttribute('mousedown','');
2796 }
2797 else if (xtmp[i].getAttribute('href').match(/https?\:\/\/www\.guardian\.co\.uk/)) {
2798 xtmp[i].setAttribute('href',decodeURIComponent(xtmp[i].getAttribute('href').match(/(https?\:\/\/www\.guardian\.co\.uk.*?)\?fb_action_ids/)[1]));
2799 //console.log(decodeURIComponent(xtmp[i].getAttribute('href').match(/(http\:\/\/www\.guardian\.co\.uk.*?)\?fb_action_ids/)[1]));
2800 xtmp[i].setAttribute('rel','');
2801 xtmp[i].setAttribute('onmousedown','');
2802 }
2803 else if (xtmp[i].getAttribute('href').match(/https?\:\/\/www\.facebook\.com\/l\.php\?u=/)) {
2804 xtmp[i].setAttribute('href',decodeURIComponent(xtmp[i].getAttribute('href').match(/http\:\/\/www\.facebook\.com\/l\.php\?u=(.*)\%3Ffb_action_ids/)[1]));
2805 //console.log(xtmp[i].getAttribute('href'));
2806 xtmp[i].setAttribute('rel','');
2807 xtmp[i].setAttribute('onmousedown','');
2808 }
2809 else if(xtmp[i].getAttribute('href').match(/https?\:\/\/apps\.facebook\.com/)){
2810 if(xtmp[i].textContent.length){ // && xtmp[i].parentNode.getAttribute('class').match(/ogAggregationAnimSubstorySlideHeadline/)
2811 xtmp[i].setAttribute('href', 'http://google.com/search?q=' + encodeURIComponent("'" + xtmp[i].textContent + "'") + "&btnI=I'm+Feeling+Lucky");
2812 xtmp[i].setAttribute('rel','');
2813 xtmp[i].setAttribute('mousedown','');
2814 }
2815 }
2816 } // end if
2817 //else
2818 // console.log(xtmp[i].getAttribute('href'));
2819 xtmp=null;
2820 } catch(e)
2821 {
2822 ;//console.log('feckit! ' + e );
2823 }
2824 }
2825
2826 function filtermatchmsg(mnode, msg) {
2827 if(mnode.getElementsByClassName('filtermatchtext').length)
2828 mnode.getElementsByClassName('filtermatchtext')[0].textContent=msg;
2829 else {
2830 var matchspan=document.createElement('div');
2831 matchspan.setAttribute('class','filtermatchtext');
2832 matchspan.style.color='grey';
2833 matchspan.appendChild(document.createElement('br'));
2834 matchspan.appendChild(document.createTextNode(msg));
2835 mnode.appendChild(matchspan);
2836 }
2837 }
2838
2839 function cleartheshizzle(thenode) {
2840 //if(location.href.match(/facebook\.com\/messages\//))
2841 // return;
2842 //unsafeWindow.console.log('clearing the shizzle a : ' + location.href);
2843 var oldfeedstyle=document.getElementById('pagelet_home_stream');
2844 var newfeedstyle=document.getElementById('pagelet_litestand_section');
2845 var neweststyle= document.getElementById('stream_pagelet');
2846 //if(!oldfeedstyle && (!newfeedstyle) && (!neweststyle))
2847 if(!(oldfeedstyle || newfeedstyle || neweststyle)) {
2848 console.log('FBP Error: couldnt find the news stream');
2849 return;
2850 }
2851 //if(!document.getElementById('pagelet_home_stream') || (!document.getElementById('pagelet_litestand_section')))
2852 // return;
2853
2854 if(!document.getElementById('fbpblockcount')) {
2855
2856 crappyappmsgcounter=0;
2857 fbpstyle.textContent=fbpStyleNormal;
2858
2859 if(document.getElementById('pagelet_fl_composer')) // friends list page
2860 var insertpoint = document.getElementById('pagelet_fl_composer');
2861 else if (document.getElementById('profile_stream_composer')) //profile page or fanpage
2862 var insertpoint = document.getElementById('profile_stream_composer');
2863 else if (document.getElementById('pagelet_composer')) //homepage
2864 var insertpoint = document.getElementById('pagelet_composer');
2865 else if(document.getElementById('timelineNavContent')) {
2866 return;
2867 var insertpoint = document.getElementById('timelineNavContent');
2868 }
2869 else if(window.location.href.match(/facebook\.com\/apps\/feed/) || window.location.href.match(/facebook\.com\/pages\/feed/))
2870 var insertpoint = document.getElementById('contentArea');
2871
2872 if(insertpoint) {
2873 if(document.getElementsByClassName('uiHeaderPage') && document.getElementsByClassName('uiHeaderPage').length)
2874 document.getElementsByClassName('uiHeaderPage')[0].setAttribute('style','padding-bottom:5px');
2875 var fbpurityinfowrapper=document.createElement('div');
2876 if(oldfeedstyle)
2877 fbpurityinfowrapper.style.marginTop='-10px';
2878 fbpurityinfowrapper.style.marginBottom='2px';
2879 fbpurityinfowrapper.setAttribute('id','fbpurityinfowrapper');
2880 if(document.getElementById('boulder_fixed_header'))
2881 document.getElementById('boulder_fixed_header').firstChild.style.marginTop='13px';
2882 var fbpurityinfo=document.createElement('div');
2883 fbpurityinfo.setAttribute('id','fbpurityinfobar');
2884 var fbpclear=document.createElement('div');
2885 fbpclear.style.clear='both';
2886
2887 fbpurityinfo.style.cssFloat='right';
2888 fbpurityinfo.style.background='whitesmoke';
2889 fbpurityinfo.innerHTML='<span id="fbpupgradeinfo" style="color:red"></span>&nbsp;<a id="fbpoptslink" title="' + fbpVersion + ' - Fluff Busting Purity - Options" href="javascript:;"><b>F.B. Purity</b></a> <span id="fbperrormsg" style="color:red"></span> hid: &nbsp;<span id="fbpblockcount">0</span> <abbr title="Application + Game Stories">app</abbr> [ <a title="Show Application + Game Stories" id="fbpshowblockedlink" href="javascript:;">Show</a> ] &nbsp;<span id="fbpblockxcount">0</span> <abbr title="Friend/Group/Fan/Event etc Stories">extra</abbr> [ <a title="Show Friend/Group/Fan/Event etc Stories" id="fbpshowblockedxlink" href="javascript:;">Show</a> ]&nbsp;';
2890
2891 fbpurityinfowrapper.appendChild(fbpurityinfo);
2892 fbpurityinfowrapper.appendChild(fbpclear);
2893
2894 if((document.getElementById('pagelet_composer') || document.getElementById('pagelet_fl_composer')) && (!document.getElementById('fbpurityinfobar'))) // homepage // fanpage or // friends list page
2895 insertpoint.parentNode.insertBefore(fbpurityinfowrapper, insertpoint.nextSibling); // after composer
2896 else if (document.getElementById('profile_stream_composer') && (!document.getElementById('fbpurityinfobar')))
2897 insertpoint.parentNode.insertBefore(fbpurityinfowrapper, insertpoint.nextSibling);
2898 else if (document.getElementById('timelineNavContent') && (!document.getElementById('fbpurityinfobar'))) {
2899 fbpurityinfowrapper.style.display='none'; // we not showing bar for now, as filtering doesnt work on timeline yet
2900 insertpoint.appendChild(fbpurityinfowrapper);
2901 }
2902 else if(window.location.href.match(/facebook\.com\/apps\/feed/) || window.location.href.match(/facebook\.com\/pages\/feed/)) { // games feed page
2903 insertpoint.insertBefore(fbpurityinfowrapper, insertpoint.firstChild);
2904 }
2905
2906 document.getElementById('fbpshowblockedlink').addEventListener("click", fbpshowblockedev, false);
2907 document.getElementById('fbpshowblockedxlink').addEventListener("click", fbpshowblockedxev, false);
2908 document.getElementById('fbpoptslink').addEventListener("click", fbptoggleopts, false);
2909
2910 fpbblockcountspan=document.getElementById('fbpblockcount');
2911 fpbblockxcountspan=document.getElementById('fbpblockxcount');
2912
2913 }
2914
2915 }
2916
2917 //if we navigate away from the page then come back, the event listeners seem to disappear, so lets re-add them here.
2918 if( document.getElementById('fbpshowblockedlink') ) {
2919 document.getElementById('fbpshowblockedlink').removeEventListener("click", fbpshowblockedev, false);
2920 document.getElementById('fbpshowblockedlink').addEventListener("click", fbpshowblockedev, false);
2921 }
2922 if( document.getElementById('fbpshowblockedxlink') ) {
2923 document.getElementById('fbpshowblockedxlink').removeEventListener("click", fbpshowblockedxev, false);
2924 document.getElementById('fbpshowblockedxlink').addEventListener("click", fbpshowblockedxev, false);
2925 }
2926 if( document.getElementById('fbpoptslink') ) {
2927 document.getElementById('fbpoptslink').removeEventListener("click", fbptoggleopts, false);
2928 document.getElementById('fbpoptslink').addEventListener("click", fbptoggleopts, false);
2929 }
2930
2931 // Deal with recent activity blocks
2932 /*
2933 if (thenode.getAttribute && thenode.getAttribute('class') && thenode.getAttribute('class').match(/uiStreamMinistoryGroup/)) {
2934 if(fbpoptsobj.recentactivity) {
2935 thenode.setAttribute('class',thenode.getAttribute('class') + ' fbpblockedx');
2936 updateblockedcount();
2937 return;
2938 }
2939 else {
2940 thenode.setAttribute('class',thenode.getAttribute('class') + ' fbpnormal');
2941 return;
2942 }
2943 }
2944 else if(thenode.getElementsByClassName('uiStreamMinistoryGroup').length) {
2945 var rablocks=thenode.getElementsByClassName('uiStreamMinistoryGroup');
2946 for(var rai=0;rai<rablocks.length;i++)
2947 if(fbpoptsobj.recentactivity) {
2948 rablocks[rai].setAttribute('class',rablocks[rai].getAttribute('class') + ' fbpblockedx');
2949 updateblockedcount();
2950 }
2951 else
2952 rablocks[rai].setAttribute('class',rablocks[rai].getAttribute('class') + ' fbpnormal');
2953 rablocks=null;
2954 }
2955 */
2956
2957 storyclass="uiStreamStory";
2958
2959 var storynodes, singlestory;
2960 singlestory=0;
2961 if(oldfeedstyle) {
2962 storynodes=thenode.getElementsByClassName(storyclass);
2963 if (!storynodes[0])
2964 if(thenode.getAttribute && thenode.getAttribute('class') && thenode.getAttribute('class').match(storyclass)) {
2965 storynodes[0]=thenode;
2966 singlestory=1;
2967 }
2968 else {
2969 //unsafeWindow.console.log('no generic: ' + thenode.getAttribute('class'));
2970 return;
2971 }
2972 }
2973 else { // new newsfeed design
2974 storynodes=thenode.querySelectorAll("div[data-dedupekey]");
2975 if (!storynodes[0])
2976 if(thenode.getAttribute && thenode.getAttribute('data-dedupekey')) {
2977 storynodes[0]=thenode;
2978 singlestory=1;
2979 }
2980 else {
2981 //unsafeWindow.console.log('no generic: ' + thenode.getAttribute('class'));
2982 return;
2983 }
2984 }
2985
2986 var blockit, blockitx;
2987 var story_meta, fbpAppId; // story_type,
2988 var attribappid, attribnode, fbpAppIdMatch;
2989 var storysaction, storysactiontext;
2990 var actoria, actorialink, actoriadatacard;
2991 var storyattachments,storyattachment;
2992
2993 if(singlestory)
2994 storynodeslength=1;
2995 else
2996 storynodeslength=storynodes.length;
2997
2998 // START MAIN LOOP
2999 for(i=0;i<storynodeslength;i++) {
3000 if(oldfeedstyle) {
3001 if(storynodes[i].nodeName=='DIV') //deal with anomalous div that has classname pvm
3002 continue;
3003 if((storynodes[i].parentNode.parentNode && storynodes[i].parentNode.parentNode.getAttribute('class') && storynodes[i].parentNode.parentNode.getAttribute('class').match('uiStreamMinistoryGroup')) || ((storynodes[i].parentNode.parentNode.parentNode.parentNode.getAttribute('class') && storynodes[i].parentNode.parentNode.parentNode.parentNode.getAttribute('class').match('uiStreamMinistoryGroup'))))
3004 continue;
3005 }
3006
3007 blockit=0;
3008
3009 //console.log(storynodes[i].textContent);
3010
3011 //parse the story's header for the story type and check the header for any matches
3012 if(oldfeedstyle)
3013 storysaction=storynodes[i].getElementsByClassName('uiStreamMessage');
3014 else
3015 storysaction=storynodes[i].getElementsByTagName('h5');
3016 if(storysaction && storysaction.length) {
3017 //unsafeWindow.console.log(storysaction + storysaction.length + storysaction[0].textContent);
3018 storysactiontext=storysaction[0].textContent;
3019 }
3020 else {
3021 if(oldfeedstyle)
3022 storysactiontext='';
3023 else
3024 storysactiontext=storynodes[i].textContent;
3025 }
3026 if(typeof storysactiontext=='undefined')
3027 storysactiontext='';
3028
3029 if(debug)
3030 console.log(storysactiontext);
3031 storyattachments=storynodes[i].getElementsByClassName('uiStreamAttachments');
3032 story_meta=storynodes[i].getAttribute('data-ft');
3033 if(story_meta==null) {
3034 /*
3035 if(storynodes[i].getElementsByClassName('fss').length) { // check for Recent Activity Blocks
3036 // need to check fbpopts for whether to treat as extra
3037 if(fbpoptsobj.recentactivity==1)
3038 storynodes[i].setAttribute('class',storynodes[i].getAttribute('class')+ ' fbpblockedx');
3039 else
3040 storynodes[i].setAttribute('class',storynodes[i].getAttribute('class')+ ' fbpnormal');
3041 updateblockedcount();
3042 continue;
3043 }
3044 */
3045 if(storynodes[i].className.match(/uiFacepile|uiListHorizontal|uiListVerticalItemBorder/)) { // deals with new feature of friends list pages
3046 continue;
3047 }
3048 break;
3049 }
3050
3051 // sponsored stories filter
3052 if(fbpoptsobj.sponsoredbox && story_meta && story_meta.match(/"ei"/)) {
3053 storynodes[i].style.display='none';//backgroundColor='red';
3054 continue;
3055 }
3056 // "play with friends" story filter
3057 if(fbpoptsobj.filterappmessages && storynodes[i].getAttribute('class').match(/aid_140332009231/)) {
3058 storynodes[i].style.display='none'; //.style.backgroundColor='red';
3059 continue;
3060 }
3061
3062 // experimental swearing filter (seems a bit memory intensive..)
3063 /*
3064 var swearfilter=1;
3065 if(swearfilter) {
3066 storynodes[i].innerHTML=storynodes[i].innerHTML.split(/cunt|shit|piss|fuck|wank|arse|tits|cocksucker/).join("****");
3067 }
3068 */
3069
3070 /*
3071 var foundspon=0;
3072 ufooter=storynodes[i].getElementsByClassName('uiStreamFooter');
3073 if(ufooter.length){
3074 for(g=0;g<ufooter.length;g++)
3075 if(ufooter[g].textContent.match(/· Sponsored/)) {
3076 storynodes[i].style.display='none';
3077 if(debug)
3078 console.log("Hid sponsored story\n\n" + storynodes[i].textContent);
3079 foundspon=1;
3080 break;
3081 }
3082 if(foundspon)
3083 continue;
3084 }
3085 */
3086
3087 // start fan page story filter . also check that we are not on an fb fan page or the story is not by the current logged in user,
3088 //if(fbpoptsobj.pagestory && (!document.getElementById('pagelet_pages_about'))) {
3089 //console.log(storynodes[i].innerHTML);
3090 actoria=storynodes[i].getElementsByClassName('uiStreamMessage');
3091 if(actoria.length) {
3092 actorialink=actoria[0].getElementsByTagName('a')[0];
3093 if(typeof(actorialink)!='undefined') {
3094 actoriadatacard=actorialink.getAttribute('data-hovercardx');
3095 if(!actoriadatacard)
3096 actoriadatacard=actorialink.getAttribute('data-hovercard');
3097 }
3098 if(actoriadatacard) {
3099 if (actoriadatacard.match(useridwhitelistRX)) { // if its fbp or the current user
3100 storynodes[i].setAttribute('class',storynodes[i].getAttribute('class')+ ' fbpnormal');
3101 actoriadatcard=null;
3102 actorialink=null;
3103 actoria=null;
3104 continue;
3105 }
3106 else if(fbpoptsobj.pagestory && (!document.getElementById('pagelet_pages_about')) && actoriadatacard.match(/page\.php/) && (!window.location.href.match(/facebook.com\/(pages\/feed|lists\/)/))) {
3107 // if we are on the "page feed" or interest list leave it alone
3108 //if(actoriadatacard.match(/page\.php/) && (!actoriadatacard.match(/id=408502197558/))) {
3109 //its a page and its not fbp;
3110 storynodes[i].setAttribute('class',storynodes[i].getAttribute('class')+ ' fbpblockedx');
3111 filtermatchmsg(storynodes[i],'FBP : Story Type Filter Match - Fan Page Story');
3112 updateblockedcount();
3113 actoriadatcard=null;
3114 actorialink=null;
3115 actoria=null;
3116 continue;
3117 }
3118 actoriadatacard=null;
3119 }
3120 actorialink=null;
3121 }
3122 actoria=null;
3123 // end fan page story filter
3124
3125 //unsafeWindow.console.log('"'+storysactiontext+'"' + ' ' + headerTextFilter);
3126 // lets check the header text filter
3127 if((fbpoptsobj.fixarticleredirects && storysactiontext.length && storysactiontext.match(/ article/)) || storynodes[i].getElementsByClassName('ogAggregationSubstory').length || storynodes[i].getElementsByClassName('ogStaticSlidePager').length || storynodes[i].getElementsByClassName('ogSliderAnimPager').length) {
3128 fixarticleredirects(storynodes[i]);
3129 }
3130
3131 if(storysactiontext.length && headerTextFilter.length && storysactiontext.match(headertextfilterRX)) {
3132 storynodes[i].setAttribute('class',storynodes[i].getAttribute('class')+' fbpblockedx');
3133 //matchspan=document.createElement('div');
3134 //matchspan.style.color='grey';
3135 matchedtext=storysactiontext.match(headertextfilterRX)[0];
3136 filtermatchmsg(storynodes[i],' FBP : Story Type Filter Match - ' + matchedtext);
3137 //if(matchedtext.match(/ article/))
3138 // fixarticleredirects(storynodes[i]);
3139 storysactiontext=matchedtext='';
3140 updateblockedcount();
3141 continue;
3142 }
3143
3144 // lets check the text filter
3145 if(cleancustomtextfilter.length && storynodes[i].textContent.length && storynodes[i].textContent.match(textfilterRX)) {
3146 //window.console.log(storynodes[i].textContent)
3147 storynodes[i].setAttribute('class',storynodes[i].getAttribute('class')+' fbpblockedx');
3148 filtermatchmsg(storynodes[i],' FBP : Custom Text Filter Match - ' + storynodes[i].textContent.match(textfilterRX)[0]);
3149 updateblockedcount();
3150 continue;
3151 }
3152
3153 // if hide all photos option has specifically been ticked
3154 //if(fbpoptsobj.sharedphoto && fbpoptsobj.uploadedphoto && fbpoptsobj.taggedlikescommentphoto && fbpoptsobj.taggedalbum)
3155 if((typeof fbpoptsobj.hideallphotos!=='undefined') && fbpoptsobj.hideallphotos)
3156 if(!window.location.href.match(/facebook\.com\/\?sk=app_2305272732_2392950137/))
3157 if(storynodes[i].getElementsByClassName('photoRedesign').length) {
3158 storynodes[i].setAttribute('class',storynodes[i].getAttribute('class')+' fbpblockedx');
3159 filtermatchmsg(storynodes[i],' FBP : Story Type Filter Match - Hide All Photos');
3160 updateblockedcount();
3161 continue;
3162 }
3163
3164 if((typeof fbpoptsobj.hideallvideos!=='undefined') && fbpoptsobj.hideallvideos) {
3165 //if(!window.location.href.match(/facebook\.com\/\?sk=app_2305272732_2392950137/))
3166 if(storynodes[i].getElementsByClassName('uiVideoThumb').length) {
3167 storynodes[i].setAttribute('class',storynodes[i].getAttribute('class')+' fbpblockedx');
3168 filtermatchmsg(storynodes[i],' FBP : Story Type Filter Match - Hide All Videos');
3169 updateblockedcount();
3170 continue;
3171 }
3172 }
3173 else if ((typeof fbpoptsobj.sharedvideo!=='undefined') &&fbpoptsobj.sharedvideo){
3174 var svid=storynodes[i].getElementsByClassName('shareMediaVideo');
3175 if(svid.length)
3176 if(svid[0].getAttribute('href') && svid[0].getAttribute('href').match(/facebook\.com\/video\/video\.php/)) {
3177 storynodes[i].setAttribute('class',storynodes[i].getAttribute('class')+' fbpblockedx');
3178 filtermatchmsg(storynodes[i],' FBP : Story Type Filter Match - Hide Shared Video');
3179 updateblockedcount();
3180 svid=null;
3181 continue;
3182 }
3183 }
3184
3185 // probably could get rid of this bracket... (it used to be part of a big if/else statement
3186 {
3187 // so far it looks like a normal story, but lets check if its been posted by an application
3188 //unsafeWindow.console.log("normal?:" + storynodes[i].getElementsByClassName('uiStreamSource')[0].textContent);
3189 blockit=0;
3190
3191 // these 3 blocks of code need to be refactored
3192 attribnode=storynodes[i].getElementsByClassName('UIIntentionalStory_BottomAttribution');
3193 if(attribnode && attribnode.length) {
3194 attribnode=attribnode[0];
3195 if(attribnode.innerHTML.match(/\?id=(\d+)\"/)) {
3196 attribappid=attribnode.innerHTML.match(/\?id=(\d+)\"/)[1];
3197 if(attribappid){
3198 if(!arrwhitelist2[attribappid])
3199 blockit=1; // its not in the whitelist so block it
3200 }
3201 }
3202 }
3203
3204 attribnode2=storynodes[i].getElementsByClassName('GenericStory_BottomAttribution');
3205 if(attribnode2 && attribnode2.length) { // GenericStory
3206 attribnode2=attribnode2[0];
3207 if (attribnode2.innerHTML.match(/id=(\d+)/)) {
3208 attribappid=attribnode2.innerHTML.match(/id=(\d+)/)[1];
3209 if(attribappid){
3210 if(!arrwhitelist2[attribappid])
3211 blockit=1; // its not in the whitelist so block it
3212 }
3213 }
3214 }
3215
3216 attribnode3=storynodes[i].getElementsByClassName('uiStreamSource');
3217 if(attribnode3 && attribnode3.length) {
3218 attribnode3=attribnode3[0];
3219 if (attribnode3.innerHTML.match(/php\?id=(\d+)\"|\&quot\;app_id\&quot\;\:(\d+)\,/)) {
3220 if(typeof attribnode3.innerHTML.match(/php\?id=(\d+)\"|\&quot\;app_id\&quot\;\:(\d+)\,/)[1] !='undefined')
3221 attribappid=attribnode3.innerHTML.match(/php\?id=(\d+)\"|\&quot\;app_id\&quot\;\:(\d+)\,/)[1];
3222 else if (typeof attribnode3.innerHTML.match(/php\?id=(\d+)\"|\&quot\;app_id\&quot\;\:(\d+)\,/)[2] !='undefined')
3223 attribappid=attribnode3.innerHTML.match(/php\?id=(\d+)\"|\&quot\;app_id\&quot\;\:(\d+)\,/)[2];
3224 if(attribappid){
3225 if(!arrwhitelist2[attribappid])
3226 blockit=1; // its not in the whitelist so block it
3227 }
3228 }
3229 }
3230
3231 attribnode4=storynodes[i].getElementsByClassName('UIActionLinks_bottom');
3232 if(attribnode4 && attribnode4.length) {
3233 attribnode4=attribnode4[0];
3234 if (attribnode4.innerHTML.match(/application.php\?id=(\d+)/)) {
3235 attribappid=attribnode4.innerHTML.match(/application.php\?id=(\d+)/)[1];
3236 if(attribappid){
3237 if(!arrwhitelist2[attribappid])
3238 blockit=1; // its not in the whitelist so block it
3239 }
3240 }
3241 }
3242 // new app checks for fb actions / frictionless sharing apps
3243 var sua=0;
3244 if(storysaction && storysaction.length) {
3245 attribappid=storysaction[0].innerHTML.match(/\/hovercard\/application\.php\?id\=(\d*)/);
3246 if(attribappid) {
3247 if(!arrwhitelist2[attribappid[1]]) {
3248 blockit=1; // its not in the whitelist so block it
3249 sua=1; // sua = started using app?
3250 }
3251 }
3252 else {
3253 if(storynodes[i].getAttribute('data-gt')) {
3254 //"appid":"163114453728333"
3255 if(storynodes[i].getAttribute('data-gt').match(/\"appid\":\"\d+\"/)) {
3256 attribappid=storynodes[i].getAttribute('data-gt').match(/\"appid\":\"(\d+)\"/)[1];
3257 if(!arrwhitelist2[attribappid]) {
3258 blockit=1; // its not in the whitelist so block it
3259 sua=1; // sua = started using app?
3260 }
3261 }
3262 }
3263 }
3264 }
3265
3266 if(blockit) {
3267 // mark app as blocked
3268 storynodes[i].setAttribute('class',storynodes[i].getAttribute('class')+ filterapptext);
3269 if(sua)
3270 dspBlockLink(storynodes[i],"sua");
3271 else
3272 dspBlockLink(storynodes[i]);
3273 }
3274 else {
3275 //its probably a "normal" story node but lets check for attachments (photos or links)
3276 //if ((fbpoptsobj.postedlink || fbpoptsobj.sharedphoto) && (!storynodes[i].getAttribute('class').match(/fbp/)) && storyattachments.length ) {
3277 if (fbpoptsobj.postedlink && (!storynodes[i].getAttribute('class').match(/fbp/)) && storyattachments.length ) {
3278 storyattachment=storyattachments[0];
3279 storylinks=storyattachment.getElementsByTagName('a');
3280 if(storylinks.length) {
3281 storylink=storylinks[0];
3282 if (fbpoptsobj.postedlink && storylink.getAttribute('onclick') && storylink.getAttribute('onclick').match(/^LinkshimAsync/)) {
3283 //its an external link
3284 storynodes[i].setAttribute('class',storynodes[i].getAttribute('class')+' fbpblockedx');
3285 //unsafeWindow.console.log("postedlink= " +fbpoptsobj.postedlink);
3286 //storynodes[i].appendChild(filtermatchmsg(' FBP : Story Type Filter - Shared a link'));
3287 filtermatchmsg(storynodes[i],' FBP : Story Type Filter - Shared a link');
3288 }
3289 /*else if (fbpoptsobj.sharedphoto && storynodes[i].getElementsByClassName('uiPhotoThumb').length) // should we also check for uiMediaThumb ???
3290 // its a shared photo
3291 storynodes[i].setAttribute('class',storynodes[i].getAttribute('class')+' fbpblockedx');*/
3292 else {
3293 storynodes[i].setAttribute('class',storynodes[i].getAttribute('class')+' fbpnormal');
3294 }
3295 }
3296 else {
3297 storynodes[i].setAttribute('class',storynodes[i].getAttribute('class')+' fbpnormal');
3298 }
3299 //else if(storyattachment.getElementsByClassName('uiVideoThumb').length)
3300 //unsafeWindow.console.log(storyattachment.textContent);
3301 //check for attachments
3302 storyattachments={};
3303 storyattachment=null;
3304 }
3305 else
3306 storynodes[i].setAttribute('class',storynodes[i].getAttribute('class')+' fbpnormal');
3307 }
3308 // check for wall posts
3309 if(fbpoptsobj.commentwall && (typeof(storynodes[i])!='undefined') && storynodes[i].getAttribute && storynodes[i].getAttribute('class').match(/fbpnormal/)) {
3310 var wallarrows=storynodes[i].getElementsByClassName('wallArrowIcon');
3311 if(wallarrows.length) {
3312 storynodes[i].setAttribute('class',storynodes[i].getAttribute('class').replace('fbpnormal','') + ' fbpblockedx');
3313 //storynodes[i].setAttribute('class',storynodes[i].getAttribute('class')+' fbpblockedx');
3314 //storynodes[i].appendChild(filtermatchmsg(' FBP : Story Type Filter Match - Commented on Wall'));
3315 filtermatchmsg(storynodes[i],' FBP : Story Type Filter Match - Wrote on Wall');
3316 }
3317 }
3318 }
3319
3320 updateblockedcount();
3321
3322 } // End For Loop through feed nodes
3323
3324 storynodes=null;
3325
3326 }// END cleartheshizzle function
3327
3328
3329 ///////////////////////////////////////
3330 // BEGIN BRING BACK NORMAL COMMENTING
3331 ///////////////////////////////////////
3332 bringbacknormalcommenting = function() {
3333 if(debug)
3334 console.log('inside bring back normal commenting function');
3335
3336 if(typeof(window.navigator.vendor)!='undefined') //fix the stupid comment box growing too much in safari and chrome
3337 if(window.navigator.userAgent.match(/Safari/)) //Apple Computer
3338 //if(window.navigator.userAgent.match(/AppleWebKit/))
3339 if(document.getElementById('fbpfreestyler'))
3340 document.getElementById('fbpfreestyler').textContent += ' textarea.uiTextareaAutogrow {max-height:250px !important}'
3341
3342 fbptasubmit = function (e) {
3343 //console.log(e.target.getAttribute('id'));
3344 //var fbpcta=document.getElementById('x' + e.target.getAttribute('id').split(/butt/)[0]);
3345 var fbpcta=document.querySelector("textarea[data-x-reactid=\""+ e.target.getAttribute('id').split(/butt/)[0] + "\"]"); // getElementById('x' + e.target.getAttribute('id').split(/butt/)[0]);
3346 if(!fbpcta)
3347 return;
3348 //fbpcta.setAttribute('id',fbpcta.getAttribute('id').split(/x/)[1]);
3349 fbpcta.setAttribute('data-reactid',fbpcta.getAttribute('data-x-reactid'));
3350 fbpcta.focus();
3351 e.target.value="Now press 'Enter' to submit your comment";
3352 //e.target.parentNode.style.left="95px"; // width is wrong for photo comments
3353
3354 //if(window.navigator.userAgent.match(/Opera/))
3355 // e.target.removeListener('click',fbtasubmit)
3356 //else
3357 e.target.disabled=true;
3358 if(window.navigator.userAgent.match(/Opera/))
3359 e.target.style.backgroundColor='red !important';
3360 var xnode=fbpcta;
3361 while(xnode.parentNode) {
3362 if(xnode.parentNode.nodeName=="FORM") {
3363 //xnode.parentNode.submit();
3364 //window.Event.__inlineSubmit(xnode.parentNode);
3365 break;
3366 }
3367 xnode=xnode.parentNode
3368 }
3369 }
3370
3371 if (fbpoptsobj.commentbutton) { // when editing a comment, if first key pressed is enter, the text is submitted, if not then it works ok.
3372 if(debug)
3373 console.log('bring back normal commenting function is ENABLED');
3374 window.addEventListener('keydown', function(event) {
3375 if (event.target.tagName && (event.target.tagName=="TEXTAREA")) {
3376 if(event.target.getAttribute('class')) {
3377 event.target.setAttribute('class',event.target.getAttribute('class').replace(/enter_submit/,''));
3378 }
3379 if(event.target.getAttribute('data-reactid')) { // && event.target.getAttribute('id').match(/^\.reactRoot/)
3380 event.target.setAttribute('data-x-reactid',event.target.getAttribute('data-reactid'));
3381 event.target.setAttribute('data-reactid',''); //'x' + event.target.getAttribute('data-reactid'));
3382 var tmph=event.target.parentNode.parentNode.parentNode.getElementsByClassName('monglab');
3383 if(tmph.length) {
3384 tmph[0].getElementsByTagName('input')[0].value='Comment';
3385 //tmph[0].getElementsByTagName('input')[0].parentNode.style.left="250px";
3386 if(window.navigator.userAgent.match(/Opera/))
3387 tmph[0].getElementsByTagName('input')[0].style.backgroundColor="#5B74A8";
3388 tmph[0].getElementsByTagName('input')[0].disabled=false;
3389 // tmph[0].addEventListener('click',fbptasubmit,false);
3390 //else
3391 // tmph[0].getElementsByTagName('input')[0].disabled=false;
3392 }
3393 else {
3394 monglab=document.createElement('label');
3395 //monglab.setAttribute('style','float:right');
3396 monglab.setAttribute('class','monglab mts commentBtn stat_elem optimistic_submit uiButton uiButtonConfirm');
3397 monglab.setAttribute('style','');//position:relative;left:250px // width is wrong for photo comments
3398 monglab.innerHTML='<input value="Comment" class="enter_submit_target" name="comment" type="button" id="' + event.target.getAttribute('data-x-reactid') + 'butt' + '">';
3399 monglab.addEventListener('click',fbptasubmit,false);
3400 event.target.parentNode.parentNode.parentNode.appendChild(monglab);
3401 }
3402 }
3403 }
3404 } , false);
3405
3406 if (document.getElementById('fbpfreestyler'))
3407 document.getElementById('fbpfreestyler').textContent += ' .sendOnEnterTip , .commentUndoTip {display:none !important} .hidden_elem .optimistic_submit, #facebook .child_is_active .hidden_elem.commentBtn, #fbPhotoSnowliftFeedbackInput .hidden_elem.commentBtn {display:block !important;} div.-cx-PRIVATE-fbGiftTodayBirthdaysCoverPhoto__coverBlock {overflow:auto}';
3408
3409 bringbackcommentbuttons=function () {
3410 //deal with the ticker flyout comment boxes
3411 var plops=document.getElementsByClassName('uiContextualDialogPositioner');
3412 var combutts2;
3413 for(var i=0;i<plops.length;i++) {
3414 combutts2=plops[i].getElementsByClassName('optimistic_submit');
3415 if(combutts2.length)
3416 combutts2[0].setAttribute('style','display:block !important');
3417 }
3418 //deal with birthday flyout comment boxes and groups new member boxes
3419 var remconts=document.getElementsByClassName('fbRemindersContent');
3420 if(remconts.length) {
3421 for(var m=0;m<remconts.length;m++) {
3422 plops=remconts[m].getElementsByClassName('pam');
3423 var combutts3,comta;
3424 for(i=0;i<plops.length;i++) {
3425 combutts3=plops[i].getElementsByClassName('hidden_elem');
3426 for(j=combutts3.length-1;j>=0;j--)
3427 if(!combutts3[j].getAttribute('class').match(/highlighterContent/) && (combutts3[j].nodeName!='DIV'))
3428 combutts3[j].setAttribute('class','uiButton uiButtonConfirm');
3429 comta=plops[i].getElementsByClassName('enter_submit');
3430 for(l=comta.length-1;l>=0;l--)
3431 comta[l].setAttribute('class',comta[l].getAttribute('class').replace('enter_submit',''));
3432 }
3433 }
3434 }
3435
3436 // deal with birthdays box in newsfeed itself
3437 var blobuts=document.querySelectorAll('.-cx-PRIVATE-fbGiftTodayBirthdays__list label.hidden_elem');
3438 if(blobuts.length)
3439 for(m=0;m<blobuts.length;m++)
3440 blobuts[m].setAttribute('class','uiButton uiButtonConfirm');
3441
3442 plops=remconts=comta=blobuts=null;
3443 }
3444
3445 bringbackcommentbuttons();
3446
3447 var waitfordom=setInterval(function(){
3448 //clearInterval(waitfordom);
3449 bringbackcommentbuttons();
3450 }, 3000);
3451
3452 } // END IF hide button option has not been selected
3453 else
3454 if(debug)
3455 console.log('bring back normal commenting function is NOT ENABLED');
3456 /////////////////////////////////////
3457 // END BRING BACK NORMAL COMMENTING
3458 /////////////////////////////////////
3459 } // end bringbacknormalcommenting function
3460
3461 function fixexternallinkredirects() {
3462 // fix external link redirects
3463 window.setTimeout(function() {UntrustedLink=null;if(typeof(LinkshimAsyncLink)!='undefined') LinkshimAsyncLink.referrer_log = LinkshimAsyncLink.swap = search_logged_ajax=function(){;};},0);
3464 window.setTimeout(function() {UntrustedLink=null;if(typeof(LinkshimAsyncLink)!='undefined') LinkshimAsyncLink.referrer_log = LinkshimAsyncLink.swap = search_logged_ajax=function(){;};},5000);
3465 window.setInterval(function(){UntrustedLink=null;if(typeof(LinkshimAsyncLink)!='undefined') LinkshimAsyncLink.referrer_log = LinkshimAsyncLink.swap = search_logged_ajax=function(){;};},60000);
3466
3467 unmanglelinks = function(nodetofix) {
3468 //console.log(typeof(nodetofix));
3469 if(typeof(nodetofix)=='undefined')
3470 var nodetofix=document;
3471 if(nodetofix.getElementsByTagName) {
3472 var as=nodetofix.getElementsByTagName('a');
3473 for(var i=0;i<as.length;i++)
3474 if(as[i].href && as[i].href.match(/\/l\.php\?/)) {
3475 as[i].href=decodeURIComponent(as[i].href.match(/\/l\.php\?u=(.*)\&h=/)[1]);
3476 //console.log(decodeURIComponent(as[i].href));
3477 }
3478 }
3479 }
3480 window.setTimeout(unmanglelinks,3000); // run on first load of page
3481 }
3482
3483 // new fix links code>
3484 //as=document.getElementsByTagName('a');for(i=0;i<as.length;i++)if(as[i].href.match(/\/l\.php/))console.log(as[i].href)
3485
3486
3487 // this function is duplicated, as it is also injected into the page's dom, so it can run from there too
3488 unmanglelinks = function(nodetofix) {
3489 //console.log('unmanglelinks');
3490 if(typeof(nodetofix)=='undefined')
3491 var nodetofix=document;
3492 if(nodetofix.getElementsByTagName) {
3493 var as=nodetofix.getElementsByTagName('a');
3494 for(var i=0;i<as.length;i++) {
3495 //if(as[i].href.match(/l\.php/)) console.log((as[i].href));
3496 if(as[i].href.match(/\/l\.php\?u=(.*)\&h=/)) {
3497 as[i].href=decodeURIComponent(as[i].href.match(/\/l\.php\?u=(.*)\&h=/)[1]);
3498 //console.log(decodeURIComponent(as[i].href));
3499 }
3500 }
3501 }
3502 }
3503 // END Duplicated function
3504
3505 ////////////////////////////////////////////////////////////////
3506 // BEGIN FUNCTION deleterecentactivitymodule
3507 // function deleterecentactivitymodule is just a wrapper for the code, so we can inject it into the fb page
3508 function deleterecentactivitymodule () {
3509
3510 /* BEGIN HISTORY STATE CHANGE HANDLER */
3511 (function(history){
3512 var pushState = history.pushState;
3513 history.pushState = function(state) {
3514 if (typeof history.onpushstate == "function") {
3515 history.onpushstate({state: state});
3516 }
3517 // ... whatever else you want to do
3518 // maybe call onhashchange e.handler
3519 //console.log('history state changed:' + arguments[0]);
3520 // experiment to disable theatre mode
3521 //if(arguments[0].match(/\/photo\.php\?.*\&theater/))
3522 // location.href=arguments[0];
3523
3524 /* facebook has now added an event delete button
3525 if(arguments[0].match(/\/events\//)) {
3526 setTimeout(deleventbutt,3000);
3527 }
3528 */
3529 if(arguments[0].match(/facebook\.com\/?$|\/\?sk=/)) {
3530 window.setTimeout(fixsortorder,5500); // this line stops image viewer from working properly if the "if statement" above is not there
3531 }
3532 else if(arguments[0].match(/\/appcenter\/|\/dialog\/oauth\//)) {
3533 window.setTimeout(highlightemailrequest,6500);
3534 window.setTimeout(addblockapplinktoapppage,6500);
3535 window.setTimeout(addblockbuttontopermreq,6500)
3536 }
3537
3538
3539 //console.dir(arguments[0]);
3540 return pushState.apply(window.history, arguments);
3541 }
3542 })(window.history);
3543 /* END HISTORY STATE CHANGE HANDLER*/
3544
3545 }
3546 // END FUNCTION deleterecentactivitymodule
3547
3548 addexternallinkfix = function() {
3549 /////////////////////////////////////////////////////////////
3550 // BEGIN inject deleterecentactivitymodule code into fb page
3551 var scriptx = document.createElement('script');
3552 scriptx.setAttribute('id','scriptx');
3553 if(fbpoptsobj.fixarticleredirects) // fix external link redirects
3554 scriptx.appendChild(document.createTextNode('('+ fixexternallinkredirects +')();'));
3555
3556 scriptx.appendChild(document.createTextNode('('+ deleterecentactivitymodule +')();'));
3557
3558 (document.head || document.body || document.documentElement).appendChild(scriptx);
3559 // END inject deleterecentactivitymodule code into fb page
3560 ////////////////////////////////////////////////////////////////
3561 }
3562
3563 addblockbuttontopermreq = function() {
3564 //console.log("in addblockbuttontopermreq function");
3565 buttbars=document.getElementsByClassName('platform_dialog_buttons');
3566 if(!buttbars.length)
3567 buttbars=document.getElementsByClassName('rightContent');
3568 if(!buttbars.length)
3569 buttbars=document.getElementsByClassName('uiOverlayFooterButtons');
3570 if(buttbars.length) {
3571 buttbar=buttbars[0];
3572 //if(location.href.match(/client_id=/)
3573 //var bappid=window.location.href.match(/[client|app]_id=(\d*)/)[1];
3574 var bappid;
3575 if(document.getElementById('input_app_id'))
3576 bappid=document.getElementById('input_app_id').getAttribute('value');
3577 else if (document.getElementsByClassName('legalese').length) {
3578 var legas=document.getElementsByClassName('legalese')[0].getElementsByTagName('a');
3579 if(legas.length)
3580 for(var v=legas.length-1;v>=0;v--)
3581 if(legas[v].getAttribute('ajaxify').match(/cid=(\d+)/)) {
3582 bappid=legas[v].getAttribute('ajaxify').match(/cid=(\d+)/)[1];
3583 break;
3584 }
3585 }
3586 else if (document.getElementsByName('app_id').length ){
3587 bappid=document.getElementsByName('app_id')[0].getAttribute('value');
3588 }
3589
3590 var titleclass=document.getElementsByClassName('fsxl');
3591 if(titleclass.length)
3592 var bapname=titleclass[0].textContent;
3593 else
3594 if(document.getElementById('permPanel'))
3595 bapname=document.getElementById('permPanel').getElementsByTagName('b')[0].textContent;
3596 else if (document.getElementsByClassName('permissions_app_name').length)
3597 bapname=document.getElementsByClassName('permissions_app_name')[0].textContent;
3598 else
3599 var bapname="Application";
3600 /*
3601 blahlink=document.createElement('a');
3602 blahlink.setAttribute('ajaxify','/ajax/apps/block_app.php?app_id=' + bappid + '&type_index=0&source=about&confirm_id=block_app_link');
3603 blahlink.setAttribute('rel','dialog');
3604 blahlink.setAttribute('id','js_3');
3605 blahlink.style.marginLeft='4px';
3606
3607 blahlab=document.createElement('label');
3608 blahlab.setAttribute('class','uiButton uiButtonConfirm uiButtonLarge');
3609 blahlab.setAttribute('id','blockapplab');
3610 blahlab.setAttribute('appid',bappid);
3611 blahlab.setAttribute('appname',bapname);
3612 blahlab.setAttribute('nodeid','platform_dialog_content'); //globalContainer
3613 //blahlab.setAttribute('style','position:absolute;top:-15px;left:520px');
3614 blahlab.setAttribute('title','Block this application with F.B. Purity');
3615 //blahlab.innerHTML='<input value="Block App" name="block" type="button" id="appblocker">';
3616 blahlab.innerHTML='<span style="color:white">Block</span>';//<div id="block_app_link"><a style="color:white" rel="dialog" ajaxify="/ajax/apps/block_app.php?app_id=' + bappid + '&type_index=0&source=about&confirm_id=block_app_link" href="#" id="js_3" class="">Block</a></div>';
3617 blahlink.appendChild(blahlab);
3618 // new block code, get id of cancel_click button, and click it to close dialog
3619 //<div id="block_app_link"><a style="color:white" rel="dialog" ajaxify="/ajax/apps/block_app.php?app_id=182901371776451&amp;type_index=0&amp;source=about&amp;confirm_id=block_app_link" href="#" id="js_3" class="">Block</a></div>
3620
3621 buttbox=document.getElementsByClassName('rightContent');
3622 if(buttbox.length)
3623 buttbox[0].appendChild(blahlink);
3624 else {
3625 buttbox2=document.getElementsByClassName('platform_dialog_buttons');
3626 if(buttbox2.length)
3627 buttbox2[0].appendChild(blahlink);
3628 }
3629 */
3630
3631 /* BEGIN NEW / OLD CODE */
3632 /* ---------------------*/
3633 blahlab=document.createElement('label');
3634 blahlab.setAttribute('class','uiButton uiButtonConfirm uiButtonLarge');
3635 blahlab.style.marginLeft="2px";
3636 blahlab.setAttribute('id','blockapplab');
3637 blahlab.setAttribute('appid',bappid);
3638 blahlab.setAttribute('appname',bapname);
3639 if(document.getElementById('platform_dialog_content'))
3640 blahlab.setAttribute('nodeid','platform_dialog_content');//globalContainer
3641 else if(document.getElementsByClassName('tosPane').length)
3642 document.getElementsByClassName('tosPane')[0].setAttribute('id','platform_dialog_content');
3643 else if (document.getElementById('platformDialogForm'))
3644 blahlab.setAttribute('nodeid','platformDialogForm');
3645
3646 //blahlab.setAttribute('style','position:absolute;top:-15px;left:520px');
3647 blahlab.setAttribute('title','Block this application with F.B. Purity');
3648 blahlab.innerHTML='<input value="Block App" name="block" type="button" id="appblocker">';
3649 //document.getElementById('content').appendChild(blahlab);
3650
3651
3652 /*buttbox=document.getElementsByClassName('rightContent');
3653 if(buttbox.length)
3654 buttbox[0].appendChild(blahlab);
3655 else {
3656 buttbox2=document.getElementsByClassName('platform_dialog_buttons');
3657 if(buttbox2.length)
3658 buttbox2[0].appendChild(blahlab);
3659 }
3660 */
3661
3662 buttbar.appendChild(blahlab);
3663
3664 if(document.getElementById('appblocker'))
3665 document.getElementById('blockapplab').addEventListener('click',blockappev,false);
3666 /* -------------------*/
3667 /* END NEW / OLD CODE */
3668
3669 //if(document.getElementById('appblocker'))
3670 // document.getElementById('blockapplab').addEventListener('click',blockappev,false);
3671
3672 //if((!location.href.match(/www\.facebook\.com\/connect\/uiserver\.php/)) && document.getElementById('block_app_link')) // hide the original dialog only if we are not in a frame on another site, otherwise we lose the block dialog too
3673 // document.getElementById('block_app_link').addEventListener('click',function() { document.getElementById('cancel_clicked').click();},false);
3674
3675 // if requesting permission to send direct emails, warn user by highlighting it
3676 highlightemailrequest();
3677 }
3678 }
3679
3680 highlightemailrequest = function() {
3681 if(debug)
3682 console.log('in highlightemailrequest function');
3683 // if a facebook application is requesting the users email address highlight it
3684 var appperms=document.getElementsByClassName('gdp_list_item');
3685 if(appperms.length)
3686 for(var i=0;i<appperms.length;i++) {
3687 if(appperms[i].getElementsByClassName('send-email-change-link').length)
3688 appperms[i].setAttribute('style', 'border:4px solid red');
3689 if(appperms[i].textContent.match(/Post on my behalf/))
3690 appperms[i].setAttribute('style', 'border:4px solid red');
3691 }
3692 var emailperms=document.getElementsByTagName('input');
3693 if(emailperms.length)
3694 for(i=0;i<emailperms.length;i++)
3695 if(emailperms[i].getAttribute('name')=='GdpEmailBucket_grantEmailType')
3696 emailperms[i].parentNode.setAttribute('style', 'border:4px solid red');
3697 if(document.getElementsByClassName && document.getElementsByClassName('gdp_right_container').length && document.getElementsByClassName('gdp_right_container')[0].getElementsByClassName('mbm').length)
3698 document.getElementsByClassName('gdp_right_container')[0].getElementsByClassName('mbm')[0].setAttribute('style','border:4px solid red; color:black !important'); // ( can post as you )
3699 if(document.getElementsByClassName && document.getElementsByClassName('permissionsPublishActionsBadge').length)
3700 document.getElementsByClassName('permissionsPublishActionsBadge')[0].setAttribute('style','border:4px solid red');
3701 if(document.getElementsByClassName('tosPane').length) {
3702 var tossas=document.getElementsByClassName('tosPane')[0].getElementsByTagName('a');
3703 for(i=0;i<tossas.length;i++)
3704 if(tossas[i].getAttribute('href') && tossas[i].getAttribute('href').match(/about\/privacy\/your-info-on-other\#applications/)) {
3705 if(!tossas[i].parentNode.textContent.match(tossas[i].getAttribute('aria-label'))) {
3706 tossas[i].parentNode.appendChild(document.createTextNode(' - ' + tossas[i].getAttribute('aria-label') ));
3707 break;
3708 }
3709 }
3710 }
3711 tossas=appperms=emailperms=null;
3712
3713 // test why the button doesnt show up sometimes...
3714 //console.log(location.href.match(/facebook\.com\/appcenter\//));
3715 //console.log(location.href.match(document.getElementsByClassName('mll').length));
3716
3717 // add prominent block app button to app center app pages
3718 if((window.location.href.match(/facebook\.com\/appcenter\//) || document.getElementsByTagName('body')[0].getAttribute('class').match(/app_center/)) && document.getElementsByClassName('mll').length) // if theres buttons {
3719 if(document.getElementById('block_app_link') && !document.getElementById('block_app_link2')) {
3720 var aja=document.getElementById('block_app_link').getElementsByTagName('a')[0].getAttribute('ajaxify');
3721 var ajatext=document.getElementById('block_app_link').getElementsByTagName('a')[0].textContent;
3722 var ajalab=document.createElement('label');
3723 ajalab.setAttribute('class','uiButton uiButtonConfirm uiButtonLarge');
3724 ajalab.setAttribute('id','block_app_link2');
3725 ajalab.setAttribute('title','Block this application with FB Purity');
3726 ajalab.style.color='white';
3727 ajalab.textContent= ajatext + ' App';
3728 var ajalink=document.createElement('a');
3729 ajalink.setAttribute('ajaxify',aja.replace('block_app_link','block_app_link2'));
3730 ajalink.setAttribute('href','#');
3731 ajalink.setAttribute('rel','dialog-post');
3732 ajalink.setAttribute('role','button');
3733 ajalink.appendChild(ajalab);
3734 document.getElementsByClassName('mll')[0].setAttribute('class','mll');
3735 document.getElementsByClassName('mll')[0].appendChild(document.createTextNode(' '));
3736 document.getElementsByClassName('mll')[0].appendChild(ajalink);
3737 }
3738 if(window.location.href.match(/facebook\.com\/appcenter\/?/) || document.getElementsByTagName('body')[0].getAttribute('class').match(/app_center/)) {
3739 // add BA (and eventually WL) links to all app listings in app center (this part is a work in progress/not completed yet)
3740 if(document.getElementsByClassName('appsListHeader').length) {
3741 topspan=document.createElement('span');
3742 topspan.setAttribute('style','color:red;font-weight:bold;margin-left:10px')
3743 topspan.setAttribute('id','block_app_link');
3744 document.getElementsByClassName('appsListHeader')[0].appendChild(topspan);
3745
3746 var appslist = document.getElementsByClassName('appsListItem');
3747
3748 for(i=0;i<appslist.length;i++) {
3749 tspan=document.createElement('div');
3750 tspan.setAttribute('class','uiPopover appFeedbackMenu');
3751 tspan.setAttribute('style','top:18px');
3752 if(appslist[i].getAttribute('data-gt'))
3753 appid=appslist[i].getAttribute('data-gt').match(/appid":"(\d+)"/)[1]; //match(/appid\&quot;:\&quot;(\d+)\&quot;/)[1]
3754 else
3755 appid=appslist[i].querySelector('a[data-gt]').getAttribute('data-gt').match(/appid":"(\d+)"/)[1]; //match(/appid\&quot;:\&quot;(\d+)\&quot;/)[1]
3756 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>';
3757 appslist[i].getElementsByClassName('appName')[0].appendChild(tspan);
3758 }
3759
3760 }
3761 }
3762
3763 } // END highlightemailrequest function
3764
3765 /*BEGIN Check if this page is an authorise app page so we can add a block button
3766 Example URLS https://www.facebook.com/connect/uiserver.php?app_id=216694208368074
3767 Scenarios: oauth page / request permissions page / app page
3768 */
3769 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/))
3770 //if(!window.navigator.userAgent.match(/Opera\//))
3771 // addblockbuttontopermreq();
3772 //else
3773 window.setTimeout(addblockbuttontopermreq,10000); // pause a while because we are now running the script before the dom is fully loaded for all browsers...
3774
3775 if(window.location.href.match(/\/appcenter\/?/))
3776 window.setTimeout(highlightemailrequest,10000);
3777 /* END Check if this page is an authorise app page so we can add a block button */
3778
3779 /* BEGIN add a "block application" link at the bottom left hand corner of all application pages */
3780 function addblockapplinktoapppage() {
3781 if (window.location.href.match(/\:\/\/apps\./)) {
3782 if(document.getElementById('footerContainer')) {
3783 var footzer=document.getElementById('footerContainer');
3784 var footytxt='footerContainer';
3785 }
3786 else {
3787 var footzer=document.getElementById('pagelet_canvas_footer_content');
3788 var footytxt='pagelet_canvas_footer_content';
3789 }
3790 if(footzer) {
3791 var fas=footzer.getElementsByTagName('a');
3792 for(var i=0;i<fas.length;i++)
3793 if(fas[i].getAttribute('ajaxify') && fas[i].getAttribute('ajaxify').match(/\/ajax\/report\.php\?content_type=17/)) {
3794 zappid=fas[i].getAttribute('ajaxify').match(/cid=(\d*)/)[1];
3795 zapplink=document.createElement('a');
3796 zapplink.textContent='Block Application ';
3797 zapptitle=document.getElementById(footytxt).getElementsByTagName('span')[0].textContent;
3798 zapplink.setAttribute('appname',zapptitle);
3799 zapplink.setAttribute('appid',zappid);
3800 zapplink.setAttribute('nodeid','pagelet_canvas_content');
3801 zapplink.setAttribute('id','zapplink');
3802 zapplink.setAttribute('title','Block this application with F.B. Purity');
3803 zparent=document.getElementById(footytxt).getElementsByClassName('fsm')[0];
3804 zparent.insertBefore(zapplink,zparent.firstChild);
3805 document.getElementById('zapplink').addEventListener('click',blockappev,false);
3806 break;
3807 }
3808 }
3809 }
3810 }
3811 window.setTimeout(addblockapplinktoapppage,13000); // needed to make the delay longer, because we are starting the script before the dom has loaded
3812 /* END Add a block application link at bottom left of all application pages */
3813
3814 function toggletimeline(ev) {
3815 var TLBUTT=document.getElementById('TLJewel');
3816 if (typeof(fbpoptsobj.timelineonecol)=='undefined')
3817 fbpoptsobj.timelineonecol=true;
3818 else
3819 if(fbpoptsobj.timelineonecol==true)
3820 fbpoptsobj.timelineonecol=false;
3821 else
3822 fbpoptsobj.timelineonecol=true;
3823 if(fbpoptsobj.timelineonecol==false) {
3824 document.getElementById('FBTLX').style.display='none';
3825 var tdotxt='F.B. Purity - Normal Facebook Timeline Layout Restored';
3826 TLBUTT.setAttribute('title','');
3827 }
3828 else {
3829 document.getElementById('FBTLX').style.display='block';
3830 var tdotxt='F.B. Purity - Single Column Timeline<br/>Layout Enabled';
3831 TLBUTT.setAttribute('title','');
3832 }
3833 if(!document.getElementById('tdotxt')) {
3834 tdo=document.createElement('div');
3835 tdo.setAttribute('id','tdotxt');
3836 tdo.setAttribute('style','position:absolute;top:25px;left:29px;font-size:15px;width:235px;background-color:white;border:2px solid;z-index:30'); //rgba(255,255,255,0.5)
3837 document.getElementById('TLJewel').appendChild(tdo);
3838 }
3839 else
3840 tdo=document.getElementById('tdotxt');
3841
3842 document.getElementById('tdotxt').style.display='block';
3843 tdo.innerHTML='<a title="FB Purity Website" alt="FB Purity Website" href="http://fbpurity.com"><img style="border:0px;float:left;margin-right:10px" src="https://sites.google.com/site/st333v/fbp-1/fbp-ghost-lid-icon-48x48.jpg"></a> ' + tdotxt;
3844 window.setTimeout(function(){document.getElementById('tdotxt').style.display='none';TLBUTT.setAttribute('title','F.B. Purity: Single Column Timeline Layout');},1700)
3845
3846 //save to prefs obj to localstorage
3847 fbpsavevalue('fbpoptsjson-' + currentuserid, JSON.stringify(fbpoptsobj));
3848 //window.location.reload();
3849 fbptimelinerestyle(fbpoptsobj.timelineonecol);
3850 } // END toggletimeline function
3851
3852 function tlbuttinit() {
3853 // BEGIN add TL (single column timeline) button next to search box (now works on graph search bar too)
3854 if(fbpoptsobj.timelineonecol==true)
3855 var disx='block';
3856 else
3857 var disx='none';
3858 var TLBUTTHTML='<a id="TLINK" href="javascript:;" class="jewelButton" style="top:3px;max-height:25px;">'+
3859 '<div id="FBTL" style="position:absolute;top:0px;left:0px;background:transparent;font-size:22px !important;font-weight:bold;color:green">TL</div>'+
3860 '<div id="FBTLX" style="' + 'display:' + disx + '; position:absolute;top:0px;left:6px;background:transparent;font-size:22px !important;color:#E80000;font-weight:bold">X</div></a>';
3861 TLBUTT=document.createElement('div');
3862 TLBUTT.setAttribute('class','lfloat fbJewel');
3863 TLBUTT.setAttribute('id','TLJewel');
3864 TLBUTT.setAttribute('title','F.B. Purity: Single Column Timeline Layout');
3865 /*
3866 window.setTimeout(function() {
3867 console.log('delayed??');
3868 if(document.querySelector('body.hasSmurfbar'))
3869 //TLBUTT.setAttribute('style','top:0px;margin-left:3px;vertical-align:middle;font-size:20px;font-color:#173a85;font-weight:bold; left: 614px; top: -20px !important; '); //
3870 document.getElementById('TLJewel').setAttribute('style','top:0px;margin-left:3px;vertical-align:middle;font-size:20px;font-color:#173a85;font-weight:bold; left: 614px; top: -20px !important; '); //
3871 else
3872 //TLBUTT.setAttribute('style','top:0px;margin-left:3px;vertical-align:middle;font-size:20px;font-color:#173a85;font-weight:bold');
3873 document.getElementById('TLJewel').setAttribute('style','top:0px;margin-left:3px;vertical-align:middle;font-size:20px;font-color:#173a85;font-weight:bold');
3874 },3500);
3875 */
3876
3877 TLBUTT.innerHTML=TLBUTTHTML;
3878 window.setTimeout( function(){
3879 var datd=document.getElementById('navSearch');
3880 if(!datd) {
3881 datd=document.querySelector('div[role="search"]');
3882 TLBUTT.setAttribute('style','top:0px;margin-left:3px;vertical-align:middle;font-size:20px;font-color:#173a85;font-weight:bold; left: 614px; top: -20px !important'); //
3883 if(debug) console.log('no navsearch, so must be graph search?' + TLBUTT);
3884 }
3885 else {
3886 TLBUTT.setAttribute('style','top:0px;margin-left:3px;vertical-align:middle;font-size:20px;font-color:#173a85;font-weight:bold;'); // left :0px !important'
3887 if(debug) console.log('oldschool navsearch' + TLBUTT);
3888 }
3889 if(datd && (!document.getElementById('TLJewel'))) {
3890 datd.parentNode.insertBefore(TLBUTT,datd.nextSibling);
3891 document.getElementById('TLINK').addEventListener('click',toggletimeline,false);
3892 }
3893 //single column timeline
3894 if(fbpoptsobj.timelineonecol==1)
3895 fbptimelinerestyle(1);
3896 else
3897 fbptimelinerestyle(0);
3898 },3000);
3899 // END add TL button next to search box
3900 }
3901
3902 function resetclasses () {
3903 var fbpn,a;
3904 var arrResetClasses=['fbpnormal','fbpblockedx','fbpblocked'];
3905 for(a in arrResetClasses) {
3906 //console.log(arrResetClasses[a]);
3907 fbpn=document.getElementsByClassName(arrResetClasses[a]);
3908 for(i=fbpn.length;i>0;i--) {
3909 //console.log(i);
3910 fbpn[i-1].setAttribute('class',fbpn[i-1].getAttribute('class').replace(arrResetClasses[a],''));
3911 }
3912 //console.log("fbpoptsobj.filterappmessages=" + fbpoptsobj.filterappmessages + " current arr length=" + document.getElementsByClassName(arrResetClasses[a]).length);
3913 }
3914 }
3915
3916
3917 ////// BEGIN HIDE STICKER PACK FUNCTIONALITY
3918
3919 // Hide sticker packs functionality
3920 // /* hide Heromals pack*/
3921 // a[data-id="633721996647110"] {display:none !important}
3922
3923 function fbpInsertedStickerStoreHandler(records) { //event // mutationObserverRef
3924 //try{
3925 var q,p,tempnode;
3926 if(records.length) {
3927 for(q=0;q<records.length;q++) {
3928 //if(records[q].addedNodes.length)
3929 for(p=0;p<records[q].addedNodes.length;p++) {
3930 tempnode=records[q].addedNodes[p];
3931 if(tempnode.nodeName=='DIV') //console.log(tempnode);
3932 if(tempnode.getAttribute && tempnode.getAttribute("class")=="_10 uiLayer _4-hy _3qw") {
3933 if(document.getElementById('pagelet_sticker_store_dialog')) {
3934 if(debug)
3935 console.log('found sticker store!!');
3936 managestickerpacks();
3937 }
3938 }
3939 }
3940 }
3941 }
3942 //} catch(e) {
3943 // console.log("something wrong in inserted stickerstorehandler: " + e);
3944 //}
3945 }
3946
3947 function hidestickerpacks() {
3948 if(debug) {
3949 console.log("\nhidestickerpacks function");
3950 console.log("typeof fbpoptsobj:" + typeof(fbpoptsobj));
3951 console.log("typeof fbpoptsobj.stickerpacks:" + typeof(fbpoptsobj.stickerpacks));
3952 console.log("stickerpack ids in fbpoptsobj:\"" + fbpoptsobj.stickerpacks +"\"");
3953 }
3954 if((typeof(fbpoptsobj)=='undefined') || typeof(fbpoptsobj.stickerpacks)=='undefined') {
3955 if(debug)
3956 console.log("fbpoptsobj is not yet defined");
3957 fbpoptsobj.stickerpacks='';
3958 //return;
3959 }
3960 var spar=fbpoptsobj.stickerpacks.split(',');
3961 var stickerpackstyles='';
3962 if(spar.length && (spar[0]!=''))
3963 for(var i=0;i<spar.length;i++)
3964 stickerpackstyles+= 'a[data-id="' + spar[i] + '"] {display:none} ';
3965 else
3966 ; //console.log('array was empty');
3967 if(debug)
3968 console.log(stickerpackstyles);
3969 stickerpackstyle=document.getElementById('stickerpackstyle');
3970 stickerpackstyle.textContent=stickerpackstyles;
3971 }
3972
3973 function hidestickerpackclick(e) {
3974 //console.log('clicked it');
3975 var spid=e.target.getAttribute('id');
3976 if(debug) {
3977 console.log("\nhidestickerpackclick function");
3978 }
3979
3980 if(e.target.checked) {
3981 if(!fbpoptsobj.stickerpacks.match("'" + spid +"'")) {
3982 if(fbpoptsobj.stickerpacks.length)
3983 fbpoptsobj.stickerpacks+=',' + spid;
3984 else
3985 fbpoptsobj.stickerpacks+= spid;
3986 }
3987 }
3988 else {
3989 fbpoptsobj.stickerpacks=fbpoptsobj.stickerpacks.replace(spid,'');
3990 fbpoptsobj.stickerpacks=fbpoptsobj.stickerpacks.replace(/,,/,',');
3991 fbpoptsobj.stickerpacks=fbpoptsobj.stickerpacks.replace(/(^,|,$)/,'');
3992 }
3993 //console.log(fbpoptsobj.stickerpacks);
3994
3995 //save prefs obj to localstorage
3996 fbpsavevalue('fbpoptsjson-' + currentuserid, JSON.stringify(fbpoptsobj));
3997
3998 hidestickerpacks();
3999 }
4000
4001 // BEGIN init stickerpack variables
4002 var stickerpackstyle;
4003 var stickyobject={};
4004
4005 function managestickerpacks() {
4006
4007 // BEGIN cache current stickerpacks
4008 if(typeof(stickyobject.ready)=='undefined') {
4009 var stickerpackbar=document.getElementsByClassName('_590r');
4010 if(!stickerpackbar.length) {
4011 console.log('couldnt find stickerpack bar, maybe the class name has changed');
4012 return;
4013 }
4014
4015 var stickypacks=stickerpackbar[0].getElementsByClassName('_55bn')
4016 if(!stickypacks.length) {
4017 console.log('couldnt find individual sticker packs in stickerpack bar, maybe the class name has changed')
4018 return;
4019 }
4020
4021 for(var i=0;i<stickypacks.length-1;i++) {
4022 if(debug)
4023 console.log(stickypacks[i].getAttribute('aria-label') + ':' + stickypacks[i].getAttribute('data-id'))
4024 stickyobject[stickypacks[i].getAttribute('aria-label')]=stickypacks[i].getAttribute('data-id');
4025 }
4026 }
4027 stickyobject.ready=1;
4028 // END cache current stickerpacks
4029
4030 var spboxes=document.getElementsByClassName('_5b2l');
4031 if(!spboxes.length) {
4032 console.log('didnt find the stickerpack boxes in the stickerstore')
4033 return;
4034 }
4035 if(!spboxes[0].getElementsByClassName('_5b2r').length) {
4036 console.log('we didnt find the stickerpack names in the stickerpack store, maybe the class name has changed.')
4037 return;
4038 }
4039
4040 var spcheckboxspan=document.createElement('span');
4041 spcheckboxspan.setAttribute('title','Hide sticker pack with with FB Purity.');
4042 var sptextnode=document.createTextNode(' Hide');
4043 spcheckboxspan.appendChild(sptextnode);
4044 var spcheckbox=document.createElement('input');
4045 spcheckbox.setAttribute('type','checkbox');
4046 spcheckbox.setAttribute('style','vertical-align:middle');
4047 spcheckboxspan.appendChild(spcheckbox);
4048
4049 for(var i=0;i<spboxes.length;i++) {
4050 if(typeof (stickyobject[ spboxes[i].getElementsByClassName('_5b2r')[0].textContent ])!='undefined') {
4051 spboxes[i].getElementsByClassName('mts rfloat')[0].appendChild(spcheckboxspan.cloneNode(1));
4052 spboxes[i].getElementsByTagName('input')[0].setAttribute('id',stickyobject[spboxes[i].getElementsByClassName('_5b2r')[0].textContent]);
4053 spboxes[i].getElementsByTagName('input')[0].addEventListener('click',hidestickerpackclick,false);
4054 if(fbpoptsobj && fbpoptsobj.stickerpacks && fbpoptsobj.stickerpacks.length)
4055 if(fbpoptsobj.stickerpacks.match(stickyobject[spboxes[i].getElementsByClassName('_5b2r')[0].textContent]))
4056 spboxes[i].getElementsByTagName('input')[0].checked=true;
4057 }
4058 }
4059 } // end managestickerpacks function
4060
4061 ////// END HIDE STICKER PACK FUNCTIONALITY
4062
4063 function fbpurify() {
4064 if(debug)
4065 console.trace();
4066
4067 var crappyappmsgcounter=0;
4068 var xtramsgcounter=0;
4069 fbpstyle.setAttribute('id','fbpstyler');
4070 fbpstyle.setAttribute('type','text/css');
4071 fbpStyleApps= ".fbpblocked {border-style: dashed !important; border-width:1px !important; border-top: 0px !important; border-color: pink !important; display:block !important} .fbpblockedx {display:none !important} .fbpnormal {display:none !important}";
4072 if(document.querySelector('body.hasSmurfbar'))
4073 fbpStyleExtras= ".fbpblocked {display:none !important} .fbpblockedx {border-style: dashed !important; border-width:1px !important; border-top: 0px !important; border-color: blue !important; display:block !important} .fbpnormal {display:none !important}";
4074 else
4075 fbpStyleExtras= ".fbpblocked {display:none !important} .fbpblockedx {border-style: dashed !important; border-width:1px !important; border-top: 0px !important; border-color: lightblue !important; display:block !important} .fbpnormal {display:none !important}";
4076 fbpStyleNormal= ".fbpblocked {display:none !important} .fbpblockedx {display:none !important} .fbpnormal {display:block !important}";
4077 fbpstyle.textContent=fbpStyleNormal;
4078
4079 document.addEventListener("DOMNodeInserted", fpInsertedNodeDomHandler, false);
4080
4081 if(document.getElementById('pagelet_home_stream') || document.getElementById('pagelet_litestand_section') || document.getElementById('stream_pagelet'))
4082 cleartheshizzle(document);
4083
4084 } // END fbpurify function
4085
4086 // only run if DOM has loaded
4087 finalstage=function () {
4088 // we should check to see if fbpurify is already running...
4089
4090 if(document.getElementsByTagName('head').length) {
4091 if(!document.getElementById('stickerpackstyle')) {
4092 stickerpackstyle=document.createElement('style');
4093 stickerpackstyle.setAttribute('id','stickerpackstyle');
4094 }
4095 document.getElementsByTagName('head')[0].appendChild(fbpstyle);
4096 document.getElementsByTagName('head')[0].appendChild(fbpfreestyle);
4097 document.getElementsByTagName('head')[0].appendChild(fbpboxstyle);
4098 document.getElementsByTagName('head')[0].appendChild(fbpcssstyle);
4099 document.getElementsByTagName('head')[0].appendChild(fbptlstyle);
4100 document.getElementsByTagName('head')[0].appendChild(stickerpackstyle);
4101
4102 //window.setTimeout(bringbacknormalcommenting,2000); // prefs werent being read in before running this, so i added a short delay
4103 bringbacknormalcommenting();
4104 //window.setTimeout(addexternallinkfix,2000);
4105 addexternallinkfix();
4106 tlbuttinit(); // initialise the timeline single column button
4107 window.setTimeout(fixsortorder,6000);
4108 hidestickerpacks();
4109 }
4110 else {
4111 var waitforhead=setInterval(function(){
4112 if(document.getElementsByTagName('head').length ) {
4113 if(!document.getElementById('stickerpackstyle')) {
4114 stickerpackstyle=document.createElement('style');
4115 stickerpackstyle.setAttribute('id','stickerpackstyle');
4116 }
4117 document.getElementsByTagName('head')[0].appendChild(fbpstyle);
4118 document.getElementsByTagName('head')[0].appendChild(fbpfreestyle);
4119 document.getElementsByTagName('head')[0].appendChild(fbpboxstyle);
4120 document.getElementsByTagName('head')[0].appendChild(fbpcssstyle);
4121 document.getElementsByTagName('head')[0].appendChild(fbptlstyle);
4122 document.getElementsByTagName('head')[0].appendChild(stickerpackstyle);
4123
4124 //window.setTimeout(bringbacknormalcommenting,2000); // prefs werent being read in before running this, so i added a short delay
4125 bringbacknormalcommenting();
4126 //window.setTimeout(addexternallinkfix,2000);
4127 addexternallinkfix();
4128 tlbuttinit(); // initialise the timeline single column button
4129 hidestickerpacks();
4130 window.setTimeout(fixsortorder,6000);
4131 clearInterval(waitforhead);
4132 }
4133 }, 500);
4134
4135 }
4136
4137 var waitforbody=setInterval(function(){
4138 if(document.getElementsByTagName('body').length) {
4139 //new (this.MutationObserver || this.MozMutationObserver || this.WebKitMutationObserver)(fbpInsertedStickerStoreHandler).observe(document.getElementsByTagName('body')[0], { childList: true, subtree: true }); //document.body
4140 try{
4141 new (MutationObserver || MozMutationObserver || WebKitMutationObserver)(fbpInsertedStickerStoreHandler).observe(document.body, { childList: true, subtree: true }); //document.body
4142 }
4143 catch(e) {
4144 console.log('Mutation Observer not supported');
4145 }
4146 clearInterval(waitforbody);
4147 }
4148 }, 500);
4149
4150 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')
4151 fbpurify();
4152 window.setTimeout(fixsortorder,3000);
4153 }
4154 else {
4155 var waitfordom=setInterval(function(){
4156 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')
4157 clearInterval(waitfordom);
4158 fbpurify();
4159 window.setTimeout(fixsortorder,3000);
4160 }
4161 }, 500);
4162 }
4163 } // end finalstage function;
4164
4165 fbpgetprefs();
4166
4167 })();