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