]> git.rmz.io Git - dotfiles.git/blob - dwb/greasemonkey/ponyhoof.user.js
add awesome mlp theme
[dotfiles.git] / dwb / greasemonkey / ponyhoof.user.js
1 // ==UserScript==
2 // @name Ponyhoof
3 // @namespace http://www.facebook.com/ponyhoof
4 // @run-at document-start
5 // @version 1.631
6 // @installURL https://hoof.little.my/files/ponyhoof.user.js
7 // @updateURL https://hoof.little.my/files/ponyhoof.meta.js
8 // @icon https://hoof.little.my/files/app32.png
9 // @icon64 https://hoof.little.my/files/icon64.png
10 // @description Ponify Facebook and make it 20% cooler!
11 // @author The Ponyhoof Team <pony@little.my> http://ponyhoof.little.my
12 // @developer Ng Yik Phang
13 // @contributor James
14 // @contributor http://ponyhoof.little.my/credits
15 // @homepage http://ponyhoof.little.my
16 // @supportURL http://www.facebook.com/Ponyhoof
17 // @contributionURL http://ponyhoof.little.my/donate
18 // @include http://*.facebook.com/*
19 // @include https://*.facebook.com/*
20 // @include http://*.little.my/*
21 // @include https://*.little.my/*
22 // @match http://*.facebook.com/*
23 // @match https://*.facebook.com/*
24 // @match http://*.little.my/*
25 // @match https://*.little.my/*
26 // @exclude http://*.facebook.com/ai.php*
27 // @exclude http://*.facebook.com/l.php*
28 // @exclude http://*.facebook.com/ajax/*
29 // @exclude http://*.channel.facebook.com/*
30 // @exclude http://static.*.facebook.com/*
31 // @exclude http://graph.facebook.com/*
32 // @exclude http://0.facebook.com/*
33 // @exclude https://*.facebook.com/ai.php*
34 // @exclude https://*.facebook.com/l.php*
35 // @exclude https://*.facebook.com/ajax/*
36 // @exclude https://*.channel.facebook.com/*
37 // @exclude https://s-static.*.facebook.com/*
38 // @exclude https://graph.facebook.com/*
39 // @exclude https://0.facebook.com/*
40 // @exclude https://paste.little.my/*
41 // ==/UserScript==
42
43 /*******************************************************************************
44 * Please visit http://jointheherd.lttle.my for the official install!
45 *******************************************************************************/
46
47
48 (function() {
49 if (window.location.hostname.indexOf('facebook.com') == -1 && window.location.hostname.indexOf('little.my') == -1) {
50 return;
51 }
52
53 /**
54 * Hoof Framework
55 *
56 * @author ngyikp (http://www.facebook.com/ngyikp)
57 */
58 var d = document, w = window;
59 var ELEMENT_NODE = 1;
60 var TEXT_NODE = 3;
61
62 var SIG = '[Hoof Framework]';
63 var FRIENDLYNAME = 'Hoof Framework';
64 var CANLOG = true;
65
66 var userSettings = {};
67
68 var USERAGENT = w.navigator.userAgent.toLowerCase();
69 var ISOPERABLINK = /OPR\//.test(w.navigator.userAgent);
70 var ISOPERA = !ISOPERABLINK && (typeof opera != 'undefined' || /opera/i.test(USERAGENT));
71 var ISCHROME = !ISOPERABLINK && (typeof chrome != 'undefined' || /chrome/i.test(USERAGENT));
72 var ISFIREFOX = /firefox/i.test(USERAGENT);
73 var ISSAFARI = !ISOPERABLINK && !ISCHROME && /safari/i.test(USERAGENT);
74 var ISMOBILE = /iphone|ipad|ipod|android|blackberry|mini|windows\sce|palm/i.test(USERAGENT);
75
76 // R.I.P. unsafeWindow in Chrome 27+ http://crbug.com/222652
77 if (typeof unsafeWindow == 'undefined') {
78 var USW = w;
79 } else {
80 var USW = unsafeWindow;
81 }
82
83 function log(msg) {
84 if (CANLOG) {
85 if (typeof console !== 'undefined' && console.log) {
86 console.log(SIG + ' ' + msg);
87 }
88 }
89 }
90
91 function dir(msg) {
92 if (CANLOG) {
93 if (typeof console !== 'undefined' && console.dir) {
94 console.dir(SIG + ' ' + msg);
95 }
96 }
97 }
98
99 function debug(msg) {
100 if (CANLOG) {
101 if (typeof console !== 'undefined') {
102 if (console.debug) {
103 console.debug(SIG + ' ' + msg);
104 } else if (console.log) {
105 console.log(SIG + ' ' + msg);
106 }
107 }
108 }
109 }
110
111 function info(msg) {
112 if (CANLOG) {
113 if (typeof console !== 'undefined') {
114 if (console.info) {
115 console.info(SIG + ' ' + msg);
116 } else if (console.log) {
117 console.log(SIG + ' ' + msg);
118 }
119 }
120 }
121 }
122
123 function warn(msg) {
124 if (CANLOG) {
125 if (typeof console !== 'undefined') {
126 if (console.warn) {
127 console.warn(SIG + ' ' + msg);
128 } else if (console.log) {
129 console.log(SIG + ' ' + msg);
130 }
131 }
132 }
133 }
134
135 function error(msg) {
136 if (CANLOG) {
137 if (typeof console !== 'undefined') {
138 if (console.error) {
139 console.error(SIG + ' ' + msg);
140 } else if (console.log) {
141 console.log(SIG + ' ' + msg);
142 }
143 }
144 }
145 }
146
147 function trace() {
148 if (CANLOG) {
149 if (typeof console !== 'undefined' && console.trace) {
150 console.trace();
151 }
152 }
153 }
154
155 function $(id) {
156 return d.getElementById(id);
157 }
158
159 function randNum(min, max) {
160 return min + Math.floor(Math.random() * (max - min + 1));
161 }
162
163 function hasClass(ele, c) {
164 if (!ele) {
165 return false;
166 }
167 if (ele.classList) {
168 return ele.classList.contains(c);
169 }
170
171 var regex = new RegExp("(^|\\s)"+c+"(\\s|$)");
172 if (ele.className) { // element node
173 return (ele.className && regex.test(ele.className));
174 } else { // string
175 return (ele && regex.test(ele));
176 }
177 }
178
179 function addClass(ele, c) {
180 if (ele.classList) {
181 ele.classList.add(c);
182 } else if (!hasClass(ele, c)) {
183 ele.className += ' '+c;
184 }
185 }
186
187 function removeClass(ele, c) {
188 if (ele.classList) {
189 ele.classList.remove(c);
190 } else {
191 ele.className = ele.className.replace(new RegExp('(^|\\s)'+c+'(?:\\s|$)','g'),'$1').replace(/\s+/g,' ').replace(/^\s*|\s*$/g,'');
192 }
193 }
194
195 function toggleClass(ele, c) {
196 if (hasClass(ele, c)) {
197 removeClass(ele, c);
198 } else {
199 ele.className += ' ' + c;
200 }
201 }
202
203 function clickLink(el) {
204 if (!el) {
205 return false;
206 }
207
208 try {
209 var evt = d.createEvent('MouseEvents');
210 evt.initMouseEvent('click', true, true, w, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
211 el.dispatchEvent(evt);
212 return true;
213 } catch (e) {
214 return false;
215 }
216 }
217
218 function cookie(n) {
219 try {
220 return unescape(d.cookie.match('(^|;)?'+n+'=([^;]*)(;|$)')[2]);
221 } catch (e) {
222 return null;
223 }
224 }
225
226 function injectManualStyle(css, id) {
227 if ($('ponyhoof_style_'+id)) {
228 return $('ponyhoof_style_'+id);
229 }
230
231 var n = d.createElement('style');
232 n.type = 'text/css';
233 if (id) {
234 n.id = 'ponyhoof_style_'+id;
235 }
236 n.textContent = '/* '+SIG+' */'+css;
237
238 if (d.head) {
239 d.head.appendChild(n);
240 } else if (d.body) {
241 d.body.appendChild(n);
242 } else {
243 d.documentElement.appendChild(n);
244 }
245
246 return n;
247 }
248
249 function fadeOut(ele, callback) {
250 addClass(ele, 'ponyhoof_fadeout');
251
252 w.setTimeout(function() {
253 ele.style.display = 'none';
254
255 if (callback) {
256 callback(ele);
257 }
258 }, 250);
259 }
260
261 function getFbDomain() {
262 if (w.location.hostname == 'beta.facebook.com') {
263 return w.location.hostname;
264 }
265 return 'www.facebook.com';
266 }
267
268 function onPageReady(callback) {
269 var _loop = function() {
270 if (/loaded|complete/.test(d.readyState)) {
271 callback();
272 } else {
273 w.setTimeout(_loop, 100);
274 }
275 };
276 _loop();
277 }
278
279 var loopClassName = function(name, func) {
280 var l = d.getElementsByClassName(name);
281 if (l) {
282 for (var i = 0, len = l.length; i < len; i++) {
283 func(l[i]);
284 }
285 }
286 };
287
288 function $$(parent, query, func) {
289 if (!parent) {
290 return;
291 }
292 var l = parent.querySelectorAll(query);
293 if (l.length) {
294 for (var i = 0, len = l.length; i < len; i++) {
295 func(l[i]);
296 }
297 }
298 }
299
300 // Hacky code adapted from http://www.javascripter.net/faq/browsern.htm
301 function getBrowserVersion() {
302 var ua = w.navigator.userAgent;
303 var fullVersion = ''+parseFloat(w.navigator.appVersion);
304 var majorVersion = parseInt(w.navigator.appVersion, 10);
305 var nameOffset, offset, ix;
306
307 if (ua.indexOf('Opera') != -1) {
308 // In Opera, the true version is after 'Opera' or after 'Version'
309 offset = ua.indexOf('Opera');
310 fullVersion = ua.substring(offset + 6);
311
312 if (ua.indexOf('Version') != -1) {
313 offset = ua.indexOf('Version');
314 fullVersion = ua.substring(offset + 8);
315 }
316 } else if (ua.indexOf('OPR/') != -1) {
317 offset = ua.indexOf('OPR/');
318 fullVersion = ua.substring(offset + 4);
319 } else if (ua.indexOf('MSIE') != -1) {
320 // In MSIE, the true version is after 'MSIE' in userAgent
321 offset = ua.indexOf('MSIE');
322 fullVersion = ua.substring(offset + 5);
323 } else if (ua.indexOf('Chrome') != -1) {
324 // In Chrome, the true version is after 'Chrome'
325 offset = ua.indexOf('Chrome');
326 fullVersion = ua.substring(offset + 7);
327 } else if (ua.indexOf('Safari') != -1) {
328 // In Safari, the true version is after 'Safari' or after 'Version'
329 offset = ua.indexOf('Safari');
330 fullVersion = ua.substring(offset + 7);
331
332 if (ua.indexOf('Version') != -1) {
333 offset = ua.indexOf('Version');
334 fullVersion = ua.substring(offset + 8);
335 }
336 } else if (ua.indexOf('Firefox') != -1) {
337 // In Firefox, the true version is after 'Firefox'
338 offset = ua.indexOf('Firefox');
339 fullVersion = ua.substring(offset + 8);
340 } else {
341 throw "Unsupported browser";
342 }
343
344 if ((ix = fullVersion.indexOf(';')) != -1) {
345 fullVersion = fullVersion.substring(0, ix);
346 }
347 if ((ix = fullVersion.indexOf(' ')) != -1) {
348 fullVersion = fullVersion.substring(0, ix);
349 }
350
351 majorVersion = parseInt(''+fullVersion,10);
352 if (isNaN(majorVersion)) {
353 fullVersion = ''+parseFloat(w.navigator.appVersion);
354 majorVersion = parseInt(w.navigator.appVersion,10);
355 }
356
357 return {
358 major: majorVersion
359 ,full: fullVersion
360 };
361 }
362
363 // http://wiki.greasespot.net/Content_Script_Injection
364 var contentEval = function(source, arg) {
365 var arg = arg || {};
366 if (typeof source === 'function') {
367 source = '(' + source + ')(' + JSON.stringify(arg) + ');'
368 }
369
370 var script = d.createElement('script');
371 script.textContent = source;
372 d.documentElement.appendChild(script);
373 d.documentElement.removeChild(script);
374 };
375
376 var supportsRange = function() {
377 var i = d.createElement('input');
378 i.setAttribute('type', 'range');
379 return i.type !== 'text';
380 };
381
382 var supportsCssTransition = function() {
383 var s = d.createElement('div').style;
384 return ('transition' in s || 'WebkitTransition' in s || 'MozTransition' in s || 'msTransition' in s || 'OTransition' in s);
385 };
386
387 // Menu
388 var MENUS = {};
389 var Menu = function(id, p) {
390 var k = this;
391
392 k.id = id;
393 MENUS['ponyhoof_menu_'+k.id] = k;
394 k.menu = null; // outer wrap
395 k.selectorMenu = null; // .uiMenu.uiSelectorMenu
396 k.menuInner = null; // .uiMenuInner
397 k.content = null; // .uiScrollableAreaContent
398 k.button = null;
399 k.wrap = null; // ponyhoof_menu_wrap, used to separate button and menu
400
401 k.menuSearch = null; // .ponyhoof_menu_search
402 k.menuSearchInput = null;
403 k.menuSearchNoResults = null;
404 k.focusStealer = null;
405
406 k.hasScrollableArea = false;
407 k.scrollableAreaDiv = null; // .uiScrollableArea
408 k.scrollableArea = null; // FB ScrollableArea class
409
410 k.p = p;
411 k.afterClose = function() {};
412
413 k.canSearch = true;
414 k.alwaysOverflow = false;
415 k.rightFaced = false;
416 k.buttonTextClipped = 0;
417
418 k.createButton = function(startText) {
419 if (!startText) {
420 startText = '';
421 }
422
423 var buttonText = d.createElement('span');
424 buttonText.className = 'uiButtonText';
425 buttonText.innerHTML = startText;
426
427 k.button = d.createElement('a');
428 k.button.href = '#';
429 k.button.className = 'uiButton ponyhoof_button_menu';
430 k.button.setAttribute('role', 'button');
431 k.button.setAttribute('aria-haspopup', 'true');
432 if (k.buttonTextClipped) {
433 k.button.className += ' ponyhoof_button_clipped';
434 buttonText.style.maxWidth = k.buttonTextClipped+'px';
435 }
436 k.button.appendChild(buttonText);
437
438 k.wrap = d.createElement('div');
439 k.wrap.className = 'ponyhoof_menu_wrap';
440 if (k.rightFaced) {
441 k.wrap.className += ' uiSelectorRight';
442 }
443 k.wrap.appendChild(k.button);
444 k.p.appendChild(k.wrap);
445
446 return k.button;
447 }
448
449 k.createMenu = function() {
450 if ($('ponyhoof_menu_'+k.id)) {
451 k.menu = $('ponyhoof_menu_'+k.id);
452 k.menuInner = k.menu.getElementsByClassName('uiMenuInner')[0];
453 return k.menu;
454 }
455
456 k.injectStyle();
457
458 k.menu = d.createElement('div');
459 k.menu.className = 'ponyhoof_menu uiSelectorMenuWrapper';
460 k.menu.id = 'ponyhoof_menu_'+k.id;
461 k.menu.setAttribute('role', 'menu');
462 //k.menu.style.display = 'none';
463 k.menu.addEventListener('click', function(e) {
464 e.stopPropagation();
465 return false;
466 }, false);
467 k.wrap.appendChild(k.menu);
468
469 k.selectorMenu = d.createElement('div');
470 k.selectorMenu.className = 'uiMenu uiSelectorMenu';
471 k.menu.appendChild(k.selectorMenu);
472
473 k.menuInner = d.createElement('div');
474 k.menuInner.className = 'uiMenuInner';
475 k.selectorMenu.appendChild(k.menuInner);
476
477 k.content = d.createElement('div');
478 k.content.className = 'uiScrollableAreaContent';
479 k.menuInner.appendChild(k.content);
480
481 if (k.canSearch) {
482 k.menuSearch = d.createElement('div');
483 k.menuSearch.className = 'ponyhoof_menu_search';
484 k.content.appendChild(k.menuSearch);
485
486 k.menuSearchInput = d.createElement('input');
487 k.menuSearchInput.type = 'text';
488 k.menuSearchInput.className = 'inputtext';
489 k.menuSearchInput.placeholder = "Search";
490 k.menuSearch.appendChild(k.menuSearchInput);
491
492 k.menuSearchNoResults = d.createElement('div');
493 k.menuSearchNoResults.className = 'ponyhoof_menu_search_noResults';
494 k.menuSearchNoResults.textContent = "No results";
495 k.menuSearch.appendChild(k.menuSearchNoResults);
496
497 k.menuSearchInput.addEventListener('keydown', k.searchEscapeKey, false);
498 k.menuSearchInput.addEventListener('input', k.performSearch, false);
499
500 k.focusStealer = d.createElement('input');
501 k.focusStealer.type = 'text';
502 k.focusStealer.setAttribute('aria-hidden', 'true');
503 k.focusStealer.style.position = 'absolute';
504 k.focusStealer.style.top = '-9999px';
505 k.focusStealer.style.left = '-9999px';
506 k.focusStealer.addEventListener('focus', k.focusStealerFocused, false);
507 k.selectorMenu.appendChild(k.focusStealer);
508 }
509
510 return k.menu;
511 };
512
513 k.attachButton = function() {
514 k.button.addEventListener('click', function(e) {
515 k.toggle();
516 e.stopPropagation();
517 e.preventDefault();
518 }, false);
519 };
520
521 k.changeButtonText = function(text) {
522 k.button.getElementsByClassName('uiButtonText')[0].innerHTML = text;
523 k.button.setAttribute('data-ponyhoof-button-orig', text);
524 k.button.setAttribute('data-ponyhoof-button-text', text);
525
526 if (k.buttonTextClipped) {
527 k.button.title = text;
528 }
529 };
530
531 k.createSeperator = function() {
532 var sep = d.createElement('div');
533 sep.className = 'uiMenuSeparator';
534 k.content.appendChild(sep);
535 };
536
537 k.createMenuItem = function(param) {
538 var menuItem = new MenuItem(k);
539 menuItem._create(param);
540
541 k.content.appendChild(menuItem.menuItem);
542
543 return menuItem;
544 };
545
546 k.injectStyle = function() {
547 var css = '';
548 css += 'html .ponyhoof_dialog .ponyhoof_button_menu, .ponyhoof_menuitem_checked {background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAfQAAADdCAYAAABNAoDAAAADbElEQVR42u3Xv06aARTG4XN93oYm7eDgakw7OXsD3oBpByevBhRKVVSooIDrKR9TGxOhSRM5n8+T/MKf8C1neUMkAFBeLF5eUpIk1S4W80VKkqTaxXw+T0mSVLuYzeYpSZJqF7PnWUqSpNrF0/NTSpKk2sX0aZqSJKl2MZ0u30iSpHdtZ+90bW89H5PJJCVJ0vu3e3iWRycXr2q+X/dsPD7+SkmStB19/vr9rzFvPm/yXIzH45QkSdvTwfH5asyb102fifFo+UaSJG1VqzH/h9/HaPSQkiSpdvFwf5+SJKl2cXd3l5IkqXYxHA5TkiTVLm5vb1OSJNUurm9uUpIk1S6ur3+mJEmqXQwGg5QkSbWLH/1+SpKk2kW/30tJklS76F31UpIk1S6uLi9TkiTVLrrdbkqSpNpFp9NJSZJUO4MuSZJBlyRJBl2SJBl0SZJk0CVJMuiSJMmgS5Ikgy5Jkgy6JEkGXZIkGXRJkmTQJUmSQZckyaBLkiSDLkmSDLokSTLokiQZdEmSZNAlSZJBlyRJBl2SpPYPOgAAAAAAAAAAAAAAAAAAAAAAAAD/WW7AlQCg+Ki7DgAUH3VXAYDio+4aAFB81F0BAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD4cHb2TnNdrgQABewenuXRycWrmu9dBwAK+fTl2+TPMW8+uwoAFHRwfL4a8+bVNQCg+Ki7AgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAW29/fz9dAQCKj7lBB4AWjLlBB4BC423MAaAl/8aNOQC0YNCNOQC0aNRdAwCKj7orAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwBq55AoAUHzMDToAtGDMDToAFBpvYw4ALfk3bswBoAWDbswBoEWj7hoAUHzUXQEAAAAAAN7yG6s7d/s7eB9vAAAAAElFTkSuQmCC") !important;background-repeat:no-repeat;-webkit-background-size:500px 221px;-moz-background-size:500px 221px;background-size:500px 221px;}';
549
550 css += 'html .ponyhoof_dialog .ponyhoof_button_menu {background-position:right 0;padding-right:23px;}';
551 css += 'html .ponyhoof_button_menu:active {background-position:right -98px;}';
552 css += 'html .openToggler .ponyhoof_button_menu {background-color:#6D84B4;background-position:right -49px;border-color:#3B5998;border-bottom-color:#6D84B4;-moz-box-shadow:none;box-shadow:none;}';
553 css += 'html .openToggler .ponyhoof_button_menu .uiButtonText {color:#fff;}';
554
555 css += '.ponyhoof_menu_label {padding:7px 4px 0 0;}';
556 css += '.ponyhoof_menu_label, .ponyhoof_menu_withlabel .ponyhoof_menu_wrap {display:inline-block;}';
557 css += '.ponyhoof_menu_withlabel {margin-bottom:8px;}';
558 css += '.ponyhoof_menu_withlabel + .ponyhoof_menu_withlabel {margin-top:-8px;}';
559 css += '.ponyhoof_menu_withlabel .ponyhoof_button_menu {margin-top:-3px;}';
560 css += '.ponyhoof_menu_labelbreak .ponyhoof_menu_label {display:block;padding-bottom:7px;}';
561
562 css += '.ponyhoof_menu_wrap {position:relative;}';
563 css += 'html .ponyhoof_menu {z-index:1999;display:none;min-width:0;-webkit-user-select:none;-moz-user-select:none;user-select:none;}';
564 css += '.ponyhoof_menu_wrap.openToggler .ponyhoof_menu {display:block;}';
565 css += '.ponyhoof_menu_wrap + .uiButton {margin:4px 0 0 4px;}';
566 css += '.ponyhoof_menu .uiMenu {background:#fff;border:1px solid #777;border-bottom:2px solid #293E6A;color:#000;position:absolute;overflow:auto;overflow-x:hidden;text-align:left;}';
567 css += '.ponyhoof_menu .uiMenu.overflow {resize:vertical;height:200px;min-height:200px;}';
568 css += '.ponyhoof_menu_wrap.uiSelectorRight .uiMenu {left:auto;right:0;}';
569 css += '.ponyhoof_menu .ponyhoof_menu_search {padding:0 3px;margin-bottom:4px;}';
570 css += '.ponyhoof_menu .ponyhoof_menu_search input {width:100%;resize:none;}';
571 css += '.ponyhoof_menu .ponyhoof_menu_search_noResults {display:none;color:#999;text-align:center;margin-top:7px;width:100px;}';
572 css += '.ponyhoof_menuitem {border:solid #fff;border-width:1px 0;color:#111;display:block;font-weight:normal;line-height:16px;padding:1px 22px;text-decoration:none;outline:none;-webkit-user-drag:none;resize:none;}';
573 css += '.ponyhoof_menu .ponyhoof_menuitem {color:#111;}';
574 css += '.ponyhoof_menuitem:hover, .ponyhoof_menuitem:active, .ponyhoof_menuitem:focus {background-color:#6d84b4;border-color:#3b5998;color:#fff;text-decoration:none;}';
575 css += '.ponyhoof_menuitem_checked {background-position:0 -146px;font-weight:bold;}';
576 css += '.ponyhoof_menuitem_checked:hover, .ponyhoof_menuitem_checked:active, .ponyhoof_menuitem_checked:focus {background-position:0 -206px;}';
577 css += '.ponyhoof_menuitem_span {white-space:nowrap;text-overflow:ellipsis;display:inline-block;overflow:hidden;padding-right:16px;max-width:400px;}';
578
579 css += '.ponyhoof_button_clipped .uiButtonText {text-overflow:ellipsis;overflow:hidden;}';
580
581 injectManualStyle(css, 'menu');
582 };
583
584 k.open = function() {
585 k.closeAllMenus();
586
587 addClass(k.wrap, 'openToggler');
588
589 if (!hasClass(k.menuInner.parentNode, 'overflow') && (k.menuInner.parentNode.offsetHeight >= 224 || k.alwaysOverflow)) {
590 addClass(k.menuInner.parentNode, 'overflow');
591 }
592
593 if (k.canSearch) {
594 var scrollTop = k.selectorMenu.scrollTop;
595 k.menuSearchInput.focus();
596 k.menuSearchInput.select();
597
598 k.selectorMenu.scrollTop = scrollTop;
599 }
600
601 d.body.addEventListener('keydown', k.documentEscapeKey, false);
602 d.body.addEventListener('click', k.documentClick, false);
603 };
604
605 k.close = function() {
606 if (hasClass(k.wrap, 'openToggler')) {
607 removeClass(k.wrap, 'openToggler');
608 d.body.removeEventListener('keydown', k.documentEscapeKey, false);
609 d.body.removeEventListener('click', k.documentClick, false);
610
611 k.afterClose();
612 }
613 };
614
615 k.closeAllMenus = function() {
616 for (var menu in MENUS) {
617 if (MENUS.hasOwnProperty(menu)) {
618 MENUS[menu].close();
619 }
620 }
621 };
622
623 k.toggle = function() {
624 if (hasClass(k.wrap, 'openToggler')) {
625 k.close();
626 } else {
627 k.open();
628 }
629 };
630
631 k.changeChecked = function(menuItem) {
632 var already = k.menu.getElementsByClassName('ponyhoof_menuitem_checked');
633 if (already.length) {
634 removeClass(already[0], 'ponyhoof_menuitem_checked');
635 }
636 addClass(menuItem.menuItem, 'ponyhoof_menuitem_checked');
637 };
638
639 k.performSearch = function() {
640 var val = k.menuSearchInput.value;
641 var regex = new RegExp(val, 'i');
642
643 var count = 0;
644 $$(k.menu, '.ponyhoof_menuitem', function(menuitem) {
645 if (val == '') {
646 menuitem.style.display = '';
647 return;
648 }
649
650 if (!hasClass(menuitem, 'unsearchable')) {
651 menuitem.style.display = 'none';
652
653 var compare = menuitem.textContent;
654 if (menuitem.getAttribute('data-ponyhoof-menu-searchAlternate')) {
655 compare = menuitem.getAttribute('data-ponyhoof-menu-searchAlternate');
656 }
657
658 if (regex.test(compare)) {
659 menuitem.style.display = 'block';
660 count += 1;
661 }
662 } else {
663 menuitem.style.display = 'none';
664 }
665 });
666
667 $$(k.menu, '.ponyhoof_menu_search_noResults', function(ele) {
668 if (val) {
669 if (!count) {
670 ele.style.display = 'block';
671 } else {
672 ele.style.display = 'none';
673 }
674 } else {
675 ele.style.display = 'none';
676 }
677 });
678
679 $$(k.menu, '.uiMenuSeparator', function(menuitem) {
680 if (val == '') {
681 menuitem.style.display = '';
682 return;
683 }
684
685 menuitem.style.display = 'none';
686 });
687
688 if (k.hasScrollableArea) {
689 k.scrollableArea.poke();
690 }
691 };
692
693 k.searchEscapeKey = function(e) {
694 if (e.which == 27) {
695 if (k.menuSearchInput.value != '') {
696 k.menuSearchInput.value = '';
697 k.performSearch();
698 } else {
699 k.close();
700 if (k.button) {
701 k.button.focus();
702 }
703 }
704 e.stopPropagation();
705 e.cancelBubble = true;
706 }
707 };
708
709 k.documentEscapeKey = function(e) {
710 if (e.which == 27 && hasClass(k.wrap, 'openToggler')) { // esc
711 k.close();
712 e.stopPropagation();
713 e.cancelBubble = true;
714
715 if (k.button) {
716 k.button.focus();
717 }
718 }
719 };
720
721 k.documentClick = function(e) {
722 k.close();
723 e.stopPropagation();
724 e.preventDefault();
725 };
726
727 k.focusStealerFocused = function(e) {
728 if (k.canSearch) {
729 k.menuSearchInput.focus();
730 }
731 };
732 };
733
734 var MenuItem = function(menu) {
735 var k = this;
736
737 k.menuItem = null;
738 k.menu = menu;
739 k.onclick = null;
740
741 k._create = function(param) {
742 k.menuItem = d.createElement('a');
743 k.menuItem.href = '#';
744 k.menuItem.className = 'ponyhoof_menuitem';
745 k.menuItem.setAttribute('role', 'menuitem');
746
747 if (param.check) {
748 k.menuItem.className += ' ponyhoof_menuitem_checked';
749 }
750
751 if (param.data) {
752 k.menuItem.setAttribute('data-ponyhoof-menu-data', param.data);
753 }
754
755 if (param.title) {
756 k.menuItem.setAttribute('aria-label', param.title);
757 k.menuItem.setAttribute('data-hover', 'tooltip');
758 }
759
760 if (param.unsearchable) {
761 k.menuItem.className += ' unsearchable';
762 }
763
764 if (param.searchAlternate) {
765 k.menuItem.setAttribute('data-ponyhoof-menu-searchAlternate', param.searchAlternate);
766 }
767
768 if (param.extraClass) {
769 k.menuItem.className += param.extraClass;
770 }
771
772 k.menuItem.innerHTML = '<span class="ponyhoof_menuitem_span">'+param.html+'</span>';
773
774 if (param.onclick) {
775 k.onclick = param.onclick;
776 }
777 k.menuItem.addEventListener('click', function(e) {
778 e.stopPropagation();
779 if (k.onclick) {
780 k.onclick(k, k.menu);
781 }
782
783 return false;
784 }, false);
785 k.menuItem.addEventListener('dragstart', function() {
786 return false;
787 }, false);
788
789 return k.menuItem;
790 };
791
792 k.getText = function() {
793 return k.menuItem.getElementsByClassName('ponyhoof_menuitem_span')[0].innerHTML;
794 };
795 };
796
797 // Dialog
798 var DIALOGS = {};
799 var DIALOGCOUNT = 400;
800 var Dialog = function(id) {
801 var k = this;
802
803 k.dialog = null;
804 k.generic_dialogDiv = null;
805 k.popup_dialogDiv = null;
806 k.id = id;
807 k.visible = false;
808
809 k.alwaysModal = false;
810 k.noTitle = false;
811 k.noBottom = false;
812
813 k.canCardspace = true;
814 k.cardSpaceTimer = null;
815 k.cardspaced = false;
816
817 k.onclose = function() {};
818 k.onclosefinish = function() {};
819 k.canCloseByEscapeKey = true;
820
821 k.skeleton = '';
822
823 k.create = function() {
824 //if (DIALOGS[k.id]) {
825 // log("Attempting to recreate dialog ID \""+k.id+"\"");
826 // return DIALOGS[k.id].dialog;
827 //}
828
829 //DIALOGS[k.id] = k;
830
831 log("Creating "+k.id+" dialog...");
832
833 k.injectStyle();
834
835 DIALOGCOUNT += 1;
836 k.skeleton = '<!-- '+SIG+' Dialog -->';
837 k.skeleton += '<div class="generic_dialog pop_dialog" role="dialog" style="z-index:'+(DIALOGCOUNT)+';">';
838 k.skeleton += ' <div class="generic_dialog_popup">';
839 k.skeleton += ' <div class="popup">';
840 k.skeleton += ' <div class="wrap">';
841 k.skeleton += ' <h3 title="This dialog is sent from '+FRIENDLYNAME+'"></h3>';
842 k.skeleton += ' <div class="body">';
843 k.skeleton += ' <div class="content clearfix"></div>';
844 k.skeleton += ' <div class="bottom"></div>';
845 k.skeleton += ' </div>'; // body
846 k.skeleton += ' </div>'; // wrap
847 k.skeleton += ' </div>'; // popup
848 k.skeleton += ' </div>'; // generic_dialog_popup
849 k.skeleton += '</div>';
850
851 INTERNALUPDATE = true;
852
853 k.dialog = d.createElement('div');
854 k.dialog.className = 'ponyhoof_dialog';
855 k.dialog.id = 'ponyhoof_dialog_'+k.id;
856 k.dialog.innerHTML = k.skeleton;
857 d.body.appendChild(k.dialog);
858
859 INTERNALUPDATE = false;
860
861 k.generic_dialogDiv = k.dialog.getElementsByClassName('pop_dialog')[0];
862 k.popup_dialogDiv = k.dialog.getElementsByClassName('popup')[0];
863
864 if (k.alwaysModal) {
865 addClass(k.generic_dialogDiv, 'generic_dialog_modal');
866 }
867 if (k.noTitle) {
868 addClass(k.dialog.getElementsByTagName('h3')[0], 'hidden_elem');
869 }
870 if (k.noBottom) {
871 addClass(k.dialog.getElementsByClassName('bottom')[0], 'hidden_elem');
872 }
873
874 k.show();
875
876 return k.dialog;
877 };
878
879 k.injectStyle = function() {
880 var cx = '._6nw';
881 if (d.getElementsByClassName('-cx-PUBLIC-hasLitestand__body').length) {
882 cx = '.-cx-PUBLIC-hasLitestand__body';
883 }
884
885 var css = '';
886 css += '.ponyhoof_message .wrap {margin-top:3px;background:transparent !important;display:block;}';
887 css += '.ponyhoof_message .uiButton.rfloat {margin-left:10px;}';
888
889 css += '.ponyhoof_dialog, .ponyhoof_dialog .body {font-size:11px;}';
890 css += cx+' .ponyhoof_dialog, '+cx+' .ponyhoof_dialog .body {font-size:12px;}';
891 css += '.ponyhoof_dialog iframe {-webkit-user-select:none;-moz-user-select:none;user-select:none;}';
892 css += '.ponyhoof_dialog textarea, .ponyhoof_dialog input[type="text"] {cursor:text;-moz-box-sizing:border-box;box-sizing:border-box;}';
893 css += '.ponyhoof_dialog .generic_dialog_modal, .ponyhoof_dialog .generic_dialog_fixed_overflow {background-color:rgba(0,0,0,.4) !important;}';
894 css += '.ponyhoof_dialog .generic_dialog {z-index:250;}';
895 css += '.ponyhoof_dialog .generic_dialog_popup {margin-top:80px;}';
896 css += '.ponyhoof_dialog .popup {width:465px;margin:0 auto;cursor:default;-moz-box-shadow:0 2px 26px rgba(0, 0, 0, .3), 0 0 0 1px rgba(0, 0, 0, .1);box-shadow:0 2px 26px rgba(0, 0, 0, .3), 0 0 0 1px rgba(0, 0, 0, .1);}';
897 css += cx+' .ponyhoof_dialog .popup {font-family:"Helvetica Neue", Helvetica, Arial, "lucida grande",tahoma,verdana,arial,sans-serif;}';
898 css += '.ponyhoof_dialog .wrap {background:#fff;color:#000;}';
899 css += '.ponyhoof_dialog h3 {background-color:#6D84B4;border:1px solid #3B5998;border-bottom:0;color:#fff;font-size:14px !important;font-weight:bold !important;padding:5px 5px 5px 10px;cursor:help;min-height:17px;font-family:\'lucida grande\',tahoma,verdana,arial,sans-serif !important;line-height:1.28 !important;}';
900 css += cx+' .ponyhoof_dialog h3 {background:#f5f6f7;border:0;border-bottom:1px solid #e5e5e5;-moz-border-radius:3px 3px 0 0;border-radius:3px 3px 0 0;color:#4e5665;line-height:19px !important;padding:10px 12px;text-shadow:0 1px 0 #fff;font-family:\'Helvetica Neue\', Helvetica, Arial, \'lucida grande\',tahoma,verdana,arial,sans-serif !important;}';
901 css += '.ponyhoof_dialog h3:before {background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABDUlEQVQ4y43TzytEURQH8BnDyGKKZIGlHwtTrKZQNmJPWMxO2VopKdkoCzul7PwBkpK17NlYkGz8G7LzsXBe3cbz3tz69s65536/nfe951ZQ6cAkWjn7ucjb3MdjxFWMJLVlrJYJTGAp4l4coBH5A95C+F+BFH14QTPyRawUdVDHcJLX/K52tx70YxuXmMZ6CNxFfQEzZR7UcRvEr/h+4hnv3QhkuPF3bRT9whZOMRB5u4P8gdkwNlfgPA5WMZYQv5N4raiDKcxjEFc4w2EQX3GCC4yXeTCE0eRW4CipX2Ov20GqhPM7yWRmHRUKzOEePTgOgzOBXWyWCTTxFIRWCHb9GrMRbsSN1AK5Z38AQdAu/IfZJw8AAAAASUVORK5CYII=");background-repeat: no-repeat;display:inline-block;float:right;content:" ";width:16px;height:16px;opacity:.713;}';
902 css += cx+' .ponyhoof_dialog h3:before {display:none;}';
903 css += '.ponyhoof_dialog .body {border:1px solid #555;border-top-width:0;}';
904 css += '.ponyhoof_dialog h3.hidden_elem + .body {border-top-width:1px;}';
905 css += cx+' .ponyhoof_dialog .body {border:0;}';
906 css += '.ponyhoof_dialog .content {padding:10px;}';
907 css += '.ponyhoof_dialog .bottom {background:#F2F2F2;border-top:1px solid #ccc;padding:8px 10px 8px 10px;text-align:right;}';
908 css += cx+' .ponyhoof_dialog .bottom {-moz-border-radius:0 0 3px 3px;border-radius:0 0 3px 3px;}';
909 css += '.ponyhoof_dialog .bottom .lfloat {line-height:17px;margin-top:4px;}';
910
911 css += '.ponyhoof_dialog_header {background:#F2F2F2;border:solid #E2E2E2;border-width:1px 0;padding:4px 10px 5px;color:#333;font-size:11px;margin:0 -10px 8px;display:block;font-weight:bold;}';
912 css += '.ponyhoof_tabs {padding:4px 10px 0;background:#F2F2F2;border-bottom:1px solid #ccc;margin:-10px -10px 10px;}';
913 css += '.ponyhoof_tabs a {margin:3px 10px 0 0;padding:5px 8px;float:left;}';
914 css += '.ponyhoof_tabs a.active {color:#333;padding:4px 7px 5px;background:#fff;border:1px solid #ccc;border-bottom:1px solid #fff;margin-bottom:-1px;text-decoration:none;}';
915 css += '.ponyhoof_tabs_section {display:none;}';
916
917 if (ISMOBILE) {
918 css += '#ponyhoof_welcome_scenery {background-image:none !important;}';
919 css += '.ponyhoof_dialog .generic_dialog {position:absolute;}';
920 css += '.ponyhoof_menu .uiMenu.overflow {resize:none !important;height:auto !important;}';
921 }
922
923 injectManualStyle(css, 'dialog');
924 };
925
926 k.show = function() {
927 removeClass(k.dialog, 'ponyhoof_fadeout');
928 removeClass(k.generic_dialogDiv, 'ponyhoof_fadeout');
929
930 k.visible = true;
931 k.dialog.style.display = 'block';
932 k.generic_dialogDiv.style.display = 'block';
933
934 if (ISMOBILE) {
935 k.canCardspace = false;
936 }
937
938 if (k.canCardspace) {
939 w.addEventListener('resize', k.onBodyResize, false);
940 k.cardSpaceTick();
941 }
942
943 if (k.canCloseByEscapeKey) {
944 d.body.addEventListener('keydown', k.documentEscapeKey, false);
945 }
946 };
947
948 k.close = function(callback) {
949 k.onclose();
950
951 if (!userSettings.disable_animation) {
952 fadeOut(k.dialog, function() {
953 if (callback) {
954 callback();
955 }
956 k.onclosefinish();
957 });
958 if (callback) {
959 log("Legacy dialog close code found");
960 }
961
962 if (ISOPERA) {
963 fadeOut(k.generic_dialogDiv);
964 }
965 } else {
966 k.dialog.style.display = 'none';
967 if (callback) {
968 callback();
969 }
970 k.onclosefinish();
971 }
972
973 k._close();
974 };
975
976 k.hide = function() {
977 k.onclose();
978
979 k.dialog.style.display = 'none';
980
981 k._close();
982 };
983
984 k._close = function() {
985 k.visible = false;
986
987 w.removeEventListener('resize', k.onBodyResize, false);
988 w.clearTimeout(k.cardSpaceTimer);
989
990 if (k.cardspaced) {
991 removeClass(d.documentElement, 'generic_dialog_overflow_mode');
992 if (!k.alwaysModal) {
993 removeClass(k.generic_dialogDiv, 'generic_dialog_modal');
994 }
995 }
996 removeClass(k.generic_dialogDiv, 'generic_dialog_fixed_overflow');
997 k.cardspaced = false;
998
999 d.body.removeEventListener('keydown', k.documentEscapeKey, false);
1000 };
1001
1002 k.changeTitle = function(c) {
1003 INTERNALUPDATE = true;
1004 var title = k.dialog.getElementsByTagName('h3');
1005 if (title.length) {
1006 title = title[0];
1007 title.innerHTML = c;
1008 }
1009 INTERNALUPDATE = false;
1010 };
1011
1012 k.changeContent = function(c) {
1013 INTERNALUPDATE = true;
1014 var content = k.dialog.getElementsByClassName('content');
1015 if (content.length) {
1016 content = content[0];
1017 content.innerHTML = c;
1018 }
1019 INTERNALUPDATE = false;
1020 };
1021
1022 k.changeBottom = function(c) {
1023 INTERNALUPDATE = true;
1024 var bottom = k.dialog.getElementsByClassName('bottom');
1025 if (bottom.length) {
1026 bottom = bottom[0];
1027 bottom.innerHTML = c;
1028 }
1029 INTERNALUPDATE = false;
1030 };
1031
1032 k.addCloseButton = function(callback) {
1033 var text = "Close";
1034 if (CURRENTLANG && CURRENTLANG.close) {
1035 text = CURRENTLANG.close;
1036 }
1037
1038 var close = '<a href="#" class="uiButton uiButtonLarge uiButtonConfirm" role="button"><span class="uiButtonText">'+text+'</span></a>';
1039 k.changeBottom(close);
1040
1041 k.dialog.querySelector('.bottom .uiButton').addEventListener('click', function(e) {
1042 k.close(function() {
1043 if (callback) {
1044 log("Legacy dialog close code found");
1045 callback();
1046 }
1047 });
1048 e.preventDefault();
1049 }, false);
1050 };
1051
1052 k.onBodyResize = function() {
1053 if (k.canCardspace) {
1054 var dialogHeight = k.popup_dialogDiv.clientHeight + 80 + 40;
1055 var windowHeight = w.innerHeight;
1056
1057 if (dialogHeight > windowHeight) {
1058 if (!k.cardspaced) {
1059 addClass(d.documentElement, 'generic_dialog_overflow_mode');
1060 if (!k.alwaysModal) {
1061 addClass(k.generic_dialogDiv, 'generic_dialog_modal');
1062 }
1063 addClass(k.generic_dialogDiv, 'generic_dialog_fixed_overflow');
1064
1065 k.cardspaced = true;
1066 }
1067 } else {
1068 if (k.cardspaced) {
1069 removeClass(d.documentElement, 'generic_dialog_overflow_mode');
1070 if (!k.alwaysModal) {
1071 removeClass(k.generic_dialogDiv, 'generic_dialog_modal');
1072 }
1073 removeClass(k.generic_dialogDiv, 'generic_dialog_fixed_overflow');
1074
1075 k.cardspaced = false;
1076 }
1077 }
1078 }
1079 };
1080
1081 k.cardSpaceTick = function() {
1082 if (k.canCardspace && k.visible) {
1083 k.onBodyResize();
1084 k.cardSpaceTimer = w.setTimeout(k.cardSpaceTick, 500);
1085 } else {
1086 w.clearTimeout(k.cardSpaceTimer);
1087 }
1088 };
1089
1090 k.documentEscapeKey = function(e) {
1091 if (k.canCloseByEscapeKey) {
1092 if (e.which == 27 && k.visible) { // esc
1093 k.close();
1094 e.stopPropagation();
1095 e.cancelBubble = true;
1096 }
1097 }
1098 };
1099
1100 if (DIALOGS[k.id]) {
1101 log("Attempting to recreate dialog ID \""+k.id+"\"");
1102 return DIALOGS[k.id];
1103 }
1104 DIALOGS[k.id] = k;
1105 };
1106
1107 function createSimpleDialog(id, title, message) {
1108 if (DIALOGS[id]) {
1109 DIALOGS[id].show();
1110 return DIALOGS[id];
1111 }
1112
1113 var di = new Dialog(id);
1114 di.create();
1115 di.changeTitle(title);
1116 di.changeContent(message);
1117 di.addCloseButton();
1118
1119 return di;
1120 };
1121
1122 function injectSystemStyle() {
1123 var css = '';
1124 css += '.ponyhoof_show_if_injected {display:none;}';
1125 css += '.ponyhoof_hide_if_injected {display:block;}';
1126 css += '.ponyhoof_hide_if_injected.inline {display:inline;}';
1127 css += 'html.ponyhoof_injected .ponyhoof_show_if_injected {display:block;}';
1128 css += 'html.ponyhoof_injected .ponyhoof_hide_if_injected {display:none;}';
1129 css += '.ponyhoof_show_if_loaded {display:none;}';
1130 css += '.ponyhoof_updater_latest, .ponyhoof_updater_newVersion, .ponyhoof_updater_error {display:none;}';
1131
1132 css += '.ponyhoof_fadeout {opacity:0;-webkit-transition:opacity .25s linear;-moz-transition:opacity .25s linear;-o-transition:opacity .25s linear;transition:opacity .25s linear;}';
1133 css += '.ponyhoof_message {padding:10px;color:#000;font-weight:bold;overflow:hidden;}';
1134
1135 css += '.ponyhoof_loading {background:url("//fbstatic-a.akamaihd.net/rsrc.php/v2/y4/x/GsNJNwuI-UM.gif") no-repeat;display:inline-block;width:16px;height:11px;margin:6px 0 0 6px;}';
1136 css += '.ponyhoof_loading.ponyhoof_show_if_injected {display:none;}';
1137 css += 'html.ponyhoof_injected .ponyhoof_loading_pony {display:inline-block;}';
1138
1139 css += '.uiHelpLink {background:url("data:image/gif;base64,R0lGODlhDAALAJEAANvb26enp////wAAACH5BAEAAAIALAAAAAAMAAsAAAIblI8WkbcswAtAwWVzwoIbSWliBzWjR5abagoFADs=") no-repeat 0 center;display:inline-block;height:9px;width:12px;}';
1140
1141 css += '.uiInputLabel + .uiInputLabel {margin-top:3px;}';
1142 css += '.uiInputLabelCheckbox {float:left;margin:0;padding:0;}';
1143 css += '.uiInputLabel label {color:#333;display:block;font-weight:normal;margin-left:17px;vertical-align:baseline;}';
1144 css += '.webkit.mac .uiInputLabel label {margin-left:16px;}';
1145 css += '.webkit.mac .uiInputLabelCheckbox {margin-top:2px;}';
1146
1147 injectManualStyle(css, 'system');
1148 }
1149
1150 // http://www.html5rocks.com/en/tutorials/pagevisibility/intro/
1151 var _hiddenPropCached = '';
1152 var getHiddenProp = function() {
1153 if (_hiddenPropCached) {
1154 return _hiddenPropCached;
1155 }
1156
1157 var prefixes = ['webkit', 'moz', 'ms', 'o'];
1158
1159 if ('hidden' in document) {
1160 _hiddenPropCached = 'hidden';
1161 return _hiddenPropCached;
1162 }
1163
1164 for (var i = 0, len = prefixes.length; i < len; i++){
1165 if ((prefixes[i] + 'Hidden') in document) {
1166 _hiddenPropCached = prefixes[i] + 'Hidden';
1167 return _hiddenPropCached;
1168 }
1169 }
1170
1171 return null;
1172 };
1173 var isPageHidden = function() {
1174 var prop = getHiddenProp();
1175 if (!prop) {
1176 return false;
1177 }
1178
1179 return document[prop];
1180 };
1181 // http://www.myersdaily.org/joseph/javascript/md5.js
1182 function md5cycle(f,c){var b=f[0],a=f[1],d=f[2],e=f[3],b=ff(b,a,d,e,c[0],7,-680876936),e=ff(e,b,a,d,c[1],12,-389564586),d=ff(d,e,b,a,c[2],17,606105819),a=ff(a,d,e,b,c[3],22,-1044525330),b=ff(b,a,d,e,c[4],7,-176418897),e=ff(e,b,a,d,c[5],12,1200080426),d=ff(d,e,b,a,c[6],17,-1473231341),a=ff(a,d,e,b,c[7],22,-45705983),b=ff(b,a,d,e,c[8],7,1770035416),e=ff(e,b,a,d,c[9],12,-1958414417),d=ff(d,e,b,a,c[10],17,-42063),a=ff(a,d,e,b,c[11],22,-1990404162),b=ff(b,a,d,e,c[12],7,1804603682),e=ff(e,b,a,d,c[13],12,-40341101),d=ff(d,e,b,a,c[14],17,-1502002290),a=ff(a,d,e,b,c[15],22,1236535329),b=gg(b,a,d,e,c[1],5,-165796510),e=gg(e,b,a,d,c[6],9,-1069501632),d=gg(d,e,b,a,c[11],14,643717713),a=gg(a,d,e,b,c[0],20,-373897302),b=gg(b,a,d,e,c[5],5,-701558691),e=gg(e,b,a,d,c[10],9,38016083),d=gg(d,e,b,a,c[15],14,-660478335),a=gg(a,d,e,b,c[4],20,-405537848),b=gg(b,a,d,e,c[9],5,568446438),e=gg(e,b,a,d,c[14],9,-1019803690),d=gg(d,e,b,a,c[3],14,-187363961),a=gg(a,d,e,b,c[8],20,1163531501),b=gg(b,a,d,e,c[13],5,-1444681467),e=gg(e,b,a,d,c[2],9,-51403784),d=gg(d,e,b,a,c[7],14,1735328473),a=gg(a,d,e,b,c[12],20,-1926607734),b=hh(b,a,d,e,c[5],4,-378558),e=hh(e,b,a,d,c[8],11,-2022574463),d=hh(d,e,b,a,c[11],16,1839030562),a=hh(a,d,e,b,c[14],23,-35309556),b=hh(b,a,d,e,c[1],4,-1530992060),e=hh(e,b,a,d,c[4],11,1272893353),d=hh(d,e,b,a,c[7],16,-155497632),a=hh(a,d,e,b,c[10],23,-1094730640),b=hh(b,a,d,e,c[13],4,681279174),e=hh(e,b,a,d,c[0],11,-358537222),d=hh(d,e,b,a,c[3],16,-722521979),a=hh(a,d,e,b,c[6],23,76029189),b=hh(b,a,d,e,c[9],4,-640364487),e=hh(e,b,a,d,c[12],11,-421815835),d=hh(d,e,b,a,c[15],16,530742520),a=hh(a,d,e,b,c[2],23,-995338651),b=ii(b,a,d,e,c[0],6,-198630844),e=ii(e,b,a,d,c[7],10,1126891415),d=ii(d,e,b,a,c[14],15,-1416354905),a=ii(a,d,e,b,c[5],21,-57434055),b=ii(b,a,d,e,c[12],6,1700485571),e=ii(e,b,a,d,c[3],10,-1894986606),d=ii(d,e,b,a,c[10],15,-1051523),a=ii(a,d,e,b,c[1],21,-2054922799),b=ii(b,a,d,e,c[8],6,1873313359),e=ii(e,b,a,d,c[15],10,-30611744),d=ii(d,e,b,a,c[6],15,-1560198380),a=ii(a,d,e,b,c[13],21,1309151649),b=ii(b,a,d,e,c[4],6,-145523070),e=ii(e,b,a,d,c[11],10,-1120210379),d=ii(d,e,b,a,c[2],15,718787259),a=ii(a,d,e,b,c[9],21,-343485551);f[0]=add32(b,f[0]);f[1]=add32(a,f[1]);f[2]=add32(d,f[2]);f[3]=add32(e,f[3])}function cmn(f,c,b,a,d,e){c=add32(add32(c,f),add32(a,e));return add32(c<<d|c>>>32-d,b)}function ff(f,c,b,a,d,e,g){return cmn(c&b|~c&a,f,c,d,e,g)}function gg(f,c,b,a,d,e,g){return cmn(c&a|b&~a,f,c,d,e,g)}function hh(f,c,b,a,d,e,g){return cmn(c^b^a,f,c,d,e,g)}function ii(f,c,b,a,d,e,g){return cmn(b^(c|~a),f,c,d,e,g)}function md51(f){var txt="";var c=f.length,b=[1732584193,-271733879,-1732584194,271733878],a;for(a=64;a<=f.length;a+=64)md5cycle(b,md5blk(f.substring(a-64,a)));f=f.substring(a-64);var d=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(a=0;a<f.length;a++)d[a>>2]|=f.charCodeAt(a)<<(a%4<<3);d[a>>2]|=128<<(a%4<<3);if(55<a){md5cycle(b,d);for(a=0;16>a;a++)d[a]=0}d[14]=8*c;md5cycle(b,d);return b}function md5blk(f){var c=[],b;for(b=0;64>b;b+=4)c[b>>2]=f.charCodeAt(b)+(f.charCodeAt(b+1)<<8)+(f.charCodeAt(b+2)<<16)+(f.charCodeAt(b+3)<<24);return c}var hex_chr="0123456789abcdef".split("");function rhex(f){for(var c="",b=0;4>b;b++)c+=hex_chr[f>>8*b+4&15]+hex_chr[f>>8*b&15];return c}function hex(f){for(var c=0;c<f.length;c++)f[c]=rhex(f[c]);return f.join("")}function md5(f){return hex(md51(f))}function add32(f,c){return f+c&4294967295}"5d41402abc4b2a76b9719d911017c592"!=md5("hello")&&(add32=function(f,c){var b=(f&65535)+(c&65535);return(f>>16)+(c>>16)+(b>>16)<<16|b&65535});
1183 var VERSION = 1.631;
1184 var FRIENDLYNAME = 'P'+'onyh'+'oof';
1185 var SIG = '['+FRIENDLYNAME+' v'+VERSION+']';
1186 var DISTRIBUTION = 'userjs';
1187
1188 var runMe = true;
1189 var STORAGEMETHOD = 'none';
1190 var INTERNALUPDATE = false;
1191 var USINGMUTATION = false;
1192
1193 var CURRENTPONY = null;
1194 var REALPONY = CURRENTPONY;
1195 var BRONYNAME = '';
1196 var USERID = 0;
1197 var UILANG = 'en_US';
1198 var CURRENTLANG = {};
1199 var ISUSINGPAGE = false;
1200 var ISUSINGBUSINESS = false;
1201
1202 var SETTINGSPREFIX = '';
1203 var globalSettings = {};
1204 var GLOBALDEFAULTSETTINGS = {
1205 'allowLoginScreen':true,
1206 'runForNewUsers':true,
1207 'globalSettingsMigrated':false, 'lastUserId':0, 'lastVersion':''
1208 };
1209
1210 var PONIES = [{"code":"trixie","name":"Trixie","users":["trixie"],"menu_title":"The Great and Powerful Trixie demands your attention!","color":["6e98b4","3a7196"],"icon16":"trixie\/icon16_2.png","soundNotif":"trixie\/notif","loadingText":"Performing magic..."},{"code":"twilight","name":"Twilight Sparkle","users":["twilight","spark","tw\u0131l\u0131ght","twilite","twi light","\u0162wilight"],"search":"twilight sparkle|twilightsparkle|princess twilight","menu_title":"To switch to Princess Twilight, go to Misc > Appearance","color":["9f6eb4","7a3a96"],"mane6":true,"loadingText":"Studying friendship..."},{"code":"dash","name":"Rainbow Dash","users":["rainbow","dash"],"search":"rainbow dash|rainbowdash|dashie","color":["6e9db4","3a7796"],"soundNotif":"dash\/notif","mane6":true,"loadingText":"Loading... in ten seconds flat!","successText":"Aww yeah!"},{"code":"pinkie","name":"Pinkie Pie","users":["pink"],"search":"pinkie pie|pinkiepie|pinkamena diane pie","color":["b46e8a","963a5f"],"soundNotif":"pinkie\/notif2","mane6":true,"loadingText":"Come on everypony!"},{"code":"applej","name":"Applejack","users":["apple j","applej"],"search":"applejack|apple jack","color":["b4976e","96703a"],"soundNotif":"applej\/notif2","mane6":true,"loadingText":"Hold on there sugarcube!","successText":"Yeehaw!"},{"code":"flutter","name":"Fluttershy","users":["flutter","flut ter"],"search":"fluttershy|flutter shy","color":["b4ae6e","968e3a"],"soundNotif":"flutter\/notif2","mane6":true,"loadingText":"Screaming...","successText":"Yay!"},{"code":"rarity","name":"Rarity","users":["rarity"],"color":["9b6eb4","763a96"],"soundNotif":"rarity\/notif","mane6":true,"loadingText":"Whining...","seperator":true},{"code":"applebloom","name":"Apple Bloom","users":["appleb","apple b"],"search":"apple bloom|applebloom|cmc|cutie mark crusaders","color":["b46e8d","963a63"],"soundNotif":"applebloom\/notif","loadingText":"Getting her cutie mark...","nocutie":true},{"code":"aloe","name":"Aloe","users":["aloe"],"search":"aloe|spa pony|spa ponies","color":["b46e91","963a68"]},{"code":"babsseed","name":"Babs Seed","users":["babs","seed"],"search":"babs seed|babsseed|cmc|cutie mark crusaders","color":["b4976e","96703a"],"nocutie":true},{"code":"berry","name":"Berry Punch","users":["berry"],"color":["a56eb4","823a96"]},{"code":"bigmac","name":"Big Macintosh","users":["bigmac","big mac"],"search":"bigmacintosh|big macintosh|big mcintosh|bigmcintosh","color":["b46e75","963a43"],"soundNotif":"bigmac\/notif","loadingText":"Saying eeyup..."},{"code":"bonbon","name":"Bon Bon","users":["bon bon","bonbon","bon-bon"],"search":"bon bon|bonbon","color":["6e89b4","3a5d96"]},{"code":"braeburn","name":"Braeburn","users":["braeburn","breaburn"],"search":"braeburn|breaburn","color":["b4a86e","96873a"],"icon16":"braeburn\/icon16_2.png"},{"code":"cadance","name":"Cadance","users":["cadance","cadence"],"search":"cadance|cadence|princess cadance|princess cadence","color":["b46e96","963a6e"]},{"code":"carrot","name":"Carrot Top","users":["golden","carrot"],"search":"carrot top|carrottop|golden harvest","menu_title":"Also known as Golden Harvest","color":["b2b46e","93963a"]},{"code":"celestia","name":"Celestia","users":["celestia","trollestia","molestia"],"search":"celestia|princess celestia","color":["b46e98","963a71"],"loadingText":"Raising the sun..."},{"code":"cheerilee","name":"Cheerilee","users":["cheerilee"],"color":["b46e96","963a6e"]},{"code":"colgate","name":"Colgate","users":["colgate","minuette"],"search":"colgate|minuette|minette","menu_title":"Also known as Minuette","color":["6e99b4","3a7396"],"soundNotif":"colgate\/notif","loadingText":"Brushing..."},{"code":"cloudchaser","name":"Cloudchaser","users":["cloudch","cloud ch"],"search":"cloudchaser|cloud chaser|stormwalker|storm walker","menu_title":"Also known as Stormwalker","color":["856eb4","593a96"]},{"code":"daring","name":"Daring Do","users":["daring"],"search":"daring do|daringdo","color":["b4a76e","96853a"]},{"code":"derpy","name":"Derpy Hooves","users":["derpy"],"color":["b4b46e","96963a"],"fbIndex_swf":"derpy\/fbIndex.swf","soundNotif":"derpy\/notif","loadingText":"Wondering what went wrong..."},{"code":"diamondtiara","name":"Diamond Tiara","users":["tiara"],"search":"diamond tiara|diamondtiara","color":["926eb4","6a3a96"],"stack":"villian"},{"code":"discord","name":"Discord","users":["discord"],"color":["b46f6e","963c3a"],"stack":"villian","loadingText":"CHOCOLATE RAIN","nocutie":true},{"code":"whooves","name":"Doctor Whooves","users":["whooves","time turn"],"search":"doctor whooves|doctor hooves|time turner","menu_title":"Also known as Time Turner","color":["b4a06e","967c3a"]},{"code":"fleur","name":"Fleur De Lis","users":["fleur","fluer"],"search":"fleur de lis|fluer de lis|fleur dis lee|fluer dis lee","color":["b46eb4","963a96"]},{"code":"flimflam","name":"Flim and Flam","users":["flim","flam"],"color":["b0b46e","91963a"],"loadingText":"Giving opportunities..."},{"code":"flitter","name":"Flitter","users":["Flitter"],"color":["846eb4","573a96"]},{"code":"gilda","name":"Gilda","users":["gilda"],"color":["b49a6e","96743a"],"stack":"villian","nocutie":true},{"code":"sombra","name":"King Sombra","users":["sombra"],"color":["6eb46e","3a963a"],"stack":"villian","nocutie":true},{"code":"lightningdust","name":"Lightning Dust","users":["lightning"],"color":["6eb4ad","3a968d"]},{"code":"lotus","name":"Lotus","users":["lotus"],"search":"lotus|spa pony|spa ponies","color":["6ea0b4","3a7c96"]},{"code":"luna","name":"Luna","users":["luna"],"search":"luna|princess luna","color":["6e7eb4","3a5096"],"soundNotif":"luna\/notif","loadingText":"Doubling the fun...","successText":"Huzzah!"},{"code":"lyra","name":"Lyra","users":["lyra"],"search":"lyra heartstrings","color":["6eb49d","3a9677"]},{"code":"nightmaremoon","name":"Nightmare Moon","users":["nightmare"],"search":"nightmare moon|nightmaremoon","color":["6e7fb4","3a5196"],"stack":"villian"},{"code":"nurseredheart","name":"Nurse Redheart","users":["nurse","redheart"],"color":["b46e76","963a45"]},{"code":"octavia","name":"Octavia","users":["octavia"],"color":["b4a76e","96853a"]},{"code":"pinkamena","name":"Pinkamena","users":["pinkamena"],"search":"pinkamena diane pie","color":["b46e8c","963a62"],"stack":"villian"},{"code":"chrysalis","name":"Queen Chrysalis","users":["chrysalis"],"search":"queen chrysalis|changeling","color":["6ea2b4","3a7f96"],"stack":"chrysalis","loadingText":"Feeding...","nocutie":true},{"code":"roidrage","name":"Roid Rage","users":["snowflake","roid","rage"],"search":"snowflake|roidrage|roid rage","menu_title":"Also known as Snowflake","color":["b4ae6e","968e3a"],"soundNotif":"_sound\/roidrage_yeah","successText":"YEAH!"},{"code":"rose","name":"Rose","users":["rose"],"search":"roseluck","menu_title":"Also known as Roseluck","color":["b46e8c","963a62"]},{"code":"scootaloo","name":"Scootaloo","users":["scootaloo"],"search":"scootaloo|cmc|cutie mark crusaders|chicken","color":["b4996e","96733a"],"loadingText":"Getting her cutie mark...","nocutie":true},{"code":"shiningarmor","name":"Shining Armor","users":["shining armor"],"search":"shining armor|shiningarmor","color":["6e7bb4","3a4b96"]},{"code":"silverspoon","name":"Silver Spoon","users":["spoon"],"search":"silver spoon|silverspoon","color":["6e97b4","3a7096"],"stack":"villian"},{"code":"soarin","name":"Soarin'","users":["soarin"],"search":"soarin'|wonderbolts","color":["6e9db4","3a7796"]},{"code":"spike","name":"Spike","users":["spike"],"color":["a26eb4","7f3a96"],"nocutie":true},{"code":"spitfire","name":"Spitfire","users":["spitfire"],"search":"spitfire|wonderbolts","color":["b4ae6e","968e3a"],"icon16":"spitfire\/icon16_2.png"},{"code":"sweetieb","name":"Sweetie Belle","users":["sweetieb","sweetie b"],"search":"sweetiebelle|sweetie belle|cmc|cutie mark crusaders","color":["a06eb4","7c3a96"],"soundNotif":"sweetieb\/notif","loadingText":"Getting her cutie mark...","nocutie":true},{"code":"vinyl","name":"Vinyl Scratch","users":["vinyl","vinyx","dj p"],"search":"vinyl scratch|dj pon3|dj-pon3|dj pon 3|dj pon-3","menu_title":"Also known as DJ Pon-3","color":["6ea9b4","3a8896"],"soundNotif":"vinyl\/notif","loadingText":"Wubbing..."},{"code":"zecora","name":"Zecora","users":["zecora"],"color":["b4af6e","96903a"]},{"code":"blank","name":"(Blank)","color":["b46e6e","963a3a"],"hidden":true,"nocutie":true},{"code":"bloomberg","name":"Bloomberg","color":["9fb46e","7a963a"],"hidden":true,"nocutie":true},{"code":"mono","name":"Mono","color":["b46e6e","963a3a"],"stack":"mono","hidden":true},{"code":"taugeh","name":"Taugeh","color":["b4b46e","96963a"],"hidden":true,"nocutie":true}];
1211 var LANG = {"af_ZA":{"sniff_comment_tooltip_like":"Hou van hierdie opmerking","sniff_comment_tooltip_unlike":"Hou nie meer van hierdie opmerking nie"},"ar_AR":{"sniff_comment_tooltip_like":"\u0627\u0644\u0625\u0639\u062c\u0627\u0628 \u0628\u0627\u0644\u062a\u0639\u0644\u064a\u0642","sniff_comment_tooltip_unlike":"\u0625\u0644\u063a\u0627\u0621 \u0625\u0639\u062c\u0627\u0628\u064a \u0628\u0647\u0630\u0627 \u0627\u0644\u062a\u0639\u0644\u064a\u0642"},"az_AZ":{"sniff_comment_tooltip_like":"Bu r\u0259yi b\u0259y\u0259n","sniff_comment_tooltip_unlike":"Bu \u015f\u0259rhi b\u0259y\u0259nm\u0259"},"be_BY":{"sniff_comment_tooltip_like":"\u041f\u0430\u0434\u0430\u0431\u0430\u0435\u0446\u0446\u0430","sniff_comment_tooltip_unlike":"\u041c\u043d\u0435 \u0431\u043e\u043b\u044c\u0448 \u043d\u0435 \u043f\u0430\u0434\u0430\u0431\u0430\u0435\u0446\u0446\u0430 \u0433\u044d\u0442\u044b \u043a\u0430\u043c\u044d\u043d\u0442\u0430\u0440"},"bg_BG":{"sniff_comment_tooltip_like":"\u0425\u0430\u0440\u0435\u0441\u0432\u0430\u043c \u0442\u043e\u0437\u0438 \u043a\u043e\u043c\u0435\u043d\u0442\u0430\u0440","sniff_comment_tooltip_unlike":"\u0412\u0435\u0447\u0435 \u043d\u0435 \u0445\u0430\u0440\u0435\u0441\u0432\u0430\u043c"},"bn_IN":{"sniff_comment_tooltip_like":"\u09ae\u09a8\u09cd\u09a4\u09ac\u09cd\u09af\u099f\u09bf \u09ad\u09be\u09b2\u09cb \u09b2\u09c7\u0997\u09c7\u099b\u09c7","sniff_comment_tooltip_unlike":"\u09ad\u09be\u09b2\u09cb \u09b2\u09be\u0997\u09c7\u09a8\u09bf"},"bs_BA":{"sniff_comment_tooltip_like":"Svi\u0111a mi se ovaj komentar","sniff_comment_tooltip_unlike":"Ne svi\u0111a mi se komentar"},"ca_ES":{"sniff_comment_tooltip_like":"M'agrada aquest comentari","sniff_comment_tooltip_unlike":"Ja no m'agrada aquest comentari."},"cs_CZ":{"sniff_comment_tooltip_like":"Tento koment\u00e1\u0159 se mi l\u00edb\u00ed.","sniff_comment_tooltip_unlike":"Koment\u00e1\u0159 se mi u\u017e nel\u00edb\u00ed","close":"Zav\u0159\u00edt"},"cy_GB":{"sniff_comment_tooltip_like":"Hoffi'r sylw hwn","sniff_comment_tooltip_unlike":"Peidio hoffi'r sylw hwn"},"da_DK":{"fb_composer_lessons":"Hvilke lektioner i venskab har du l\u00e6rt idag?","sniff_comment_tooltip_like":"Tilkendegiv, at du synes godt om denne kommentar","sniff_comment_tooltip_unlike":"Synes ikke godt om denne kommentar l\u00e6ngere","close":"Luk"},"de_DE":{"fb_composer_lessons":"Welche Lektionen \u00fcber Freundschaft hast Du heute gelernt?","sniff_comment_tooltip_like":"Dieser Kommentar gef\u00e4llt mir","sniff_comment_tooltip_unlike":"Dieser Kommentar gef\u00e4llt mir nicht mehr","close":"Schlie\u00dfen"},"el_GR":{"sniff_comment_tooltip_like":"\u039c\u03bf\u03c5 \u03b1\u03c1\u03ad\u03c3\u03b5\u03b9 \u03b1\u03c5\u03c4\u03cc \u03c4\u03bf \u03c3\u03c7\u03cc\u03bb\u03b9\u03bf","sniff_comment_tooltip_unlike":"\"\u0394\u03b5\u03bd \u03bc\u03bf\u03c5 \u03b1\u03c1\u03ad\u03c3\u03b5\u03b9!\" \u03b1\u03c5\u03c4\u03cc \u03c4\u03bf \u03c3\u03c7\u03cc\u03bb\u03b9\u03bf"},"en_PI":{"sniff_comment_tooltip_like":"This comment be pleasin","sniff_comment_tooltip_unlike":"Care not fer such trifles"},"en_US":{"fb_composer_lessons":"What lessons in friendship have you learned today?","fb_comment_box":"Write a friendship letter...","fb_search_box":"Search for ponies, places and things","fb_search_boxAlt":"Type to search for ponies, places and things","fb_composer_coolstory":"Write a cool story...","fb_composer_ponies":"Ponies!","fb_composer_ponies_caps":"PONIES!!!","fb_share_tooltip":"Remember! You gotta share... You gotta care...","sniff_comment_tooltip_like":"Like this comment","sniff_comment_tooltip_unlike":"Unlike this comment","sniff_fb_search_boxAlt":"Type to search","close":"Close","reloadNow":"Reload now","notNow":"Not now","invertSelection":"Invert selection","finish":"Finish","done":"Eeyup","options_title":"Ponyhoof Options","options_tabs_main":"General","options_tabs_background":"Background","options_tabs_sounds":"Sounds","options_tabs_extras":"Misc","options_tabs_advanced":"Debug","options_tabs_about":"About","settings_disable_runForNewUsers_explain":"If you enable this, Ponyhoof will not automatically run for other Facebook accounts that did not activate Ponyhoof yet. They can still open Ponyhoof Options to re-enable Ponyhoof if they wish to.","settings_extras_login_bg":"Use alternate background","settings_sounds":"Play sounds (e.g. notifications and dialogs)","settings_sounds_noNotification":"Play sounds (e.g. dialogs)","settings_extras_runForNewUsers_explain":"If you disable this, Ponyhoof will not automatically run for other Facebook accounts that did not activate Ponyhoof yet. They can still open Ponyhoof Options to re-enable Ponyhoof if they wish to.","settings_main_visitPage":"Visit the Ponyhoof page for news and help","settings_main_visitPageBusiness":"Visit the Ponyhoof page for news","settings_sounds_unavailable":"Notification sounds are not available on your browser. Please update your browser if possible.","updater_title":"Update Ponyhoof","costume_tooltip":"Limited to certain characters only"},"eo_EO":{"sniff_comment_tooltip_like":"\u015cati \u0109i tiun komenton","sniff_comment_tooltip_unlike":"Ne plu \u015dati \u0109i tiun komenton"},"es_ES":{"sniff_comment_tooltip_like":"Me gusta este comentario","sniff_comment_tooltip_unlike":"Ya no me gusta este comentario","close":"Cerrar"},"es_LA":{"fb_composer_lessons":"\u00bfQue has aprendido hoy sobre la amistad?","fb_comment_box":"Escribe un reporte de amistad...","sniff_comment_tooltip_like":"Me gusta este comentario","sniff_comment_tooltip_unlike":"Ya no me gusta este comentario","close":"Cerrar"},"et_EE":{"sniff_comment_tooltip_like":"Meeldib see kommentaar","sniff_comment_tooltip_unlike":"Ei meeldi enam"},"eu_ES":{"sniff_comment_tooltip_like":"Iruzkin hau atsegin dut","sniff_comment_tooltip_unlike":"Iruzkin hau desatsegin"},"fa_IR":{"sniff_comment_tooltip_like":"\u0627\u06cc\u0646 \u062f\u06cc\u062f\u06af\u0627\u0647 \u0631\u0627 \u0645\u06cc\u200c\u067e\u0633\u0646\u062f\u0645","sniff_comment_tooltip_unlike":"\u0627\u06cc\u0646 \u062f\u06cc\u062f\u06af\u0627\u0647 \u0631\u0627 \u0646\u067e\u0633\u0646\u062f\u06cc\u062f\u0645"},"fb_LT":{"fb_composer_lessons":"W|-|47 \u00a33550|\\|5 !|\\| |=|2!3|\\||)5|-|!|* |-|4\\\/3 '\/0|_| \u00a334|2|\\|3|) 70|)4'\/?","fb_comment_box":"W|2!73 4 |=|2!3|\\||)5|-|!|* \u00a33773|2...","fb_search_box":"S34|2(|-| |=0|2 |*0|\\|!35, |*\u00a34(35 4|\\||) 7|-|!|\\|95","fb_search_boxAlt":"T'\/|*3 70 534|2(|-| |=0|2 |*0|\\|!35, |*\u00a34(35 4|\\||) 7|-|!|\\|95","fb_composer_coolstory":"W|2!73 4 (00\u00a3 570|2'\/...","fb_composer_ponies":"P0|\\|!35!","fb_composer_ponies_caps":"PONIES!!!","fb_share_tooltip":"R3|\\\/|3|\\\/|83|2! Y0|_| 90774 5|-|4|23... Y0|_| 90774 (4|23...","close":"Alt+F4","reloadNow":"R3\u00a304|) |\\|0vv","notNow":"N07 |\\|0vv","invertSelection":"I|\\|\\\/3|27 53\u00a33(7!0|\\|","finish":"F!|\\|!5|-|","done":"E3'\/|_||*","options_title":"P0|\\|'\/|-|00|= O|*7!0|\\|5","options_tabs_main":"G3|\\|3|24\u00a3","options_tabs_background":"B4(k9|20|_||\\||)","options_tabs_sounds":"S0|_||\\||)5","options_tabs_extras":"M!5(","options_tabs_advanced":"D38|_|9","options_tabs_about":"A80|_|7","settings_disable_runForNewUsers_explain":"I|= '\/0|_| 3|\\|48\u00a33 7|-|!5, P0|\\|'\/|-|00|= vv!\u00a3\u00a3 |\\|07 4|_|70|\\\/|47!(4\u00a3\u00a3'\/ |2|_||\\| |=0|2 07|-|3|2 F4(3800k 4((0|_||\\|75 7|-|47 |)!|) |\\|07 4(7!\\\/473 P0|\\|'\/|-|00|= '\/37. T|-|3'\/ (4|\\| 57!\u00a3\u00a3 0|*3|\\| P0|\\|'\/|-|00|= O|*7!0|\\|5 70 |23-3|\\|48\u00a33 P0|\\|'\/|-|00|= !|= 7|-|3'\/ vv!5|-| 70.","settings_extras_login_bg":"U53 4\u00a373|2|\\|473 84(k9|20|_||\\||)","settings_sounds":"P\u00a34'\/ 50|_||\\||)5 (3.9. |\\|07!|=!(47!0|\\|5 4|\\||) |)!4\u00a3095)","settings_sounds_noNotification":"P\u00a34'\/ 50|_||\\||)5 (3.9. |)!4\u00a3095)","settings_extras_runForNewUsers_explain":"I|= '\/0|_| |)!548\u00a33 7|-|!5, P0|\\|'\/|-|00|= vv!\u00a3\u00a3 |\\|07 4|_|70|\\\/|47!(4\u00a3\u00a3'\/ |2|_||\\| |=0|2 07|-|3|2 F4(3800k 4((0|_||\\|75 7|-|47 |)!|) |\\|07 4(7!\\\/473 P0|\\|'\/|-|00|= '\/37. T|-|3'\/ (4|\\| 57!\u00a3\u00a3 0|*3|\\| P0|\\|'\/|-|00|= O|*7!0|\\|5 70 |23-3|\\|48\u00a33 P0|\\|'\/|-|00|= !|= 7|-|3'\/ vv!5|-| 70.","settings_main_visitPage":"V!5!7 7|-|3 P0|\\|'\/|-|00|= |*493 |=0|2 |\\|3vv5 4|\\||) |-|3\u00a3|*","settings_main_visitPageBusiness":"V!5!7 7|-|3 P0|\\|'\/|-|00|= |*493 |=0|2 |\\|3vv5","settings_sounds_unavailable":"N07!|=!(47!0|\\| 50|_||\\||)5 4|23 |\\|07 4\\\/4!\u00a348\u00a33 0|\\| '\/0|_||2 8|20vv53|2. P\u00a33453 |_||*|)473 '\/0|_||2 8|20vv53|2 !|= |*055!8\u00a33.","updater_title":"U|*|)473 P0|\\|'\/|-|00|=","costume_tooltip":"L!|\\\/|!73|) 70 (3|274!|\\| (|-|4|24(73|25 0|\\|\u00a3'\/","sniff_comment_tooltip_like":"<3"},"fi_FI":{"fb_composer_lessons":"Mit\u00e4 oppeja yst\u00e4vyydest\u00e4 olet oppinut t\u00e4n\u00e4\u00e4n?","sniff_comment_tooltip_like":"Tykk\u00e4\u00e4 t\u00e4st\u00e4 kommentista","sniff_comment_tooltip_unlike":"En tykk\u00e4\u00e4k\u00e4\u00e4n","close":"Sulje"},"fo_FO":{"sniff_comment_tooltip_like":"M\u00e6r d\u00e1mar vi\u00f0merkingina"},"fr_CA":{"fb_composer_lessons":"Quelles le\u00e7ons sur l'amiti\u00e9 avez-vous appris aujourd'hui ?","sniff_comment_tooltip_like":"J\u2019aime ce commentaire","sniff_comment_tooltip_unlike":"Je n\u2019aime plus ce commentaire","close":"Fermer"},"fr_FR":{"fb_composer_lessons":"Quelles le\u00e7ons sur l'amiti\u00e9 avez-vous appris aujourd'hui ?","sniff_comment_tooltip_like":"J\u2019aime ce commentaire","sniff_comment_tooltip_unlike":"Je n\u2019aime plus ce commentaire","close":"Fermer"},"fy_NL":{"sniff_comment_tooltip_like":"Leuke reaksje","sniff_comment_tooltip_unlike":"Ik mei net mear oer dit berjocht"},"ga_IE":{"fb_composer_lessons":"cad ceachtanna i cairdeas ad'fhoghlaim t\u00fa inniu?","sniff_comment_tooltip_like":"L\u00e9irigh gur maith leat an tr\u00e1cht seo","sniff_comment_tooltip_unlike":"N\u00ed maith liom an tr\u00e1cht seo","close":"D\u00fan"},"gl_ES":{"sniff_comment_tooltip_like":"G\u00fastame este comentario","sniff_comment_tooltip_unlike":"Xa non me gusta"},"he_IL":{"fb_composer_lessons":"\u05d0\u05d9\u05dc\u05d5 \u05dc\u05e7\u05d7\u05d9\u05dd \u05d1\u05d9\u05d3\u05d9\u05d3\u05d5\u05ea \u05dc\u05de\u05d3\u05ea \u05d4\u05d9\u05d5\u05dd?","sniff_comment_tooltip_like":"\u05d0\u05d5\u05d4\u05d1 \u05d0\u05ea \u05d4\u05ea\u05d2\u05d5\u05d1\u05d4","sniff_comment_tooltip_unlike":"\u05dc\u05d0 \u05d0\u05d4\u05d1\/\u05d4 \u05d0\u05ea \u05ea\u05d2\u05d5\u05d1\u05d4 \u05d6\u05d5","close":"\u05e1\u05d2\u05d5\u05e8"},"hi_IN":{"sniff_comment_tooltip_like":"\u091f\u093f\u092a\u094d\u092a\u0923\u0940 \u092a\u0938\u0902\u0926 \u0915\u0930\u0947\u0902","sniff_comment_tooltip_unlike":"\u0907\u0938 \u091f\u093f\u092a\u094d\u092a\u0923\u0940 \u0915\u094b \u0928\u093e\u092a\u0938\u0902\u0926 \u0915\u0930\u0947\u0902"},"hr_HR":{"sniff_comment_tooltip_like":"Svi\u0111a mi se ovaj komentar","sniff_comment_tooltip_unlike":"Ne svi\u0111a mi se"},"hu_HU":{"fb_composer_lessons":"Mit tanult\u00e1l ma a bar\u00e1ts\u00e1gr\u00f3l?","sniff_comment_tooltip_like":"Tetszik a bejegyz\u00e9s.","sniff_comment_tooltip_unlike":"M\u00e9gsem tetszik","close":"Bez\u00e1r\u00e1s"},"hy_AM":{"sniff_comment_tooltip_like":"\u0540\u0561\u057e\u0561\u0576\u0565\u056c \u0561\u0575\u057d \u0574\u0565\u056f\u0576\u0561\u0562\u0561\u0576\u0578\u0582\u0569\u0575\u0578\u0582\u0576\u0568","sniff_comment_tooltip_unlike":"\u0549\u0570\u0561\u057e\u0561\u0576\u0565\u056c \u0561\u0575\u057d \u0574\u0565\u056f\u0576\u0561\u0562\u0561\u0576\u0578\u0582\u0569\u0575\u0578\u0582\u0576\u0568"},"id_ID":{"fb_composer_lessons":"Apa pelajaran yang kalian dapat tentang persahabatan hari ini?","sniff_comment_tooltip_like":"Suka komentar ini","sniff_comment_tooltip_unlike":"Tidak suka komentar ini","close":"Tutup"},"is_IS":{"sniff_comment_tooltip_like":"L\u00edkar vi\u00f0 \u00feessi umm\u00e6li","sniff_comment_tooltip_unlike":"L\u00edka ekki vi\u00f0 \u00feessi umm\u00e6li"},"it_IT":{"fb_composer_lessons":"Che cosa hai imparato oggi sull'amicizia?","sniff_comment_tooltip_like":"Di' che ti piace questo commento","sniff_comment_tooltip_unlike":"Di' che non ti piace pi\u00f9 questo commento","close":"Chiudi"},"ja_JP":{"fb_composer_lessons":"\u4eca\u65e5\u306f\u53cb\u60c5\u306b\u3069\u306e\u3088\u3046\u306a\u6559\u8a13\u3092\u5b66\u3073\u307e\u3057\u305f\u304b\uff1f","sniff_comment_tooltip_like":"\u3053\u306e\u30b3\u30e1\u30f3\u30c8\u306f\u3044\u3044\u306d\uff01","sniff_comment_tooltip_unlike":"\u3044\u3044\u306d\uff01\u3092\u53d6\u308a\u6d88\u3059","close":"\u9589\u3058\u308b"},"ka_GE":{"sniff_comment_tooltip_like":"\u10db\u10dd\u10d8\u10ec\u10dd\u10dc\u10d4 \u10d4\u10e1 \u10d9\u10dd\u10db\u10d4\u10dc\u10e2\u10d0\u10e0\u10d8","sniff_comment_tooltip_unlike":"\u10d0\u10e6\u10d0\u10e0 \u10db\u10dd\u10db\u10ec\u10dd\u10dc\u10e1 \u10d4\u10e1 \u10d9\u10dd\u10db\u10d4\u10dc\u10e2\u10d0\u10e0\u10d8"},"km_KH":{"sniff_comment_tooltip_like":"\u1785\u17bc\u179b\u1785\u17b7\u178f\u17d2\u178f \u179c\u17b7\u1785\u17b6\u179a \u1793\u17c1\u17c7","sniff_comment_tooltip_unlike":"\u179b\u17c2\u1784\u1785\u17bc\u179b\u1785\u17b7\u178f\u17d2\u178f\u1798\u178f\u17b7\u1793\u17c1\u17c7"},"ko_KR":{"fb_composer_lessons":"\uc6b0\uc815\uc5d0 \uad00\ud574\uc11c \uc624\ub298 \ubb34\uc5c7\uc744 \ubc30\uc6e0\ub098\uc694?","sniff_comment_tooltip_like":"\uc88b\uc544\uc694","sniff_comment_tooltip_unlike":"\uc88b\uc544\uc694 \ucde8\uc18c","close":"\ub2eb\uae30"},"ku_TR":{"sniff_comment_tooltip_like":"V\u00ea \u015f\u00eerovey\u00ea biecib\u00eene","sniff_comment_tooltip_unlike":"V\u00ea \u015firovey\u00ea neecib\u00eene"},"la_VA":[],"lt_LT":{"fb_composer_lessons":"Kokias \u017einias apie draugyst\u0119 i\u0161mokote \u0161iandien?","sniff_comment_tooltip_like":"Patinka \u0161is komentaras","sniff_comment_tooltip_unlike":"Nepatinka \u0161is komentaras","close":"U\u017edaryti"},"lv_LV":{"sniff_comment_tooltip_unlike":"Koment\u0101rs vairs nepat\u012bk"},"mk_MK":{"fb_composer_lessons":"\u041a\u043e\u0438 \u043b\u0435\u043a\u0446\u0438\u0438 \u0437\u0430 \u043f\u0440\u0438\u0458\u0430\u0442\u0435\u043b\u0441\u0442\u0432\u043e\u0442\u043e \u0434\u043e\u0437\u043d\u0430\u0432\u0442\u0435 \u0434\u0435\u043d\u0435\u0441?","sniff_comment_tooltip_like":"\u041c\u0438 \u0441\u0435 \u0434\u043e\u043f\u0430\u0453\u0430 \u043a\u043e\u043c\u0435\u043d\u0442\u0430\u0440\u043e\u0432","sniff_comment_tooltip_unlike":"\u041d\u0435 \u043c\u0438 \u0441\u0435 \u0434\u043e\u043f\u0430\u0453\u0430","close":"\u0417\u0430\u0442\u0432\u043e\u0440\u0438"},"ml_IN":{"sniff_comment_tooltip_like":"\u0d08 \u0d05\u0d2d\u0d3f\u0d2a\u0d4d\u0d30\u0d3e\u0d2f\u0d02 \u0d07\u0d37\u0d4d\u0d1f\u0d2e\u0d3e\u0d2f\u0d3f"},"ms_MY":{"fb_composer_lessons":"Apakah pelajaran tentang persahabatan yang telah anda pelajari hari ini?","fb_comment_box":"Tuliskan surat persahabatan...","fb_composer_ponies":"Kuda!","fb_composer_ponies_caps":"KUDA!!!","sniff_comment_tooltip_like":"Suka komen ini","sniff_comment_tooltip_unlike":"Tidak suka komen ini","close":"Tutup","options_title":"Opsyen Ponyhoof"},"nb_NO":{"sniff_comment_tooltip_like":"Lik denne kommentaren"},"ne_NP":[],"nl_NL":{"fb_composer_lessons":"Wat heb je vandaag geleerd over vriendschap?","sniff_comment_tooltip_like":"Leuke reactie","sniff_comment_tooltip_unlike":"Reactie niet meer leuk","close":"Sluiten"},"pa_IN":{"sniff_comment_tooltip_like":"\u0a07\u0a39 \u0a1f\u0a3f\u0a71\u0a2a\u0a23\u0a40 \u0a2a\u0a38\u0a70\u0a26 \u0a15\u0a30\u0a4b","sniff_comment_tooltip_unlike":"\u0a07\u0a39 \u0a1f\u0a3f\u0a71\u0a2a\u0a23\u0a40 \u0a28\u0a3e\u0a2a\u0a38\u0a70\u0a26 \u0a15\u0a30\u0a4b|"},"pl_PL":{"fb_composer_lessons":"Czego si\u0119 dzisiaj nauczy\u0142e\u015b o przyja\u017ani?","sniff_comment_tooltip_like":"Polub komentarz","sniff_comment_tooltip_unlike":"Nie lubi\u0119 tego komentarza","close":"Zamknij"},"ps_AF":[],"pt_BR":{"fb_composer_lessons":"Quais li\u00e7\u00f5es sobre amizade voc\u00ea aprendeu hoje?","sniff_comment_tooltip_like":"Curtir este coment\u00e1rio","sniff_comment_tooltip_unlike":"Curtir (desfazer) este coment\u00e1rio","close":"Fechar"},"pt_PT":{"fb_composer_lessons":"Que li\u00e7\u00f5es de amizade voc\u00ea aprendeu hoje?","sniff_comment_tooltip_like":"Gosto deste coment\u00e1rio","sniff_comment_tooltip_unlike":"N\u00e3o gosto deste coment\u00e1rio","close":"Fechar"},"ro_RO":{"fb_composer_lessons":"Ce lec\u0163ii despre prietenie ai \u00eenv\u0103\u0163at ast\u0103zi?","sniff_comment_tooltip_like":"\u00cemi place acest comentariu","sniff_comment_tooltip_unlike":"Nu-mi mai place acest comentariu","close":"\u00cenchide"},"ru_RU":{"fb_composer_lessons":"\u041a\u0430\u043a\u0438\u0435 \u0443\u0440\u043e\u043a\u0438 \u0434\u0440\u0443\u0436\u0431\u044b \u0432\u044b \u0432\u044b\u0443\u0447\u0438\u043b\u0438 \u0441\u0435\u0433\u043e\u0434\u043d\u044f?","sniff_comment_tooltip_like":"\u041c\u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439","sniff_comment_tooltip_unlike":"\u041d\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f","close":"\u0417\u0430\u043a\u0440\u044b\u0442\u044c"},"sk_SK":{"fb_composer_lessons":"Ak\u00e9 lekcie priate\u013estva si sa nau\u010dil dnes?","sniff_comment_tooltip_like":"P\u00e1\u010di sa mi tento koment\u00e1r","sniff_comment_tooltip_unlike":"Tento koment\u00e1r sa mi u\u017e nep\u00e1\u010di","close":"Zavrie\u0165"},"sl_SI":{"fb_composer_lessons":"Kaj si se o prijateljstvu nau\u010dil\/-a danes?","sniff_comment_tooltip_like":"V\u0161e\u010d mi je","sniff_comment_tooltip_unlike":"Ta komentar mi ni v\u0161e\u010d","close":"Zapri"},"sq_AL":{"sniff_comment_tooltip_like":"P\u00eblqeje k\u00ebt\u00eb koment","sniff_comment_tooltip_unlike":"Mos p\u00eblqe k\u00ebt\u00eb koment"},"sr_RS":{"sniff_comment_tooltip_like":"\u0421\u0432\u0438\u0452\u0430 \u043c\u0438 \u0441\u0435 \u043a\u043e\u043c\u0435\u043d\u0442\u0430\u0440.","sniff_comment_tooltip_unlike":"\u041d\u0435 \u0441\u0432\u0438\u0452\u0430 \u043c\u0438 \u0441\u0435 \u043e\u0432\u0430\u0458 \u043a\u043e\u043c\u0435\u043d\u0442\u0430\u0440","close":"\u0417\u0430\u0442\u0432\u043e\u0440\u0438"},"sv_SE":{"fb_composer_lessons":"Vilka l\u00e4rdomar i v\u00e4nskap har du l\u00e4rt dig idag?","sniff_comment_tooltip_like":"Gilla den h\u00e4r kommentaren","sniff_comment_tooltip_unlike":"Sluta gilla den h\u00e4r kommentaren","close":"St\u00e4ng"},"sw_KE":[],"ta_IN":{"sniff_comment_tooltip_like":"\u0b87\u0b95\u0bcd\u0b95\u0bb0\u0bc1\u0ba4\u0bcd\u0ba4\u0bbf\u0ba9\u0bc8 \u0bb5\u0bbf\u0bb0\u0bc1\u0bae\u0bcd\u0baa\u0bc1\u0b95\u0bbf\u0bb1\u0bc7\u0ba9\u0bcd","sniff_comment_tooltip_unlike":"\u0b87\u0b95\u0bcd\u0b95\u0bb0\u0bc1\u0ba4\u0bcd\u0ba4\u0bbf\u0ba9\u0bc8 \u0bb5\u0bbf\u0bb0\u0bc1\u0bae\u0bcd\u0baa\u0bb5\u0bbf\u0bb2\u0bcd\u0bb2\u0bc8","close":"\u0e1b\u0e34\u0e14"},"te_IN":{"sniff_comment_tooltip_unlike":"\u0c35\u0c4d\u0c2f\u0c3e\u0c16\u0c4d\u0c2f \u0c28\u0c1a\u0c4d\u0c1a\u0c32\u0c47\u0c26\u0c41"},"th_TH":{"sniff_comment_tooltip_like":"\u0e16\u0e39\u0e01\u0e43\u0e08\u0e04\u0e27\u0e32\u0e21\u0e04\u0e34\u0e14\u0e40\u0e2b\u0e47\u0e19\u0e19\u0e35\u0e49","sniff_comment_tooltip_unlike":"\u0e40\u0e25\u0e34\u0e01\u0e16\u0e39\u0e01\u0e43\u0e08\u0e04\u0e27\u0e32\u0e21\u0e04\u0e34\u0e14\u0e40\u0e2b\u0e47\u0e19\u0e19\u0e35\u0e49"},"tl_PH":{"fb_composer_lessons":"Anong mga aralin sa pagkakaibigan ang natutunan mo ngayon?","sniff_comment_tooltip_like":"Gustuhin ang komentong ito","sniff_comment_tooltip_unlike":"Ayawan ang komentong ito","close":"Isara"},"tr_TR":{"fb_composer_lessons":"Bug\u00fcn arkada\u015fl\u0131kla ilgili neler \u00f6\u011frendin?","sniff_comment_tooltip_like":"Bu yorumu be\u011fen","sniff_comment_tooltip_unlike":"Bu yorumu be\u011fenmekten vazge\u00e7","close":"Kapat"},"uk_UA":{"fb_composer_lessons":"\u042f\u043a\u0456 \u0443\u0440\u043e\u043a\u0438 \u0432 \u0434\u0440\u0443\u0436\u0431\u0456 \u0432\u0438 \u0434\u0456\u0437\u043d\u0430\u043b\u0438\u0441\u044f \u0441\u044c\u043e\u0433\u043e\u0434\u043d\u0456?","sniff_comment_tooltip_like":"\u0412\u043f\u043e\u0434\u043e\u0431\u0430\u0442\u0438 \u043a\u043e\u043c\u0435\u043d\u0442\u0430\u0440","sniff_comment_tooltip_unlike":"\u041d\u0435 \u043f\u043e\u0434\u043e\u0431\u0430\u0454\u0442\u044c\u0441\u044f \u043a\u043e\u043c\u0435\u043d\u0442\u0430\u0440","close":"\u0417\u0430\u043a\u0440\u0438\u0442\u0438"},"vi_VN":{"sniff_comment_tooltip_like":"Th\u00edch b\u00ecnh lu\u1eadn n\u00e0y","sniff_comment_tooltip_unlike":"B\u1ecf th\u00edch b\u00ecnh lu\u1eadn n\u00e0y n\u1eefa"},"zh_CN":{"sniff_comment_tooltip_like":"\u559c\u6b22\u6b64\u8bc4\u8bba","sniff_comment_tooltip_unlike":"\u4e0d\u559c\u6b22\u6b64\u8bc4\u8bba","close":"\u5173\u95ed"},"zh_HK":{"sniff_comment_tooltip_like":"\u5c0d\u9019\u5247\u7559\u8a00\u8b9a\u597d","sniff_comment_tooltip_unlike":"\u53d6\u6d88\u8b9a\u597d"},"zh_TW":{"fb_composer_lessons":"\u4f60\u4eca\u5929\u5f9e\u53cb\u60c5\u88e1\u9762\u5b78\u5230\u4e86\u4ec0\u9ebc\uff1f","sniff_comment_tooltip_like":"\u8aaa\u9019\u5247\u7559\u8a00\u8b9a","sniff_comment_tooltip_unlike":"\u6536\u56de\u8b9a","close":"\u95dc\u9589"}};
1212 var SOUNDS = {"AUTO":{"name":"(Auto-select)","seperator":true},"_sound\/defaultNotification":{"name":"Casting magic","title":"This will also be used for characters that do not have their own notification sound"},"trixie\/notif":{"name":"Trixie - Watch in awe!"},"dash\/notif":{"name":"Rainbow Dash - Aww yeah!"},"pinkie\/notif2":{"name":"Pinkie Pie - *rimshot*"},"applej\/notif":{"name":"Applejack - Yeehaw!"},"flutter\/notif2":{"name":"Fluttershy - Yay!"},"rarity\/notif":{"name":"Rarity - This is whining!"},"applebloom\/notif":{"name":"Apple Bloom - That'll be four bits"},"bigmac\/notif":{"name":"Big Macintosh - Eeyup"},"colgate\/notif":{"name":"Colgate - Why you don't brush your teeth"},"derpy\/notif":{"name":"Derpy Hooves - I brought you a letter!"},"luna\/notif":{"name":"Luna - Huzzah!"},"_sound\/roidrage_yeah":{"name":"Roid Rage\/Snowflake - YEAH!"},"sweetieb\/notif":{"name":"Sweetie Belle - Oh come on!"},"vinyl\/notif":{"name":"Vinyl Scratch - Yeah!","seperator":true},"twilight\/notif":{"name":"Twilight Sparkle - It's not over yet!"},"_sound\/grin2":{"name":"Fluttershy - *squee*"},"_sound\/dash_dundundun":{"name":"Rainbow Dash - DUN DUN DUN"},"_sound\/dash_egghead":{"name":"Rainbow Dash - I'm an egghead"},"_sound\/pinkie_boring":{"name":"Pinkie Pie - Booooring!"},"_sound\/pinkie_gasp":{"name":"Pinkie Pie - *gasp*"},"_sound\/pinkie_partycannon":{"name":"Pinkie Pie - Party cannon"},"_sound\/pinkie_pinkiepiestyle":{"name":"Pinkie Pie - Pinkie Pie style!"},"_sound\/flutter_woohoo":{"name":"Fluttershy - Woo hoo"},"_sound\/octavia_nevermess":{"name":"Octavia - Never mess with Octavia"},"_sound\/rarity_dumbrock":{"name":"Rarity - Dumb rock!"},"_sound\/rarity_itison":{"name":"Rarity - Oh. It. Is. On!"},"_sound\/rarity_wahaha":{"name":"Rarity - Wahaha!"},"_sound\/vinyl_awyeah":{"name":"Vinyl Scratch - Aw yeah!"},"_sound\/vinyl_mybasscannon":{"name":"Vinyl Scratch - My bass cannon!"},"_sound\/vinyl_wubwubwub":{"name":"Vinyl Scratch - Wubwubwub"},"_sound\/vinyl_wubedubdub":{"name":"Vinyl Scratch - Wubedubdub"},"_sound\/vinyl_yougotwubs":{"name":"Vinyl Scratch - You got wubs"}};
1213 var SOUNDS_CHAT = {"_sound\/grin2":{"name":"Fluttershy - *squee*"},"_sound\/chat_boing":{"name":"Boing"}};
1214 var HTMLCLASS_SETTINGS = ['login_bg', 'show_messages_other', 'disable_animation', 'pinkieproof', 'disable_emoticons'];
1215 var DEFAULTSETTINGS = {
1216 'theme':CURRENTPONY,
1217 'login_bg':false, 'customBg':null, //'allowLoginScreen':true,
1218 'sounds':false, 'soundsFile':'AUTO', 'soundsNotifTypeBlacklist':'', 'soundsVolume':1, 'chatSound':true, 'chatSoundFile':'_sound/grin2',
1219 'show_messages_other':true, 'pinkieproof':false, 'forceEnglish':false, 'disable_emoticons':false, 'randomPonies':'', 'costume': '', //'commentBrohoofed':true,
1220 'disable_animation':false, 'disableDomNodeInserted':false, //'disableCommentBrohoofed':false,
1221 'customcss':'', 'debug_dominserted_console':false, 'debug_slow_load':false, 'debug_disablelog':false, 'debug_noMutationObserver':false, 'debug_mutationDebug':false, 'debug_exposed':false, 'debug_betaFacebookLinks':false, //'debug_mutationObserver':false,
1222 //'lastVersion':''
1223
1224 //'survivedTheNight', 'chatSound1401', 'randomSettingMigrated'
1225 };
1226 var STACKS_LANG = [{"stack":"pony","people":"ponies","person":"pony","friend":"pal","friends":"pals","friend_logic":"pal","friends_logic":"pals","like":"brohoof","likes":"brohoofs","unlike":"unbrohoof","like_past":"brohoof","likes_past":"brohoofs","liked":"brohoof'd","liked_button":"brohoof'd","liking":"brohoofing"},{"stack":"chrysalis","people":"changelings","person":"changeling","friend":"prey","friends":"prey","friend_logic":"changeling","friends_logic":"changelings","like":"feed","likes":"feeds","unlike":"unfeed","like_past":"fed on","likes_past":"fed on","liked":"fed on","liked_button":"fed","liking":"feeding"},{"stack":"villian","people":"ponies","person":"changeling","friend":"pal","friends":"pals","friend_logic":"pal","friends_logic":"pals","like":"brohoof","likes":"brohoofs","unlike":"unbrohoof","like_past":"brohoof","likes_past":"brohoofs","liked":"brohoof'd","liked_button":"brohoof'd","liking":"brohoofing"}];
1227 var CURRENTSTACK = STACKS_LANG[0];
1228 var COSTUMESX = {"winterwrapup":{"name":"Winter Wrap Up","characters":["twilight","dash","pinkie","applej","flutter","rarity","derpy"]},"nightmarenight":{"name":"Nightmare Night","characters":["twilight","dash","pinkie","applej","flutter","applebloom","bigmac","derpy","luna","scootaloo","spike","sweetieb","zecora"]},"hearthwarming":{"name":"Hearth's Warming","characters":["twilight","dash","pinkie","applej","flutter","rarity"]},"season3premiere":{"name":"Season 3 Premiere","characters":["twilight","rarity"]},"crystal":{"name":"Crystal Pony","characters":["twilight","dash","pinkie","applej","flutter","rarity","cadance"]},"wedding":{"name":"Canterlot Wedding","characters":["sweetieb"]},"coronation":{"name":"Princess Coronation Dresses","characters":["dash","pinkie","applej","flutter","rarity","cadance"]},"princess":{"name":"Princess Twilight Sparkle","characters":["twilight"]}};
1229 var SOUNDS_NOTIFTYPE = {
1230 poke: {name:"Nuzzles", type:"poke"}
1231 ,like: {name:"Brohoofs", type:"like"}
1232 ,group_activity: {name:"New posts in herds and tags about you", type:"group_activity"}
1233 ,group_r2j: {name:"Herd join requests", type:"group_r2j"}
1234 ,group_added_to_group: {name:"Herd invites from friends", type:"group_added_to_group"}
1235 ,plan_reminder: {name:"Adventure reminders", type:"plan_reminder"}
1236 ,follow_profile: {name:"New followers", type:"follow_profile"}
1237 ,photo_made_profile_pic: {name:"Made your pony pic his/her profile picture", type:"photo_made_profile_pic"}
1238 ,answers_answered: {name:"New answers on the Facebook Help Center", type:"answers_answered"}
1239
1240 ,app_invite: {name:"Game/app requests", type:"app_invite"}
1241 ,close_friend_activity: {name:"Posts from Close Friends", type:"close_friend_activity"}
1242 ,notify_me: {name:"Page posts that you subscribed to", type:"notify_me"}
1243
1244 //,fbpage_presence: {name:"Facebook nagging you to post to your page", type:"fbpage_presence"}
1245 ,fbpage_fan_invite: {name:"Page invites from friends", type:"fbpage_fan_invite"}
1246 ,page_new_likes: {name:"New page brohoofs", type:"page_new_likes"}
1247 //,fbpage_new_message: {name:"New private messages on your page", type:"fbpage_new_message"}
1248 };
1249
1250 var THEMEURL = w.location.protocol + '//hoof.little.my/files/';
1251 var THEMECSS = THEMEURL+'';
1252 var THEMECSS_EXT = '.css?userscript_version='+VERSION;
1253 var UPDATEURL = w.location.protocol + '//hoof.little.my/files/update_check.js?' + (+new Date());
1254
1255 var PONYHOOF_PAGE = '197956210325433';
1256 var PONYHOOF_URL = '//'+getFbDomain()+'/Ponyhoof';
1257 var PONYHOOF_README = '//hoof.little.my/files/_welcome/readme.htm?version='+VERSION+'&distribution='+DISTRIBUTION;
1258
1259 var _ext_messageId = 0;
1260 var _ext_messageCallback = {};
1261
1262 // Chrome
1263 var chrome_sendMessage = function(message, callback) {
1264 if (chrome.extension.sendMessage) {
1265 chrome.extension.sendMessage(message, callback);
1266 } else {
1267 chrome.extension.sendRequest(message, callback);
1268 }
1269 };
1270
1271 var chrome_storageFallback = false;
1272 var chrome_getValue = function(name, callback) {
1273 if (chrome.storage && !chrome_storageFallback) {
1274 chrome.storage.local.get(name, function(item) {
1275 if (chrome.runtime && chrome.runtime.lastError) {
1276 // Fallback to old storage method
1277 chrome_storageFallback = true;
1278 chrome_getValue(name, callback);
1279 return;
1280 }
1281
1282 if (Object.keys(item).length === 0) {
1283 callback(null);
1284 return;
1285 }
1286 callback(item[name]);
1287 });
1288 return;
1289 }
1290
1291 try {
1292 chrome_sendMessage({'command':'getValue', 'name':name}, function(response) {
1293 if (response && typeof response.val != 'undefined') {
1294 callback(response.val);
1295 } else {
1296 callback(null);
1297 }
1298 });
1299 } catch (e) {
1300 dir(e);
1301 getValueError(e);
1302 callback(null);
1303 }
1304 };
1305
1306 var chrome_setValue = function(name, val) {
1307 if (chrome.storage && !chrome_storageFallback) {
1308 var toSet = {};
1309 toSet[name] = val;
1310 chrome.storage.local.set(toSet, function() {
1311 if (chrome.runtime && chrome.runtime.lastError) {
1312 saveValueError(chrome.runtime.lastError);
1313 return;
1314 }
1315 });
1316 return;
1317 }
1318
1319 chrome_sendMessage({'command':'setValue', 'name':name, 'val':val}, function() {});
1320 };
1321
1322 var chrome_clearStorage = function() {
1323 if (chrome.storage) {
1324 chrome.storage.local.clear();
1325 }
1326 chrome_sendMessage({'command':'clearStorage'}, function() {});
1327 };
1328
1329 var chrome_ajax = function(details) {
1330 chrome_sendMessage({'command': 'ajax', 'details': details}, function(response) {
1331 if (response.val == 'success') {
1332 if (details.onload) {
1333 details.onload(response.request);
1334 }
1335 } else {
1336 if (details.onerror) {
1337 details.onerror(response.request);
1338 }
1339 }
1340 });
1341 };
1342
1343 if (ISOPERA) {
1344 if (opera.extension) {
1345 opera.extension.onmessage = function(message) {
1346 if (message.data) {
1347 var response = message.data;
1348 var callback = _ext_messageCallback[response.messageid];
1349 if (callback) {
1350 callback(response.val);
1351 }
1352 }
1353 }
1354 }
1355
1356 var opera_getValue = function(name, callback) {
1357 _ext_messageCallback[_ext_messageId] = callback;
1358 opera.extension.postMessage({'command':'getValue', 'messageid':_ext_messageId, 'name':name});
1359 _ext_messageId += 1;
1360 };
1361
1362 var opera_setValue = function(name, val) {
1363 opera.extension.postMessage({'command':'setValue', 'name':name, 'val':val});
1364 };
1365
1366 var opera_clearStorage = function() {
1367 opera.extension.postMessage({'command':'clearStorage'});
1368 };
1369
1370 var opera_ajax = function(details) {
1371 _ext_messageCallback[_ext_messageId] = function(response) {
1372 if (response.val == 'success') {
1373 if (details.onload) {
1374 details.onload(response.request);
1375 }
1376 } else {
1377 if (details.onerror) {
1378 details.onerror(response.request);
1379 }
1380 }
1381 };
1382 var detailsX = {
1383 'method': details.method
1384 ,'url': details.url
1385 ,'headers': details.headers
1386 ,'data': details.data
1387 };
1388 opera.extension.postMessage({'command':'ajax', 'messageid':_ext_messageId, 'details':detailsX});
1389 _ext_messageId += 1;
1390 };
1391 }
1392
1393 if (ISSAFARI) {
1394 if (typeof safari != 'undefined') {
1395 safari.self.addEventListener('message', function(message) {
1396 var data = message.message;
1397 if (data) {
1398 var response = data;
1399 var callback = _ext_messageCallback[message.name];
1400 if (callback) {
1401 callback(response.val);
1402 }
1403 }
1404 });
1405 }
1406
1407 var safari_getValue = function(name, callback) {
1408 _ext_messageId = md5(Math.random().toString()); // safari, you don't know what's message passing/callbacks, do you?
1409 _ext_messageCallback[_ext_messageId] = callback;
1410 safari.self.tab.dispatchMessage('getValue', {'messageid':_ext_messageId, 'name':name});
1411 //_ext_messageId += 1;
1412 };
1413
1414 var safari_setValue = function(name, val) {
1415 safari.self.tab.dispatchMessage('setValue', {'name':name, 'val':val});
1416 };
1417
1418 var safari_clearStorage = function() {
1419 safari.self.tab.dispatchMessage('clearStorage', {});
1420 };
1421
1422 var safari_ajax = function(details) {
1423 _ext_messageId = md5(Math.random().toString());
1424 _ext_messageCallback[_ext_messageId] = function(response) {
1425 if (response.val == 'success') {
1426 if (details.onload) {
1427 details.onload(response.request);
1428 }
1429 } else {
1430 if (details.onerror) {
1431 details.onerror(response.request);
1432 }
1433 }
1434 };
1435 var detailsX = {
1436 'method': details.method
1437 ,'url': details.url
1438 ,'headers': details.headers
1439 ,'data': details.data
1440 };
1441 safari.self.tab.dispatchMessage('ajax', {'messageid':_ext_messageId, 'details':detailsX});
1442 //_ext_messageId += 1;
1443 };
1444 }
1445
1446 if (ISFIREFOX && typeof self != 'undefined' && typeof self.on != 'undefined') {
1447 self.on('message', function(message) {
1448 var data = message;
1449 if (data) {
1450 var response = data;
1451 var callback = _ext_messageCallback[message.messageid];
1452 if (callback) {
1453 callback(response.val);
1454 }
1455 }
1456 });
1457 var xpi_getValue = function(name, callback) {
1458 _ext_messageCallback[_ext_messageId] = callback;
1459 self.postMessage({'command':'getValue', 'messageid':_ext_messageId, 'name':name});
1460 _ext_messageId += 1;
1461 };
1462
1463 var xpi_setValue = function(name, val) {
1464 self.postMessage({'command':'setValue', 'name':name, 'val':val});
1465 };
1466
1467 var xpi_clearStorage = function(name, val) {
1468 self.postMessage({'command':'clearStorage'});
1469 };
1470
1471 var xpi_ajax = function(details) {
1472 _ext_messageCallback[_ext_messageId] = function(response) {
1473 if (response.val == 'success') {
1474 if (details.onload) {
1475 details.onload(response.request);
1476 }
1477 } else {
1478 if (details.onerror) {
1479 details.onerror(response.request);
1480 }
1481 }
1482 };
1483 var detailsX = {
1484 'method': details.method
1485 ,'url': details.url
1486 ,'headers': details.headers
1487 ,'data': details.data
1488 };
1489 self.postMessage({'command':'ajax', 'messageid':_ext_messageId, 'details':detailsX});
1490 _ext_messageId += 1;
1491 };
1492 }
1493
1494 if (typeof w.external != 'undefined' && typeof w.external.mxGetRuntime != 'undefined') {
1495 var maxthonRuntime = w.external.mxGetRuntime();
1496
1497 maxthonRuntime.listen('messageContentScript', function(message) {
1498 var data = message;
1499 if (data) {
1500 var response = data;
1501 var callback = _ext_messageCallback[message.messageid];
1502 if (callback) {
1503 callback(response.val);
1504 }
1505 }
1506 });
1507
1508 var mxaddon_ajax = function(details) {
1509 _ext_messageCallback[_ext_messageId] = function(response) {
1510 if (response.val == 'success') {
1511 if (details.onload) {
1512 details.onload(response.request);
1513 }
1514 } else {
1515 if (details.onerror) {
1516 details.onerror(response.request);
1517 }
1518 }
1519 };
1520 var detailsX = {
1521 'method': details.method
1522 ,'url': details.url
1523 ,'headers': details.headers
1524 ,'data': details.data
1525 };
1526 maxthonRuntime.post('messageBackground', {'command':'ajax', 'messageid':_ext_messageId, 'details':detailsX});
1527 _ext_messageId += 1;
1528 };
1529 }
1530
1531 function ajax(obj) {
1532 switch (STORAGEMETHOD) {
1533 case 'greasemonkey':
1534 return GM_xmlhttpRequest(obj);
1535
1536 case 'chrome':
1537 return chrome_ajax(obj);
1538
1539 case 'opera':
1540 return opera_ajax(obj);
1541
1542 case 'safari':
1543 return safari_ajax(obj);
1544
1545 case 'xpi':
1546 return xpi_ajax(obj);
1547
1548 case 'mxaddon':
1549 return mxaddon_ajax(obj);
1550
1551 default:
1552 break;
1553 }
1554
1555 throw {
1556 responseXML:''
1557 ,responseText:''
1558 ,readyState:4
1559 ,responseHeaders:''
1560 ,status:-100
1561 ,statusText:'No GM_xmlhttpRequest support'
1562 };
1563 }
1564
1565 function isPonyhoofPage(id) {
1566 if (id == PONYHOOF_PAGE) {
1567 return true;
1568 }
1569 return false;
1570 }
1571
1572 function capitaliseFirstLetter(string) {
1573 return string.charAt(0).toUpperCase() + string.slice(1);
1574 }
1575
1576 // Settings
1577 for (var i in HTMLCLASS_SETTINGS) {
1578 if (!DEFAULTSETTINGS[HTMLCLASS_SETTINGS[i]]) {
1579 DEFAULTSETTINGS[HTMLCLASS_SETTINGS[i]] = false;
1580 }
1581 }
1582 //DEFAULTSETTINGS.show_messages_other = true;
1583 if (ISMOBILE) {
1584 DEFAULTSETTINGS.disable_animation = true;
1585 }
1586
1587 function getValueError(extra) {
1588 if (extra === 'ModuleSystem has been deleted' || extra === 'TypeError: Cannot read property \'sendMessage\' of undefined' || extra === '<code>ModuleSystem has been deleted</code>' || extra === '<code>TypeError: Cannot read property \'sendMessage\' of undefined</code>') {
1589 createSimpleDialog('localStorageError_getValueChromeExt', "Ponyhoof derp'd", "Ponyhoof has been disabled/updated recently. Please reload the page in order for Ponyhoof to work properly.");
1590 } else {
1591 createSimpleDialog('localStorageError_getValue', "Ponyhoof derp'd", "Ponyhoof can't load your settings. Please try again later.<br><br>If you keep seeing this error, please update to the latest version of Ponyhoof if available and <a href=\""+w.location.protocol+PONYHOOF_URL+"\" data-hovercard=\"/ajax/hovercard/page.php?id="+PONYHOOF_PAGE+"\">visit the Ponyhoof page for help</a>.<br><br>"+extra);
1592 }
1593
1594 trace();
1595 }
1596
1597 function saveValueError(extra) {
1598 var desc = "Ponyhoof can't save your settings. There might be a conflict with another extension installed on your browser. Please try again later.<br><br>If you keep seeing this error, please update to the latest version of Ponyhoof if available and <a href=\""+w.location.protocol+PONYHOOF_URL+"\" data-hovercard=\"/ajax/hovercard/page.php?id="+PONYHOOF_PAGE+"\">visit the Ponyhoof page for help</a>.<br><br>"+extra;
1599 createSimpleDialog('localStorageError_saveValue', "Ponyhoof derp'd", desc);
1600
1601 trace();
1602 }
1603
1604 function ponyhoofError(extra) {
1605 createSimpleDialog('ponyhoofError', "Ponyhoof derp'd", "Ponyhoof encountered an internal error. Please try again later and update to the latest version of Ponyhoof if available.<br><br>"+extra);
1606
1607 trace();
1608 }
1609
1610 function getValue(name, callback) {
1611 switch (STORAGEMETHOD) {
1612 case 'greasemonkey':
1613 callback(GM_getValue(name));
1614 break;
1615
1616 case 'chrome':
1617 chrome_getValue(name, callback);
1618 break;
1619
1620 case 'opera':
1621 opera_getValue(name, callback);
1622 break;
1623
1624 case 'safari':
1625 safari_getValue(name, callback);
1626 break;
1627
1628 case 'xpi':
1629 xpi_getValue(name, callback);
1630 break;
1631
1632 case 'mxaddon':
1633 callback(w.external.mxGetRuntime().storage.getConfig(name));
1634 break;
1635
1636 case 'localstorage':
1637 default:
1638 name = 'ponyhoof_'+name;
1639 callback(w.localStorage.getItem(name));
1640 break;
1641 }
1642 }
1643
1644 function saveValue(name, v) {
1645 switch (STORAGEMETHOD) {
1646 case 'greasemonkey':
1647 GM_setValue(name, v);
1648 break;
1649
1650 case 'chrome':
1651 chrome_setValue(name, v);
1652 break;
1653
1654 case 'opera':
1655 opera_setValue(name, v);
1656 break;
1657
1658 case 'safari':
1659 safari_setValue(name, v);
1660 break;
1661
1662 case 'xpi':
1663 xpi_setValue(name, v);
1664 break;
1665
1666 case 'mxaddon':
1667 w.external.mxGetRuntime().storage.setConfig(name, v);
1668 break;
1669
1670 case 'localstorage':
1671 default:
1672 name = 'ponyhoof_'+name;
1673 w.localStorage.setItem(name, v);
1674 break;
1675 }
1676 }
1677
1678 function loadSettings(callback, opts) {
1679 // opts => prefix, defaultsettings
1680 var opts = opts || {prefix:null};
1681 var settingsKey = 'settings';
1682 if (opts.prefix != null) {
1683 settingsKey = opts.prefix+settingsKey;
1684 } else {
1685 settingsKey = SETTINGSPREFIX+settingsKey;
1686 }
1687 if (!opts.defaultSettings) {
1688 opts.defaultSettings = DEFAULTSETTINGS;
1689 }
1690
1691 try {
1692 getValue(settingsKey, function(s) {
1693 if (s) {
1694 s = JSON.parse(s);
1695 if (!s) {
1696 s = {};
1697 }
1698 } else {
1699 s = {};
1700 }
1701 for (var i in opts.defaultSettings) {
1702 if (!s.hasOwnProperty(i)) {
1703 s[i] = opts.defaultSettings[i];
1704 }
1705 }
1706 callback(s);
1707 });
1708 } catch (e) {
1709 dir(e);
1710
1711 var extra = '';
1712 if (e.message) {
1713 extra = "<code>"+e.message+"</code>";
1714 } else {
1715 extra = "<code>"+e.toString()+"</code>";
1716 }
1717 try {
1718 getValueError(extra);
1719 } catch (e) {
1720 onPageReady(function() {
1721 if (d.body) {
1722 getValueError(extra);
1723 }
1724 });
1725 }
1726 callback();
1727 return false;
1728 }
1729 }
1730
1731 function saveSettings(opts) {
1732 // opts => prefix, settings
1733 var opts = opts || {prefix:null, settings:userSettings};
1734 var settingsKey = 'settings';
1735 if (opts.prefix != null) {
1736 settingsKey = opts.prefix+settingsKey;
1737 } else {
1738 settingsKey = SETTINGSPREFIX+settingsKey;
1739 }
1740 var settings = userSettings;
1741 if (opts.settings) {
1742 settings = opts.settings;
1743 }
1744
1745 try {
1746 saveValue(settingsKey, JSON.stringify(settings));
1747 return true;
1748 } catch (e) {
1749 dir(e);
1750
1751 var extra = '';
1752 if (e.message) {
1753 if (e.message == 'ModuleSystem has been deleted' || e.message == 'TypeError: Cannot read property \'sendMessage\' of undefined') {
1754 createSimpleDialog('localStorageError_setValueChromeExt', "Ponyhoof derp'd", "Ponyhoof has been disabled/updated recently. Please reload the page in order for Ponyhoof to work properly.");
1755 callback();
1756 return;
1757 }
1758
1759 extra = "<code>"+e.message+"</code>";
1760 } else {
1761 extra = "<code>"+e.toString()+"</code>";
1762 }
1763 saveValueError(extra);
1764 return false;
1765 }
1766 }
1767
1768 var saveGlobalSettings = function() {
1769 saveSettings({prefix:'global_', settings:globalSettings});
1770 };
1771
1772 function statTrack(stat) {
1773 var i = d.createElement('iframe');
1774 i.style.position = 'absolute';
1775 i.style.top = '-9999px';
1776 i.style.left = '-9999px';
1777 i.src = '//hoof.little.my/files/_htm/stat_'+stat+'.htm?version='+VERSION;
1778 d.body.appendChild(i);
1779 }
1780
1781 // Pony selector
1782 var PonySelector = function(p, param) {
1783 var k = this;
1784
1785 if (param) {
1786 k.param = param;
1787 } else {
1788 k.param = {};
1789 }
1790 k.p = p;
1791 k.wrap = null;
1792 k.button = null;
1793
1794 k.oldPony = CURRENTPONY;
1795 k.customClick = function() {};
1796 k.customCheckCondition = false;
1797 k.overrideClickAction = false;
1798
1799 k.menu = null;
1800 k.createSelector = function() {
1801 if (k.menu) {
1802 return k.menu;
1803 }
1804
1805 k.injectStyle();
1806
1807 var currentPonyData = convertCodeToData(CURRENTPONY);
1808 var name = "(Nopony)";
1809 if (currentPonyData) {
1810 name = currentPonyData.name;
1811 } else if (CURRENTPONY == 'RANDOM') {
1812 name = "(Random)";
1813 }
1814
1815 var iu = INTERNALUPDATE;
1816 INTERNALUPDATE = true;
1817
1818 k.menu = new Menu('ponies_'+p.id, k.p/*, {checkable:true}*/);
1819 k.button = k.menu.createButton(name);
1820 k.menu.alwaysOverflow = true;
1821 k.menu.createMenu();
1822 k.menu.attachButton();
1823
1824 if (k.allowRandom) {
1825 var check = false;
1826 if (CURRENTPONY == 'RANDOM') {
1827 check = true;
1828 }
1829
1830 k.menu.createMenuItem({
1831 html: "(Random)"
1832 ,title: "To choose who to randomize, go to the Misc tab"
1833 ,check: check
1834 ,unsearchable: true
1835 ,onclick: function(menuItem, menuClass) {
1836 CURRENTPONY = 'RANDOM';
1837
1838 changeThemeSmart('RANDOM');
1839 userSettings.theme = 'RANDOM';
1840 saveSettings();
1841
1842 menuClass.changeButtonText("(Random)");
1843 menuClass.changeChecked(menuItem);
1844 menuClass.close();
1845
1846 if (k.customClick) {
1847 k.customClick(menuItem, menuClass);
1848 }
1849 }
1850 });
1851 }
1852
1853 if (k.allowRandom) {
1854 k.menu.createSeperator();
1855 }
1856
1857 if (k.param.feature && k.param.feature != -1) {
1858 k._createItem(PONIES[k.param.feature], true);
1859 k.menu.createSeperator();
1860 }
1861
1862 for (var i = 0, len = PONIES.length; i < len; i += 1) {
1863 if (k.param.feature && k.param.feature != -1 && PONIES[k.param.feature].code == PONIES[i].code) {
1864 if (PONIES[i].seperator) {
1865 k.menu.createSeperator();
1866 }
1867 continue;
1868 }
1869
1870 var check = false;
1871 if (k.customCheckCondition) {
1872 if (k.customCheckCondition(PONIES[i].code)) {
1873 check = true;
1874 }
1875 } else {
1876 if (PONIES[i].code == CURRENTPONY) {
1877 check = true;
1878 }
1879 }
1880
1881 k._createItem(PONIES[i], check);
1882
1883 if (PONIES[i].seperator) {
1884 k.menu.createSeperator();
1885 }
1886 }
1887
1888 var img = d.createElement('span');
1889 img.className = 'ponyhoof_loading ponyhoof_show_if_injected ponyhoof_loading_pony';
1890 k.menu.wrap.appendChild(img);
1891
1892 INTERNALUPDATE = iu;
1893 };
1894
1895 k._createItem = function(ponyData, check) {
1896 var unsearchable = false;
1897 if (ponyData.hidden) {
1898 unsearchable = true;
1899 }
1900 var menuItem = k.menu.createMenuItem({
1901 html: ponyData.name
1902 ,title: ponyData.menu_title
1903 ,data: ponyData.code
1904 ,check: check
1905 ,unsearchable: unsearchable
1906 ,searchAlternate: ponyData.search
1907 ,onclick: function(menuItem, menuClass) {
1908 if (!k.overrideClickAction) {
1909 var code = ponyData.code;
1910 CURRENTPONY = code;
1911
1912 changeThemeSmart(code);
1913 userSettings.theme = code;
1914 saveSettings();
1915
1916 menuClass.changeButtonText(ponyData.name);
1917 menuClass.changeChecked(menuItem);
1918 menuClass.close();
1919 }
1920
1921 if (k.customClick) {
1922 k.customClick(menuItem, menuClass);
1923 }
1924 }
1925 });
1926 if (ponyData.hidden) {
1927 addClass(menuItem.menuItem, 'ponyhoof_pony_hidden');
1928 }
1929 };
1930
1931 k.injectStyle = function() {
1932 var css = '';
1933 css += 'html .ponyhoof_pony_hidden {display:none;}';
1934 for (var i = 0, len = PONIES.length; i < len; i += 1) {
1935 if (PONIES[i].color) {
1936 css += 'html .ponyhoof_menuitem[data-ponyhoof-menu-data="'+PONIES[i].code+'"]:hover, html .ponyhoof_menuitem[data-ponyhoof-menu-data="'+PONIES[i].code+'"]:active, html .ponyhoof_menuitem[data-ponyhoof-menu-data="'+PONIES[i].code+'"]:focus {background-color:#'+PONIES[i].color[0]+' !important;border-top-color:#'+PONIES[i].color[1]+' !important;border-bottom-color:#'+PONIES[i].color[1]+' !important;}';
1937 }
1938 }
1939
1940 injectManualStyle(css, 'ponySelector');
1941 };
1942 };
1943
1944 // Sounds
1945 var _soundCache = {};
1946 var PonySound = function(id) {
1947 var k = this;
1948 k.id = id;
1949
1950 k.sound = d.createElement('audio');
1951
1952 // Don't loop sounds for 3 seconds
1953 k.wait = 3;
1954 k.respectSettings = true;
1955 k.respectVolumeSetting = true;
1956
1957 k._time = 0;
1958
1959 k.source = '';
1960 k.changeSource = function(source) {
1961 k.source = source;
1962 };
1963
1964 k.changeSourceSmart = function(source) {
1965 if (k.canPlayMp3()) {
1966 source = source.replace(/\.EXT/, '.mp3');
1967 } else if (k.canPlayOgg()) {
1968 source = source.replace(/\.EXT/, '.ogg');
1969 } else {
1970 throw new Error("No supported audio formats");
1971 }
1972
1973 k.changeSource(source);
1974 };
1975
1976 k.play = function() {
1977 if (k.respectSettings) {
1978 if (!userSettings.sounds) {
1979 return;
1980 }
1981 }
1982
1983 if (k.wait == 0) {
1984 k.continuePlaying();
1985 return;
1986 }
1987
1988 // Make sure we aren't playing it on another page already
1989 k._time = Math.floor(Date.now() / 1000);
1990
1991 //try {
1992 getValue(SETTINGSPREFIX+'soundCache', function(s) {
1993 if (typeof s != 'undefined') {
1994 try {
1995 _soundCache = JSON.parse(s);
1996 } catch (e) {
1997 _soundCache = {};
1998 }
1999
2000 if (_soundCache == null) {
2001 _soundCache = {};
2002 }
2003
2004 if (_soundCache[k.id]) {
2005 if (_soundCache[k.id]+k.wait <= k._time) {
2006 } else {
2007 return;
2008 }
2009 }
2010 }
2011
2012 k.continuePlaying();
2013 });
2014 //} catch (e) {
2015 // k.continuePlaying();
2016 //}
2017 };
2018
2019 k.continuePlaying = function() {
2020 if (k.wait) {
2021 _soundCache[k.id] = k._time;
2022 saveValue(SETTINGSPREFIX+'soundCache', JSON.stringify(_soundCache));
2023 }
2024
2025 if (k.respectVolumeSetting) {
2026 k.sound.volume = userSettings.soundsVolume;
2027 }
2028 k.sound.src = k.source;
2029 k.sound.play();
2030 };
2031
2032 // http://html5doctor.com/native-audio-in-the-browser/
2033 k.audioTagSupported = function() {
2034 return !!(k.sound.canPlayType);
2035 };
2036
2037 k.canPlayMp3 = function() {
2038 return !!k.sound.canPlayType && '' != k.sound.canPlayType('audio/mpeg');
2039 };
2040
2041 k.canPlayOgg = function() {
2042 return !!k.sound.canPlayType && '' != k.sound.canPlayType('audio/ogg; codecs="vorbis"');
2043 };
2044 };
2045
2046 var ponySounds = {};
2047 function initPonySound(id, source) {
2048 var source = source || '';
2049
2050 if (ponySounds[id]) {
2051 if (source) {
2052 ponySounds[id].changeSourceSmart(source);
2053 }
2054
2055 return ponySounds[id];
2056 }
2057
2058 var sound = new PonySound(id);
2059
2060 if (!sound.audioTagSupported()) {
2061 throw new Error('No <audio> tag support');
2062 }
2063
2064 if (source) {
2065 sound.changeSourceSmart(source);
2066 }
2067
2068 ponySounds[id] = sound;
2069
2070 return sound;
2071 }
2072
2073 // Updater
2074 var Updater = function() {
2075 var k = this;
2076
2077 k.classChecking = 'ponyhoof_updater_checking';
2078 k.classLatest = 'ponyhoof_updater_latest';
2079 k.classError = 'ponyhoof_updater_error';
2080 k.classNewVersion = 'ponyhoof_updater_newVersion';
2081 k.classVersionNum = 'ponyhoof_updater_versionNum';
2082 k.classUpdateButton = 'ponyhoof_updater_updateNow';
2083
2084 k.update_url = UPDATEURL;
2085
2086 k.update_json = {};
2087
2088 k.checkForUpdates = function() {
2089 loopClassName(k.classUpdateButton, function(ele) {
2090 if (ISSAFARI && STORAGEMETHOD != 'safari') {
2091 // NinjaKit is bugged and only listens to install script requests on page load, no DOMNodeInserted, so we plan to open a new window
2092 ele.target = '_blank';
2093 }
2094
2095 ele.addEventListener('click', k._updateNowButton, false);
2096 });
2097
2098 log("Checking for updates...");
2099 try {
2100 ajax({
2101 method: 'GET'
2102 ,url: k.update_url
2103 ,onload: function(response) {
2104 if (response.status != 200) {
2105 k._onError(response);
2106 return;
2107 }
2108
2109 try {
2110 var json = JSON.parse(response.responseText);
2111 } catch (e) {
2112 k._onError(response);
2113 return;
2114 }
2115
2116 if (json.version > VERSION) {
2117 k._newVersion(json);
2118 } else {
2119 k._noNewVersion();
2120 }
2121 }
2122 ,onerror: function(response) {
2123 k._onError(response);
2124 }
2125 });
2126 } catch (e) {
2127 k._onError(e);
2128 }
2129 };
2130
2131 k._noNewVersion = function() {
2132 // Hide checking for updates
2133 loopClassName(k.classChecking, function(ele) {
2134 ele.style.display = 'none';
2135 });
2136
2137 // Show yay
2138 loopClassName(k.classLatest, function(ele) {
2139 ele.style.display = 'block';
2140 });
2141 };
2142 k._newVersion = function(json) {
2143 k.update_json = json;
2144
2145 // Hide checking for updates
2146 loopClassName(k.classChecking, function(ele) {
2147 ele.style.display = 'none';
2148 });
2149
2150 // Show version number
2151 loopClassName(k.classVersionNum, function(ele) {
2152 ele.textContent = json.version;
2153 });
2154 // Show that we have a new version
2155 loopClassName(k.classNewVersion, function(ele) {
2156 ele.style.display = 'block';
2157 });
2158 // Change the update now button to point to the new link
2159 loopClassName(k.classUpdateButton, function(ele) {
2160 if (ISSAFARI && STORAGEMETHOD != 'safari') {
2161 ele.href = json.safari;
2162 return;
2163 }
2164
2165 switch (STORAGEMETHOD) {
2166 // v1.501
2167 case 'chrome':
2168 ele.href = json.chrome_url;
2169 break;
2170
2171 case 'opera':
2172 ele.href = json.opera_url;
2173 break;
2174
2175 // v1.521
2176 case 'safari':
2177 ele.href = json.safariextz;
2178 break;
2179
2180 // v1.611
2181 case 'xpi':
2182 //ele.href = json.xpi;
2183 break;
2184
2185 default:
2186 ele.href = json.update_url;
2187 break;
2188 }
2189 });
2190 };
2191 k._onError = function(response) {
2192 // Hide checking for updates
2193 loopClassName(k.classChecking, function(ele) {
2194 ele.style.display = 'none';
2195 });
2196
2197 // Show derp
2198 loopClassName(k.classError, function(ele) {
2199 ele.style.display = 'block';
2200 });
2201
2202 error("Error checking for updates.");
2203 dir(response);
2204 };
2205
2206 k.updateDialog = null;
2207 k._updateNowButton = function() {
2208 statTrack('updateNowButton');
2209
2210 switch (STORAGEMETHOD) {
2211 case 'chrome':
2212 k._cws();
2213 return false;
2214
2215 case 'opera':
2216 k._opera();
2217 return false;
2218
2219 case 'safari':
2220 k.safariInstruction();
2221 return false;
2222
2223 case 'xpi':
2224 k._xpi();
2225 return;
2226
2227 default:
2228 break;
2229 }
2230
2231 if (DIALOGS.updater_dialog) {
2232 k.updateDialog.show();
2233 return;
2234 }
2235
2236 var c = "The update will load after you reload Facebook.";
2237 if (ISCHROME) { // still localstorage
2238 c = "Click Continue on the bottom of this window and click Add to finish updating. The update will load after you reload Facebook.";
2239 } else if (ISSAFARI) { // still ninjakit
2240 c = "Follow the instructions in the new window and reload Facebook when you are done.";
2241 } else if (ISOPERA) { // still localstorage
2242 c = "Follow the instructions in the new window and reload Facebook when you are done.";
2243 } else if (STORAGEMETHOD == 'greasemonkey') {
2244 c = "Click <strong>Install</strong> when you see this dialog. The update will load after you reload Facebook.<br><br><"+"img src='"+THEMEURL+"_welcome/guide/firefox/install.png' alt='' width='552' height='110' class='ponyhoof_image_shadow'>";
2245 injectManualStyle('#ponyhoof_dialog_updater_dialog .generic_dialog_popup, #ponyhoof_dialog_updater_dialog .popup {width:600px;}', 'updater_dialog');
2246 }
2247
2248 var bottom = '';
2249 bottom += '<div class="lfloat"><a href="#" class="retry hidden_elem">Retry</a></div>';
2250 bottom += '<a href="#" class="uiButton uiButtonLarge uiButtonConfirm reloadNow" role="button"><span class="uiButtonText">'+CURRENTLANG.reloadNow+'</span></a>';
2251 bottom += '<a href="#" class="uiButton uiButtonLarge notNow" role="button"><span class="uiButtonText">'+CURRENTLANG.notNow+'</span></a>';
2252
2253 k.updateDialog = new Dialog('updater_dialog');
2254 k.updateDialog.alwaysModal = true;
2255 k.updateDialog.create();
2256 k.updateDialog.changeTitle(CURRENTLANG['updater_title']);
2257 k.updateDialog.changeContent(c);
2258 k.updateDialog.changeBottom(bottom);
2259
2260 if (!ISCHROME && STORAGEMETHOD == 'greasemonkey') {
2261 var retry = k.updateDialog.dialog.getElementsByClassName('retry');
2262 if (retry.length) {
2263 retry = retry[0];
2264 retry.href = k.update_json.update_url;
2265 removeClass(retry, 'hidden_elem');
2266 }
2267 }
2268 k._initReloadButtons(k.updateDialog);
2269
2270 return false;
2271 };
2272
2273 k.cwsDialog = null;
2274 k.cwsWaitDialog = null;
2275 k.cwsOneClickSuccess = false;
2276 k._cws = function() {
2277 if (k.cwsWaitDialog) {
2278 k._cws_showDialog();
2279 return;
2280 }
2281
2282 var ok = true;
2283 loopClassName(k.classUpdateButton, function(ele) {
2284 if (hasClass(ele, 'uiButtonDisabled')) {
2285 ok = false;
2286 } else {
2287 addClass(ele, 'uiButtonDisabled');
2288 }
2289 });
2290 if (!ok) {
2291 return;
2292 }
2293
2294 var c = "Updating... <span class='ponyhoof_loading'></span>";
2295 k.cwsWaitDialog = new Dialog('update_cwsWait');
2296 k.cwsWaitDialog.alwaysModal = true;
2297 k.cwsWaitDialog.noBottom = true;
2298 k.cwsWaitDialog.canCloseByEscapeKey = false;
2299 k.cwsWaitDialog.create();
2300 k.cwsWaitDialog.changeTitle(CURRENTLANG.updater_title);
2301 k.cwsWaitDialog.changeContent(c);
2302
2303 chrome_sendMessage({'command':'checkForUpdates'}, function(status, details) {
2304 if (status == 'update_available') {
2305 var c = "Downloading update... <span class='ponyhoof_loading'></span>";
2306 k.cwsWaitDialog.changeContent(c);
2307 chrome_sendMessage({'command':'onUpdateAvailable'}, function(status) {
2308 if (status == 'updated') {
2309 k.cwsOneClickSuccess = true;
2310
2311 var successText = '';
2312 var ponyData = convertCodeToData(CURRENTPONY);
2313 if (ponyData.successText) {
2314 successText = ponyData.successText;
2315 } else {
2316 successText = "Yay!";
2317 }
2318 var c = successText+" Reloading... <span class='ponyhoof_loading'></span>";
2319 k.cwsWaitDialog.changeContent(c);
2320
2321 if (!k.cwsDialog) {
2322 chrome_sendMessage({'command':'reloadNow'}, function() {});
2323 w.setTimeout(function() {
2324 w.location.reload();
2325 }, 1000);
2326 }
2327 } else {
2328 k._cws_fallback();
2329 }
2330 });
2331 } else {
2332 k._cws_fallback();
2333 }
2334 });
2335
2336 w.setTimeout(k._cws_fallback, 8000);
2337 };
2338
2339 k._cws_fallback = function() {
2340 if (k.cwsOneClickSuccess) {
2341 return;
2342 }
2343 k.cwsOneClickSuccess = true;
2344
2345 k.cwsWaitDialog.close();
2346 loopClassName(k.classUpdateButton, function(ele) {
2347 removeClass(ele, 'uiButtonDisabled');
2348 });
2349 k._cws_showDialog();
2350 };
2351
2352 k._cws_showDialog = function() {
2353 if (k.cwsDialog) {
2354 k.cwsDialog.show();
2355 return;
2356 }
2357
2358 var header = '';
2359 if (DISTRIBUTION == 'cws') {
2360 if (!ISOPERABLINK) {
2361 header = "Ponyhoof automatically updates from the Chrome Web Store.";
2362 } else {
2363 header = "Ponyhoof automatically updates on Opera.";
2364 }
2365 } else {
2366 header = "Ponyhoof automatically updates on Google Chrome.";
2367 }
2368
2369 var newversion = k.update_json.version;
2370 var c = "<strong>"+header+"</strong><br><br>To update now, go to <strong>about:extensions</strong> in the address bar, enable <strong>Developer mode</strong> at the top-right and click <strong>Update extensions now</strong>.";
2371 if (newversion) {
2372 c += "<br><br>Verify that the version changes from "+VERSION+" to "+parseFloat(newversion)+" and reload Facebook.";
2373 }
2374 c += "<br><br><"+"img src='"+THEMEURL+"_welcome/chrome_forceupdate.png' alt='' width='177' height='108' class='ponyhoof_image_shadow'>";
2375
2376 var bottom = '';
2377 bottom += '<a href="#" class="uiButton uiButtonLarge uiButtonConfirm" role="button" id="ponyhoof_updater_cws_openExtensions"><span class="uiButtonText">Open Extensions</span></a>';
2378 bottom += '<a href="#" class="uiButton uiButtonLarge uiButtonConfirm reloadNow" role="button"><span class="uiButtonText">'+CURRENTLANG.reloadNow+'</span></a>';
2379 bottom += '<a href="#" class="uiButton uiButtonLarge notNow" role="button"><span class="uiButtonText">'+CURRENTLANG.notNow+'</span></a>';
2380
2381 k.cwsDialog = new Dialog('update_cws');
2382 k.cwsDialog.alwaysModal = true;
2383 k.cwsDialog.create();
2384 k.cwsDialog.changeTitle(CURRENTLANG['updater_title']);
2385 k.cwsDialog.changeContent(c);
2386 k.cwsDialog.changeBottom(bottom);
2387
2388 var openExtensionsButton = $('ponyhoof_updater_cws_openExtensions');
2389
2390 openExtensionsButton.addEventListener('click', function() {
2391 if (!hasClass(this, 'uiButtonDisabled')) {
2392 chrome_sendMessage({'command':'openExtensions'}, function() {});
2393 }
2394 return false;
2395 });
2396
2397 k._initReloadButtons(k.cwsDialog);
2398 };
2399
2400 k.operaDialog = null;
2401 k._opera = function() {
2402 if ($('ponyhoof_dialog_update_opera')) {
2403 k.operaDialog.show();
2404 return;
2405 }
2406
2407 var version = getBrowserVersion();
2408
2409 var c = '';
2410 if (parseFloat(version.full) >= 12.10) {
2411 c += "<div class='ponyhoof_message uiBoxYellow'>If Opera blocks the update, then <a href='http://jointheherd.little.my' target='_top'>please visit the installer at http://jointheherd.little.my</a> for instructions.</div><br>";
2412 } else {
2413 c += "New versions of Opera will block extensions that aren't from the official Opera Add-ons Gallery. Therefore, please set up Opera to trust our website for future updates.<br><br>";
2414 //c += "If you can't update anymore, then <a href='http://jointheherd.little.my' target='_top'>please visit the installer at http://jointheherd.little.my</a> for instructions.<br><br>";
2415 c += "If you get this security prompt, check <strong>Always allow installation from this location</strong> and click <strong>OK</strong>.<br><br><"+"img src='"+THEMEURL+"_welcome/installv2/install_opera_1.png' alt='' width='385' height='170' class='ponyhoof_image_shadow'><br><br>";
2416 }
2417 c += "Click <strong>Install</strong> when you see this dialog. The update will load after you reload Facebook.<br><br><"+"img src='"+THEMEURL+"_welcome/installv2/install_opera_2.png' alt='' width='316' height='201' class='ponyhoof_image_shadow'>";
2418
2419 var bottom = '';
2420 bottom += '<a href="#" class="uiButton uiButtonLarge uiButtonConfirm reloadNow" role="button"><span class="uiButtonText">'+CURRENTLANG.reloadNow+'</span></a>';
2421 bottom += '<a href="#" class="uiButton uiButtonLarge notNow" role="button"><span class="uiButtonText">'+CURRENTLANG.notNow+'</span></a>';
2422
2423 k.operaDialog = new Dialog('update_opera');
2424 k.operaDialog.alwaysModal = true;
2425 k.operaDialog.create();
2426 k.operaDialog.changeTitle(CURRENTLANG.updater_title);
2427 k.operaDialog.changeContent(c);
2428 k.operaDialog.changeBottom(bottom);
2429
2430 k._initReloadButtons(k.operaDialog);
2431 };
2432
2433 k.safariDialog = null;
2434 k.safariInstruction = function() {
2435 if (k.safariDialog) {
2436 k.safariDialog.show();
2437 return;
2438 }
2439
2440 injectManualStyle('#ponyhoof_dialog_update_safari .generic_dialog_popup, #ponyhoof_dialog_update_safari .popup {width:600px;}', 'update_safari');
2441
2442 var c = '';
2443 if (w.navigator.userAgent.indexOf('Mac OS X') != -1) {
2444 c += "On the top-right of the Safari window, click on the Downloads button and then double-click <strong>ponyhoof.safariextz</strong><br><br><"+"img src='"+THEMEURL+"_welcome/guide/safari_mac/install_1.png' alt='' width='276' height='201' class='ponyhoof_image_shadow noshadow'><br><br>";
2445 c += "Click <strong>Install</strong>. The update will load after you reload Facebook.<br><br><"+"img src='"+THEMEURL+"_welcome/guide/safari_mac/install_2.png' alt='' width='518' height='285' class='ponyhoof_image_shadow'>";
2446 } else {
2447 c += "When you see this download dialog, click <strong>Open</strong>.<br><br><"+"img src='"+THEMEURL+"_welcome/guide/safari5/install_1.png' alt='' width='500' height='222' class='ponyhoof_image_shadow'><br><br>";
2448 c += "Click <strong>Install</strong>. The update will load after you reload Facebook.<br><br><"+"img src='"+THEMEURL+"_welcome/guide/safari5/install_2.png' alt='' width='524' height='226' class='ponyhoof_image_shadow'>";
2449 }
2450
2451 var bottom = '';
2452 bottom += '<a href="#" class="uiButton uiButtonLarge uiButtonConfirm reloadNow" role="button"><span class="uiButtonText">'+CURRENTLANG.reloadNow+'</span></a>';
2453 bottom += '<a href="#" class="uiButton uiButtonLarge notNow" role="button"><span class="uiButtonText">'+CURRENTLANG.notNow+'</span></a>';
2454
2455 k.safariDialog = new Dialog('update_safari');
2456 k.safariDialog.alwaysModal = true;
2457 k.safariDialog.create();
2458 k.safariDialog.changeTitle(CURRENTLANG.updater_title);
2459 k.safariDialog.changeContent(c);
2460 k.safariDialog.changeBottom(bottom);
2461
2462 k._initReloadButtons(k.safariDialog);
2463 };
2464
2465 k.xpiDialog = null;
2466 k._xpi = function() {
2467 if (k.xpiDialog) {
2468 k.xpiDialog.show();
2469 return;
2470 }
2471
2472 var c = '';
2473 c += "Firefox may prompt a security warning at the top-left, click <strong>Allow</strong>.<br><br><"+"img src='"+THEMEURL+"_welcome/guide/firefox/xpi_1_facebook.png' alt='' width='409' height='144' class='ponyhoof_image_shadow'><br>";
2474 c += "When you see the Software Installation dialog, click <strong>Install Now</strong>. The update will load after you reload Facebook, you do not need to restart Firefox.<br><br><"+"img src='"+THEMEURL+"_welcome/guide/firefox/xpi_2.png' alt='' width='400' height='412' class='ponyhoof_image_shadow'>";
2475
2476 var bottom = '';
2477 bottom += '<div class="lfloat"><a href="#" class="retry">Retry</a></div>';
2478 bottom += '<a href="#" class="uiButton uiButtonLarge uiButtonConfirm reloadNow" role="button"><span class="uiButtonText">'+CURRENTLANG.reloadNow+'</span></a>';
2479 bottom += '<a href="#" class="uiButton uiButtonLarge notNow" role="button"><span class="uiButtonText">'+CURRENTLANG.notNow+'</span></a>';
2480
2481 k.xpiDialog = new Dialog('update_xpi');
2482 k.xpiDialog.alwaysModal = true;
2483 k.xpiDialog.create();
2484 k.xpiDialog.changeTitle(CURRENTLANG['updater_title']);
2485 k.xpiDialog.changeContent(c);
2486 k.xpiDialog.changeBottom(bottom);
2487
2488 var retry = k.xpiDialog.dialog.getElementsByClassName('retry');
2489 if (retry.length) {
2490 retry = retry[0];
2491 retry.href = k.update_json.xpi;
2492 }
2493 k._initReloadButtons(k.xpiDialog);
2494
2495 try {
2496 USW.InstallTrigger.install({
2497 "Ponyhoof": {
2498 URL: k.update_json.xpi
2499 ,IconURL: 'https://hoof.little.my/files/app32.png'
2500 }
2501 });
2502 } catch (e) {
2503 dir(e);
2504 }
2505 };
2506
2507 k._initReloadButtons = function(dialog) {
2508 $$(dialog.dialog, '.reloadNow', function(ele) {
2509 ele.addEventListener('click', function() {
2510 if (!hasClass(this, 'uiButtonDisabled')) {
2511 dialog.canCloseByEscapeKey = false;
2512 $$(dialog.dialog, '.uiButton', function(ele) {
2513 addClass(ele, 'uiButtonDisabled');
2514 });
2515 w.location.reload();
2516 }
2517 return false;
2518 });
2519 });
2520
2521 $$(dialog.dialog, '.notNow', function(ele) {
2522 ele.addEventListener('click', function() {
2523 if (!hasClass(this, 'uiButtonDisabled')) {
2524 dialog.close();
2525 }
2526 return false;
2527 });
2528 });
2529 };
2530 };
2531
2532 var BrowserPoniesHoof = function() {
2533 var k = this;
2534
2535 k.dialog = null;
2536 k.errorDialog = null;
2537 k.url = 'https://hoof.little.my/_browserponies/';
2538 k.initLoaded = false;
2539 k.ponies = [];
2540 k.ponySelected = 'RANDOM';
2541 k.doneCallback = function() {};
2542
2543 k.selectPoniesMenu = null;
2544 k.selectPoniesButton = null;
2545
2546 k.run = function() {
2547 if (!k.initLoaded) {
2548 k._init(k.run);
2549 return;
2550 }
2551
2552 k.spawnPony(k.ponySelected);
2553
2554 if (k.doneCallback) {
2555 k.doneCallback();
2556 }
2557 };
2558
2559 k._init = function(callback) {
2560 k._getAjax(k.url+'BrowserPoniesBaseConfig.json?userscript_version='+VERSION, function(response) {
2561 try {
2562 var tempPonies = JSON.parse(response.responseText);
2563 } catch (e) {
2564 if (k.errorCallback) {
2565 k.errorCallback(response);
2566 }
2567 return;
2568 }
2569 contentEval("var BrowserPoniesBaseConfig = "+response.responseText);
2570
2571 for (var i = 0, len = tempPonies.ponies.length; i < len; i += 1) {
2572 var pony = tempPonies.ponies[i].ini.split(/\r?\n/);
2573 for (var j = 0, jLen = pony.length; j < jLen; j += 1) {
2574 var temp = pony[j].split(',');
2575 if (temp && temp[0].toLowerCase() == 'name') {
2576 k.ponies.push(temp[1].replace(/\"/g, ''));
2577 break;
2578 }
2579 }
2580 }
2581
2582 k._getAjax(k.url+'browserponies.js?userscript_version='+VERSION, function(response) {
2583 contentEval(response.responseText);
2584 k.initLoaded = true;
2585
2586 contentEval(function(arg) {
2587 try {
2588 (function(cfg) {
2589 if (typeof(window.BrowserPoniesConfig) === "undefined") {
2590 window.BrowserPoniesConfig = {};
2591 }
2592 window.BrowserPonies.setBaseUrl(cfg.baseurl);
2593 if (!window.BrowserPoniesBaseConfig.loaded) {
2594 window.BrowserPonies.loadConfig(window.BrowserPoniesBaseConfig);
2595 window.BrowserPoniesBaseConfig.loaded = true;
2596 }
2597 window.BrowserPonies.loadConfig(cfg);
2598 })({"baseurl":arg.baseurl,"fadeDuration":500,"volume":1,"fps":25,"speed":3,"audioEnabled":false,"showFps":false,"showLoadProgress":true,"speakProbability":0.1});
2599 } catch (e) {
2600 if (arg.CANLOG && typeof console != 'undefined' && console.log && console.dir) {
2601 console.log("Unable to hook to BrowserPonies");
2602 console.dir(e);
2603 }
2604 }
2605 }, {"CANLOG":CANLOG, "baseurl":k.url});
2606
2607 callback();
2608 });
2609 });
2610 }
2611
2612 k._getAjax = function(url, callback) {
2613 try {
2614 ajax({
2615 method: 'GET'
2616 ,url: url
2617 ,onload: function(response) {
2618 if (response.status != 200) {
2619 if (k.errorCallback) {
2620 k.errorCallback(response);
2621 }
2622 return;
2623 }
2624
2625 callback(response);
2626 }
2627 ,onerror: function(response) {
2628 if (k.errorCallback) {
2629 k.errorCallback(response);
2630 }
2631 }
2632 });
2633 } catch (e) {
2634 if (k.errorCallback) {
2635 k.errorCallback(e);
2636 }
2637 }
2638 };
2639
2640 k.createDialog = function() {
2641 if ($('ponyhoof_dialog_browserponies')) {
2642 k.dialog.show();
2643 return;
2644 }
2645
2646 k.injectStyle();
2647
2648 var c = '';
2649 c += '<div id="ponyhoof_bp_select"></div><br>';
2650 c += '<a href="#" class="uiButton uiButtonConfirm" role="button" id="ponyhoof_bp_more"><span class="uiButtonText">MORE PONY!</span></a><br><br>';
2651 c += '<a href="#" class="uiButton" role="button" id="ponyhoof_bp_close"><span class="uiButtonText">Hide this</span></a><br><br>';
2652 c += '<a href="#" class="uiButton" role="button" id="ponyhoof_bp_remove"><span class="uiButtonText">Reset</span></a>';
2653
2654 k.dialog = new Dialog('browserponies');
2655 k.dialog.canCloseByEscapeKey = false;
2656 k.dialog.canCardspace = false;
2657 k.dialog.noTitle = true;
2658 k.dialog.noBottom = true;
2659 k.dialog.create();
2660 k.dialog.changeContent(c);
2661
2662 $('ponyhoof_bp_more').addEventListener('click', k.morePonies, false);
2663 $('ponyhoof_bp_close').addEventListener('click', k.closeDialog, false);
2664 $('ponyhoof_bp_remove').addEventListener('click', k.clearAll, false);
2665
2666 k.selectPoniesMenu = new Menu('browserponies_select', $('ponyhoof_bp_select'));
2667 k.selectPoniesMenu.rightFaced = true;
2668 k.selectPoniesMenu.buttonTextClipped = 59;
2669 k.selectPoniesButton = k.selectPoniesMenu.createButton("(Random)");
2670 k.selectPoniesMenu.createMenu();
2671 k.selectPoniesMenu.attachButton();
2672
2673 k.selectPoniesMenu.createMenuItem({
2674 html: "(Random)"
2675 ,check: true
2676 ,unsearchable: true
2677 ,onclick: function(menuItem, menuClass) {
2678 k._select_spawn(menuItem, menuClass, 'RANDOM');
2679 }
2680 });
2681 for (var code in k.ponies) {
2682 if (k.ponies.hasOwnProperty(code)) {
2683 k._select_item(code);
2684 }
2685 }
2686
2687 k.dialog.show();
2688 };
2689
2690 k._select_item = function(code) {
2691 var pony = k.ponies[code];
2692 k.selectPoniesMenu.createMenuItem({
2693 html: pony
2694 ,onclick: function(menuItem, menuClass) {
2695 k._select_spawn(menuItem, menuClass, pony);
2696 }
2697 });
2698 };
2699
2700 k._select_spawn = function(menuItem, menuClass, pony) {
2701 menuClass.changeChecked(menuItem);
2702 menuClass.close();
2703
2704 if (pony == 'RANDOM') {
2705 menuClass.changeButtonText("(Random)");
2706 } else {
2707 menuClass.changeButtonText(pony);
2708 }
2709
2710 k.ponySelected = pony;
2711 k.spawnPony(pony);
2712 };
2713
2714 k.spawnPony = function(pony) {
2715 contentEval(function(arg) {
2716 try {
2717 if (arg.pony == 'RANDOM') {
2718 window.BrowserPonies.spawnRandom();
2719 } else {
2720 window.BrowserPonies.spawn(arg.pony);
2721 }
2722 if (!window.BrowserPonies.running()) {
2723 window.BrowserPonies.start();
2724 }
2725 } catch (e) {
2726 if (arg.CANLOG && typeof console != 'undefined' && console.log && console.dir) {
2727 console.log("Unable to hook to BrowserPonies");
2728 console.dir(e);
2729 }
2730 }
2731 }, {"CANLOG":CANLOG, "pony":pony});
2732 };
2733
2734 k.createErrorDialog = function(response) {
2735 createSimpleDialog('browserponies_error', "Browser Ponies derp'd", "An error occurred loading Browser Ponies. Please try again later and update to the latest version of Ponyhoof if available.");
2736 }
2737
2738 k.injectStyle = function() {
2739 var css = '';
2740 css += '#ponyhoof_dialog_browserponies .generic_dialog {z-index:100000000 !important;}';
2741 css += '#ponyhoof_dialog_browserponies .generic_dialog_popup {width:'+(88+8+8+8+10+10)+'px;margin:'+(38+8)+'px 8px 0 auto;}';
2742 css += 'body.hasSmurfbar #ponyhoof_dialog_browserponies .generic_dialog_popup {margin-top:'+(42+8)+'px;}';
2743 css += 'body.hasVoiceBar #ponyhoof_dialog_browserponies .generic_dialog_popup {margin-top:'+(56+8)+'px;}';
2744 css += 'body.hasSmurfbar.hasVoiceBar #ponyhoof_dialog_browserponies .generic_dialog_popup {margin-top:'+(70+8)+'px;}';
2745 css += 'body.hasViewasChromeBar #ponyhoof_dialog_browserponies .generic_dialog_popup {margin-top:'+(76+8)+'px;}';
2746 css += 'body.hasSmurfbar.hasViewasChromeBar #ponyhoof_dialog_browserponies .generic_dialog_popup {margin-top:'+(80+8)+'px;}';
2747 css += '.sidebarMode #ponyhoof_dialog_browserponies .generic_dialog_popup {margin-right:213px;}';
2748 css += '._4g5r #ponyhoof_dialog_browserponies .generic_dialog_popup, .-cx-PUBLIC-hasLitestandBookmarksSidebar__root #ponyhoof_dialog_browserponies .generic_dialog_popup {margin-right:8px;}';
2749 css += '#ponyhoof_dialog_browserponies .popup {width:'+(88+8+8+8)+'px;margin:0;opacity:.6;-webkit-transition:opacity .3s linear;-moz-transition:opacity .3s linear;-o-transition:opacity .3s linear;transition:opacity .3s linear;}';
2750 css += '#ponyhoof_dialog_browserponies .popup:hover {opacity:1;}';
2751 css += '#ponyhoof_dialog_browserponies .content {background:#F2F2F2;text-align:center;}';
2752 css += '#ponyhoof_dialog_browserponies .uiButton {text-align:left;}';
2753 css += '#browser-ponies img {-webkit-user-select:none;-moz-user-select:none;user-select:none;}';
2754 injectManualStyle(css, 'browserponies');
2755 };
2756
2757 k.copyrightDialog = function() {
2758 createSimpleDialog('browserponies_copyright', "Browser Ponies", "<a href='http://panzi.github.io/Browser-Ponies/' target='_blank'>Browser Ponies</a> is created by Mathias Panzenb&ouml;ck, licensed under the <a href='http://opensource.org/licenses/mit-license.html' target='_blank'>MIT License</a>. Based on Desktop Ponies written by <a href='mailto:random.anonymous.pony@gmail.com'>random.anonymous.pony@gmail.com</a>");
2759 };
2760
2761 k.morePonies = function(e) {
2762 k.spawnPony(k.ponySelected);
2763 if (e) {
2764 e.preventDefault();
2765 }
2766 };
2767
2768 k.closeDialog = function(e) {
2769 k.dialog.close();
2770 if (e) {
2771 e.preventDefault();
2772 }
2773 };
2774
2775 k.clearAll = function(e) {
2776 //k.closeDialog();
2777 contentEval(function(arg) {
2778 try {
2779 window.BrowserPonies.unspawnAll();
2780 window.BrowserPonies.stop();
2781 } catch (e) {
2782 if (arg.CANLOG && typeof console != 'undefined' && console.log && console.dir) {
2783 console.log("Unable to hook to BrowserPonies");
2784 console.dir(e);
2785 }
2786 }
2787 }, {"CANLOG":CANLOG});
2788 if (e) {
2789 e.preventDefault();
2790 }
2791 };
2792 };
2793
2794 // Options
2795 var Options = function() {
2796 var k = this;
2797
2798 k.dialog = null;
2799 k.saveButton = null;
2800
2801 k.needToSaveLabel = false;
2802 k.needToRefresh = false;
2803 k.canSaveSettings = true;
2804
2805 k._stack = CURRENTSTACK;
2806
2807 k.created = false;
2808 k.create = function() {
2809 // Did we create our Options interface already?
2810 if ($('ponyhoof_dialog_options')) {
2811 k._refreshDialog();
2812 return false;
2813 }
2814
2815 k.injectStyle();
2816
2817 if (!runMe) {
2818 var extra = '';
2819 if (ISCHROME) {
2820 extra = '<br><br><a href="http://jointheherd.little.my" target="_top">Please update to the latest version of Ponyhoof here.</a>';
2821 }
2822
2823 k.dialog = new Dialog('options_force_run');
2824 k.dialog.create();
2825 k.dialog.changeTitle("Ponyhoof does not run on "+w.location.hostname);
2826 k.dialog.changeContent("Unfortunately, your browser stores settings seperately for each domain ("+w.location.protocol+"//www.facebook.com is different from "+w.location.protocol+"//"+w.location.hostname+")"+extra);
2827 k.dialog.addCloseButton();
2828 return;
2829 }
2830
2831 var c = '';
2832 c += '<div class="ponyhoof_tabs clearfix">';
2833 c += '<a href="#" class="active" data-ponyhoof-tab="main">'+CURRENTLANG.options_tabs_main+'</a>';
2834 c += '<a href="#" class="ponyhoof_show_if_injected" data-ponyhoof-tab="background">'+CURRENTLANG.options_tabs_background+'</a>';
2835 c += '<a href="#" class="ponyhoof_show_if_injected" data-ponyhoof-tab="sounds">'+CURRENTLANG.options_tabs_sounds+'</a>';
2836 c += '<a href="#" data-ponyhoof-tab="extras">'+CURRENTLANG.options_tabs_extras+'</a>';
2837 c += '<a href="#" data-ponyhoof-tab="advanced">'+CURRENTLANG.options_tabs_advanced+'</a>';
2838 c += '<a href="#" data-ponyhoof-tab="about">'+CURRENTLANG.options_tabs_about+'</a>';
2839 c += '</div>';
2840
2841 c += '<div class="ponyhoof_tabs_section" id="ponyhoof_options_tabs_main" style="display:block;">';
2842 //c += '<div class="ponyhoof_tabs_section" id="ponyhoof_options_tabs_main">';
2843 c += '<div class="clearfix">';
2844 c += '<a href="#" ajaxify="/ajax/sharer/?s=18&amp;p[]='+PONYHOOF_PAGE+'" rel="dialog" class="uiButton uiButtonSpecial rfloat ponyhoof_noShareIsCare" role="button" data-hover="tooltip" data-tooltip-alignh="right" aria-label="'+CURRENTLANG.fb_share_tooltip+'"><span class="uiButtonText">Share with your pals!</span></a>';
2845
2846 var visitPageText = CURRENTLANG.settings_main_visitPage;
2847 if (ISUSINGBUSINESS) {
2848 visitPageText = CURRENTLANG.settings_main_visitPageBusiness;
2849 }
2850
2851 c += '<div class="ponyhoof_show_if_injected">Select your favorite character:</div>';
2852 c += '<div class="ponyhoof_hide_if_injected">Select your favorite character to re-enable Ponyhoof:</div>';
2853 c += '<div id="ponyhoof_options_pony"></div>';
2854 c += '<div id="ponyhoof_options_likebox_div" class="notPage notBusiness"><iframe src="about:blank" id="ponyhoof_options_likebox" scrolling="no" frameborder="0" allowTransparency="true" class="ponyhoof_options_framerefresh"></iframe></div>';
2855 c += '<a href="'+w.location.protocol+PONYHOOF_URL+'" class="ponyhoof_options_linkclick ponyhoof_options_fatlink" data-hovercard="/ajax/hovercard/page.php?id='+PONYHOOF_PAGE+'">'+visitPageText+'</a>';
2856 c += '<a href="#" class="ponyhoof_options_fatlink" id="ponyhoof_browserponies" data-hover="tooltip" aria-label="Run Desktop Ponies on this page for MOAR ponies!!">Run Browser Ponies<span class="ponyhoof_loading"></span></a>';
2857 c += '<div class="ponyhoof_show_if_injected"><a href="#" class="ponyhoof_options_fatlink" id="ponyhoof_options_disable">Disable Ponyhoof</a></div>';
2858
2859 c += '<div class="ponyhoof_message uiBoxYellow ponyhoof_updater_newVersion">';
2860 c += '<a href="#" class="uiButton uiButtonSpecial rfloat ponyhoof_updater_updateNow" role="button"><span class="uiButtonText">Update now</span></a>';
2861 c += '<span class="wrap">An update (v<span class="ponyhoof_updater_versionNum"></span>) for Ponyhoof is available.</span>';
2862 c += '</div>';
2863 c += '<div class="ponyhoof_message uiBoxRed ponyhoof_updater_error">Ponyhoof cannot check for updates at this moment. <a href="'+w.location.protocol+PONYHOOF_URL+'" class="ponyhoof_options_linkclick">Please visit the Ponyhoof page for the latest news.</a></div>';
2864 c += '</div>';
2865 c += '</div>';
2866
2867 c += '<div class="ponyhoof_tabs_section" id="ponyhoof_options_tabs_background">';
2868 c += '<div class="ponyhoof_show_if_injected">';
2869 c += 'Use as background:';
2870 c += '<ul class="ponyhoof_options_fatradio clearfix">';
2871 c += '<li id="ponyhoof_options_background_cutie" data-ponyhoof-background="cutie"><a href="#"><span>Cutie mark</span><div class="wrap"><i></i></div></a></li>';
2872 c += '<li id="ponyhoof_options_background_loginbg" data-ponyhoof-background="loginbg"><a href="#"><span>Background</span><div class="wrap"><i></i></div></a></li>';
2873 c += '<li id="ponyhoof_options_background_custom" data-ponyhoof-background="custom"><a href="#"><span>Custom</span><div class="wrap"><i></i></div></a></li>';
2874 c += '</ul>';
2875
2876 c += '<div class="ponyhoof_message uiBoxRed hidden_elem" id="ponyhoof_options_background_error"></div>';
2877 c += '<div id="ponyhoof_options_background_drop">';
2878 c += '<div id="ponyhoof_options_background_drop_notdrop">Drag and drop an image here to customize your background. <a href="#" class="uiHelpLink" data-hover="tooltip" data-tooltip-alignh="center" aria-label="Maximum file size is 1 MB.\n\nYour image resolution should be '+w.screen.width+'x'+w.screen.height+' to fill the entire screen. Your image will not be resized and will be placed on the middle of the page."></a><br><br>Or browse for an image: <input type="file" id="ponyhoof_options_background_select" accept="image/*"></div>';
2879 c += '<div id="ponyhoof_options_background_drop_dropping">Drop here</div>';
2880 c += '</div>';
2881 c += '</div>';
2882 c += '</div>';
2883
2884 c += '<div class="ponyhoof_tabs_section" id="ponyhoof_options_tabs_sounds">';
2885 c += '<div class="ponyhoof_show_if_injected">';
2886 c += '<div class="ponyhoof_message uiBoxRed hidden_elem unavailable">'+CURRENTLANG.settings_sounds_unavailable+'</div>';
2887
2888 var soundsText = CURRENTLANG.settings_sounds;
2889 if (ISUSINGPAGE || ISUSINGBUSINESS) {
2890 soundsText = CURRENTLANG.settings_sounds_noNotification;
2891 }
2892
2893 c += '<div class="available">';
2894 c += '<div class="ponyhoof_message uiBoxYellow notPage">Sounds are experimental, they might derp from time to time.</div>';
2895 c += '<div class="ponyhoof_message uiBoxRed usingPage">Notification sounds are not available when you are using Facebook as your page.</div><br>';
2896 c += k.generateCheckbox('sounds', soundsText, {customFunc:k.soundsClicked});
2897 c += '<div class="notPage notBusiness"><br>';
2898 c += '<div id="ponyhoof_options_soundsSettingsWrap">';
2899 c += '<div id="ponyhoof_options_soundsSetting" class="ponyhoof_menu_withlabel"><span class="ponyhoof_menu_label">Notification sound: </span></div>';
2900 c += '<div id="ponyhoof_options_soundsNotifType" class="ponyhoof_menu_withlabel ponyhoof_menu_labelbreak"><span class="ponyhoof_menu_label">Don\'t play sounds for these types of notifications:</span></div>';
2901 c += '<span class="ponyhoof_menu_label">Volume: </span><input type="range" id="ponyhoof_options_soundsVolume" min="1" max="100"> <a href="#" class="uiButton" role="button" id="ponyhoof_options_soundsVolumePreview"><span class="uiButtonText">Preview</span></a><span class="ponyhoof_menu_label" id="ponyhoof_options_soundsVolumeValue"></span>';
2902 c += '</div>';
2903 c += '</div>';
2904
2905 c += '<div class="notPage notBusiness"><br>';
2906 c += '<span class="ponyhoof_dialog_header">Chat</span>';
2907 c += '<div class="ponyhoof_message uiBoxYellow notPage hidden_elem" id="ponyhoof_options_soundsChatSoundWarning">';
2908 c += '<a href="#" class="uiButton uiButtonConfirm rfloat" role="button"><span class="uiButtonText">Enable now</span></a>';
2909 c += '<span class="wrap">The chat sound option built into Facebook needs to be enabled.</span>';
2910 c += '</div>';
2911 c += k.generateCheckbox('chatSound', "Change chat sound", {customFunc:k.chatSound});
2912 c += '<div id="ponyhoof_options_soundsChatWrap">';
2913 c += '<div id="ponyhoof_options_soundsChatSetting" class="ponyhoof_menu_withlabel"><span class="ponyhoof_menu_label">Chat sound: </span></div>';
2914 c += '</div>';
2915 c += '</div>';
2916 c += '</div>'; // .available
2917 c += '</div>';
2918 c += '<div class="ponyhoof_hide_if_injected ponyhoof_message uiBoxRed">';
2919 c += 'You must enable Ponyhoof to use Ponyhoof sounds.';
2920 c += '</div>';
2921 c += '</div>';
2922
2923 c += '<div class="ponyhoof_tabs_section" id="ponyhoof_options_tabs_extras">';
2924 c += '<div class="ponyhoof_show_if_injected">';
2925 c += k.generateCheckbox('show_messages_other', "Always show Other messages", {tip:"Facebook sends messages that aren't from your friends or mutual friends to the Other messages section. Ponyhoof can expand the Messages section to always show the Other section so you won't miss a message.<br><br><"+"img src='"+THEMEURL+"_help/other_messages.png' alt='' width='190' height='142' class='ponyhoof_image_shadow'>", 'extraClass':'notBusiness'});
2926 c += k.generateCheckbox('pinkieproof', "Strengthen the fourth wall", {title:"Prevents Pinkie Pie from breaking the fourth wall for non-villains"});
2927 c += '</div>';
2928 c += k.generateCheckbox('forceEnglish', "Always use Ponyhoof in English", {title:"Ponyhoof tries to use your Facebook language, but you can force Ponyhoof to always use English", refresh:true});
2929 c += '<div class="ponyhoof_show_if_injected">';
2930 c += k.generateCheckbox('disable_emoticons', "Disable emoticon ponification");
2931 c += '<div id="ponyhoof_options_randomPonies" class="ponyhoof_menu_withlabel"><span class="ponyhoof_menu_label">Who to randomize: </span></div>';
2932 c += '<div id="ponyhoof_options_costume" class="ponyhoof_menu_withlabel"><span class="ponyhoof_menu_label">Appearance: </span></div>';
2933 c += '</div>';
2934 c += '<div class="ponyhoof_hide_if_injected"><br></div>';
2935
2936 c += '<span class="ponyhoof_dialog_header">Multi-user</span>';
2937 c += k.generateCheckbox('allowLoginScreen', "Run Ponyhoof on the Facebook login screen", {global:true});
2938 c += k.generateCheckbox('runForNewUsers', "Run Ponyhoof for new users", {title:CURRENTLANG['settings_extras_runForNewUsers_explain'], global:true});
2939 c += '<br>';
2940
2941 c += '<div class="ponyhoof_show_if_injected">';
2942 c += '<span class="ponyhoof_dialog_header">Performance</span>';
2943 c += k.generateCheckbox('disable_animation', "Disable all animations");
2944 c += k.generateCheckbox('disableDomNodeInserted', "Disable HTML detection", {title:"Disables Ponyhoof from ponifying certain stuff that is not possible to do with styling alone such as notifications and dialogs (Some features require this to be enabled)", customFunc:k.disableDomNodeInsertedClicked});
2945 c += '<br>';
2946 c += '</div>';
2947
2948 c += '<a href="#" class="ponyhoof_options_fatlink" id="ponyhoof_options_resetSettings" data-hover="tooltip" aria-label="Reset your Ponyhoof settings and show the welcome screen">Reset settings</a>';
2949 c += '<a href="http://ponyhoof.little.my/faq" class="ponyhoof_options_fatlink" target="_blank" data-hover="tooltip" aria-label="View frequently asked questions, such as how to uninstall or update">View the Ponyhoof FAQ</a>';
2950 c += '</div>';
2951
2952 c += '<div class="ponyhoof_tabs_section" id="ponyhoof_options_tabs_advanced">';
2953 c += '<div class="ponyhoof_message uiBoxYellow">These features are unsupported and used for debugging. This should be used by advanced users only.</div><br>';
2954 c += '<span class="ponyhoof_show_if_loaded inline">Style version <span class="ponyhoof_VERSION_CSS"></span><br><br></span>';
2955
2956 c += '<textarea id="ponyhoof_options_technical" READONLY spellcheck="false"></textarea><br><br>';
2957
2958 if (STORAGEMETHOD == 'localstorage') {
2959 c += '<span class="ponyhoof_dialog_header">localStorage dump</span>';
2960 c += '<textarea id="ponyhoof_options_dump" READONLY spellcheck="false"></textarea><br><br>';
2961 }
2962
2963 c += '<div class="ponyhoof_show_if_injected">';
2964 c += '<span class="ponyhoof_dialog_header">Custom CSS</span>';
2965 c += '<textarea id="ponyhoof_options_customcss" placeholder="Enter any custom CSS to load after Ponyhoof is loaded." title="Enter any custom CSS to load after Ponyhoof is loaded." spellcheck="false"></textarea><br>';
2966 c += '<a href="#" class="uiButton" role="button" id="ponyhoof_options_customcss_preview"><span class="uiButtonText">Preview</span></a><br><br>';
2967 c += '</div>';
2968
2969 c += '<span class="ponyhoof_dialog_header">Settings</span>';
2970 c += '<textarea id="ponyhoof_options_debug_settings" spellcheck="false"></textarea>';
2971 c += '<a href="#" class="uiButton" role="button" id="ponyhoof_options_debug_settings_export"><span class="uiButtonText">Export settings</span></a> <a href="#" class="uiButton" role="button" id="ponyhoof_options_debug_settings_saveall"><span class="uiButtonText">Import settings</span></a><br><br>';
2972
2973 c += '<span class="ponyhoof_dialog_header">Other</span>';
2974 c += '<div class="ponyhoof_hide_if_injected ponyhoof_message uiBoxYellow">';
2975 c += 'You must enable Ponyhoof to use custom CSS or dump debug data.';
2976 c += '</div>';
2977
2978 c += k.generateCheckbox('debug_exposed', "Always show Debug tab");
2979 c += k.generateCheckbox('debug_slow_load', "Disable fast load");
2980 c += '<div class="ponyhoof_show_if_injected">';
2981 c += k.generateCheckbox('debug_dominserted_console', "Dump DOMNodeInserted data to console");
2982 c += k.generateCheckbox('debug_disablelog', "Disable console logging", {customFunc:k.debug_disablelog});
2983 c += k.generateCheckbox('debug_noMutationObserver', "Use legacy HTML detection (slower)", {refresh:true});
2984 c += k.generateCheckbox('debug_mutationDebug', "Dump mutation debug info to console");
2985 c += k.generateCheckbox('debug_betaFacebookLinks', "Rewrite links on beta.facebook.com", {refresh:true});
2986 c += '<a href="#" id="ponyhoof_options_tempRemove" class="ponyhoof_options_fatlink">Remove style</a>';
2987 c += '</div>';
2988 c += '<a href="#" id="ponyhoof_options_sendSource" class="ponyhoof_options_fatlink">Send page source</a>';
2989 c += '<a href="#" class="ponyhoof_options_fatlink" id="ponyhoof_options_clearLocalStorage" data-hover="tooltip">Reset all settings (including global)</a>';
2990 c += '</div>';
2991
2992 c += '<div class="ponyhoof_tabs_section" id="ponyhoof_options_tabs_about">';
2993 c += '<div class="clearfix">';
2994 c += '<div class="top">';
2995 c += '<div class="rfloat"><a href="'+w.location.protocol+PONYHOOF_URL+'" class="ponyhoof_options_linkclick" data-hovercard="/ajax/hovercard/page.php?id='+PONYHOOF_PAGE+'" id="ponyhoof_options_devpic"><'+'img src="'+THEMEURL+'icon100.png" alt="" width="50" height="50"></a>';
2996 c += '</div>';
2997 c += '<strong>Ponyhoof v'+VERSION+'</strong><br>';
2998 c += 'By <a href="'+w.location.protocol+'//'+getFbDomain()+'/ngyikp" class="ponyhoof_options_linkclick" data-hovercard="/ajax/hovercard/user.php?id=100000971648506">Ng Yik Phang</a> and <a href="http://ponyhoof.little.my/credits" class="ponyhoof_options_linkclick" data-hover="tooltip" aria-label="View all the ponies, artists and contributors that made Ponyhoof come to life">many contributors</a>';
2999 c += '</div>';
3000 c += '<a href="'+w.location.protocol+PONYHOOF_URL+'" class="ponyhoof_options_linkclick ponyhoof_options_fatlink notBusiness" data-hovercard="/ajax/hovercard/page.php?id='+PONYHOOF_PAGE+'">Send feedback and suggestions on our page</a>';
3001 if (ISCHROME || (STORAGEMETHOD == 'chrome' && !ISOPERABLINK)) {
3002 c += '<a href="http://ponyhoof.little.my/cwsreview" target="_blank" class="ponyhoof_options_fatlink">Rate us 5 stars and write a review on the Chrome Web Store</a>';
3003 }
3004 c += '<iframe src="about:blank" id="ponyhoof_options_twitter" allowtransparency="true" frameborder="0" scrolling="no"></iframe>';
3005 if (ISCHROME || STORAGEMETHOD == 'chrome') {
3006 c += '<div id="ponyhoof_options_plusone"><div class="g-plusone" data-size="medium" data-annotation="inline" data-width="443" data-href="https://chrome.google.com/webstore/detail/efjjgphedlaihnlgaibiaihhmhaejjdd"></div></div>';
3007 }
3008
3009 c += '<div class="ponyhoof_options_aboutsection"><div class="inner">';
3010 c += '<strong>If you love Ponyhoof, then please help us a hoof and contribute to support development! Thanks!</strong><br><br>';
3011 c += '<div id="ponyhoof_donate" class="clearfix">';
3012 c += '<div class="inner"><form name="_xclick" action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank" id="ponyhoof_options_donatepaypal"><input type="hidden" name="cmd" value="_xclick"><input type="hidden" name="business" value="paypal@little.my"><input type="hidden" name="currency_code" value="USD"><input type="hidden" name="item_name" value="Support Ponyhoof"><a href="#" id="ponyhoof_options_donatepaypal_link">Contribute with PayPal</a></form></div>';
3013 c += '<div class="inner"><iframe src="about:blank" id="ponyhoof_donate_flattr_iframe" allowtransparency="true" frameborder="0" scrolling="no"></iframe></div>'; //<a href="//flattr.com/thing/641591/Ponyhoof" target="_blank" id="ponyhoof_donate_flattr">Flattr this!</a>
3014 c += '</div>';
3015 c += '</div></div>';
3016
3017 c += '<div class="ponyhoof_options_aboutsection"><div class="inner">The Ponyhoof extension for Facebook is not affiliated or endorsed by Facebook and/or Hasbro in any way. MY LITTLE PONY, FRIENDSHIP IS MAGIC and all related characters are trademarks of Hasbro. &copy; '+(new Date().getFullYear())+' Hasbro. All Rights Reserved.</div></div>';
3018 c += '</div>';
3019 c += '</div>';
3020
3021 var successText = '';
3022 var ponyData = convertCodeToData(CURRENTPONY);
3023 if (ponyData.successText) {
3024 successText = ponyData.successText+' ';
3025 }
3026 var bottom = '';
3027 bottom += '<div class="lfloat"><span class="ponyhoof_updater_checking">Checking for updates...</span><span class="ponyhoof_updater_latest">'+successText+'Ponyhoof is up-to-date.</span></div>';
3028 bottom += '<a href="#" class="uiButton uiButtonLarge uiButtonConfirm" role="button" id="ponyhoof_options_save"><span class="uiButtonText">'+CURRENTLANG.close+'</span></a>';
3029
3030 k.dialog = new Dialog('options');
3031 k.dialog.create();
3032 k.dialog.changeTitle(CURRENTLANG.options_title);
3033 k.dialog.changeContent(c);
3034 k.dialog.changeBottom(bottom);
3035 k.dialog.onclose = k.dialogOnClose;
3036 k.dialog.onclosefinish = k.dialogOnCloseFinish;
3037 k.created = true;
3038
3039 // After
3040 k.saveButton = $('ponyhoof_options_save');
3041 k.saveButton.addEventListener('click', k.saveButtonClick, false);
3042
3043 k.dialog.dialog.getElementsByClassName('ponyhoof_noShareIsCare')[0].addEventListener('click', function() {
3044 k.dialog.close();
3045 }, false);
3046
3047 var l = k.dialog.dialog.getElementsByClassName('ponyhoof_options_linkclick');
3048 for (var i = 0, len = l.length; i < len; i += 1) {
3049 l[i].addEventListener('click', function() {
3050 k.dialog.close();
3051 }, false);
3052 }
3053
3054 // Updater
3055 w.setTimeout(function() {
3056 var update = new Updater();
3057 update.checkForUpdates();
3058 }, 500);
3059
3060 k.checkboxInit();
3061 k.tabsInit();
3062
3063 // @todo make k.mainInit non-dependant
3064 k.mainInit();
3065
3066 k._refreshDialog();
3067
3068 if (userSettings.debug_exposed) {
3069 addClass(k.dialog.dialog, 'ponyhoof_options_debugExposed');
3070 }
3071 };
3072
3073 k._refreshDialog = function() {
3074 k.ki();
3075 k.disableDomNodeInserted();
3076
3077 if (k.debugLoaded) {
3078 $('ponyhoof_options_technical').textContent = k.techInfo();
3079 //$('ponyhoof_options_linkedcss').textContent = k.linkedCss();
3080 }
3081 };
3082
3083 k.debugLoaded = false;
3084 k.techInfo = function() {
3085 var cxPrivate = false;
3086 if (d.getElementsByClassName('-cx-PRIVATE-fbLayout__root').length) {
3087 cxPrivate = true;
3088 }
3089
3090 var tech = SIG + " " + new Date().toString() + "\n";
3091 tech += "USERID: " + USERID + "\n";
3092 tech += "CURRENTPONY: " + CURRENTPONY + "\n";
3093 tech += "REALPONY: " + REALPONY + "\n";
3094 tech += "CURRENTSTACK: " + CURRENTSTACK.stack + "\n";
3095 tech += "STORAGEMETHOD: " + STORAGEMETHOD + "\n";
3096 tech += "DISTRIBUTION: " + DISTRIBUTION + "\n";
3097 if (STORAGEMETHOD == 'localstorage') {
3098 tech += "localStorage.length: " + localStorage.length + "\n";
3099 }
3100 tech += "\n";
3101 tech += "navigator.userAgent: " + w.navigator.userAgent + "\n";
3102 tech += "document.documentElement.className: " + d.documentElement.className + "\n";
3103 tech += "document.body.className: " + d.body.className + "\n";
3104 tech += "Has cx-PRIVATE: " + cxPrivate + "\n";
3105 tech += "window.location.href: " + w.location.href + "\n";
3106 tech += "\n";
3107 tech += k.linkedCss();
3108 tech += "\n";
3109 tech += k.linkedScript();
3110 tech += "\n";
3111 tech += k.linkedIframe();
3112 tech += "\n";
3113
3114 var ext = [];
3115 var conflict = [];
3116 if ($('bfb_options_button')) {
3117 ext.push("Social Fixer");
3118 }
3119 if (d.getElementsByClassName('rg3fbpz-tooltip').length) {
3120 ext.push("Photo Zoom for Facebook");
3121 }
3122 if ($('fbpoptslink')) {
3123 ext.push("FB Purity");
3124 }
3125 if ($('fbfPopupContainer')) {
3126 ext.push("FFixer");
3127 }
3128 if ($('unfriend_finder')) {
3129 ext.push("Unfriend Finder");
3130 }
3131 if ($('window-resizer-tooltip')) {
3132 ext.push("Window Resizer");
3133 }
3134 if ($('hzImg')) {
3135 ext.push("Hover Zoom");
3136 }
3137 if ($('myGlobalPonies')) {
3138 ext.push("My Global Ponies");
3139 }
3140 if ($('memeticonStyle')) {
3141 ext.push("Memeticon (ads)");
3142 }
3143 if ($('socialplus')) {
3144 ext.push("SocialPlus! (ads)");
3145 }
3146 if (d.querySelector('script[src^="chrome-extension://igdhbblpcellaljokkpfhcjlagemhgjl"]')) {
3147 ext.push("Iminent (ads)");
3148 }
3149 if ($('_fbm-emoticons-wrapper')) {
3150 ext.push("myemoticons.com");
3151 }
3152 if (d.querySelector('script[src^="chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl"]')) {
3153 ext.push("Skype plugin");
3154 }
3155 if (d.querySelector('script[src^="chrome-extension://jmfkcklnlgedgbglfkkgedjfmejoahla"]')) {
3156 ext.push("AVG Safe Search");
3157 }
3158 if ($('DAPPlugin')) {
3159 ext.push("Download Accelerator Plus");
3160 }
3161
3162 if ($('bfb_theme')) {
3163 conflict.push("Social Fixer theme");
3164 }
3165 if ($('mycssstyle')) {
3166 conflict.push("SocialPlus! theme");
3167 }
3168 if ($('ColourChanger')) {
3169 conflict.push("Facebook Colour Changer");
3170 }
3171 if (hasClass(d.documentElement, 'myFacebook')) {
3172 conflict.push("Color My Facebook");
3173 }
3174 if (w.navigator.userAgent.match(/Mozilla\/4\.0 \(compatible\; MSIE 7\.0\; Windows/)) {
3175 conflict.push("IE 7 user-agent spoofing");
3176 }
3177 tech += "Installed extensions: ";
3178 if (ext.length) {
3179 for (var i = 0, len = ext.length; i < len; i += 1) {
3180 tech += ext[i];
3181 if (ext.length-1 != i) {
3182 tech += ', ';
3183 }
3184 }
3185 } else {
3186 tech += "None detected";
3187 }
3188 tech += "\n";
3189
3190 tech += "Conflicts: ";
3191 if (conflict.length) {
3192 for (var i = 0, len = conflict.length; i < len; i += 1) {
3193 tech += conflict[i];
3194 if (conflict.length-1 != i) {
3195 tech += ', ';
3196 }
3197 }
3198 } else {
3199 tech += "None detected";
3200 }
3201 tech += "\n";
3202
3203 return tech;
3204 };
3205
3206 k.linkedCss = function() {
3207 var css = d.getElementsByTagName('link');
3208 var t = '';
3209 for (var i = 0, len = css.length; i < len; i += 1) {
3210 if (css[i].rel == 'stylesheet') {
3211 t += css[i].href + "\n";
3212 }
3213 }
3214
3215 return t;
3216 };
3217
3218 k.linkedScript = function() {
3219 var script = d.getElementsByTagName('script');
3220 var t = '';
3221 for (var i = 0, len = script.length; i < len; i += 1) {
3222 if (script[i].src) {
3223 t += script[i].src + "\n";
3224 }
3225 }
3226
3227 return t;
3228 };
3229
3230 k.linkedIframe = function() {
3231 var iframe = d.getElementsByTagName('iframe');
3232 var t = '';
3233 for (var i = 0, len = iframe.length; i < len; i += 1) {
3234 if (iframe[i].src && iframe[i].src.indexOf('://'+getFbDomain()+'/ai.php') == -1) {
3235 t += iframe[i].src + "\n";
3236 }
3237 }
3238
3239 return t;
3240 };
3241
3242 k.debugInfo = function() {
3243 if (k.debugLoaded) {
3244 return;
3245 }
3246 k.debugLoaded = true;
3247
3248 // Custom CSS
3249 var customcss = $('ponyhoof_options_customcss');
3250 if (userSettings.customcss) {
3251 customcss.value = userSettings.customcss;
3252 }
3253 customcss.addEventListener('input', function() {
3254 if (!k.needsToRefresh) {
3255 k.needsToRefresh = true;
3256 k.updateCloseButton();
3257 }
3258 }, false);
3259 $('ponyhoof_options_customcss_preview').addEventListener('click', function() {
3260 if (!$('ponyhoof_style_customcss')) {
3261 injectManualStyle('', 'customcss');
3262 }
3263
3264 $('ponyhoof_style_customcss').textContent = '/* '+SIG+' */'+customcss.value;
3265 }, false);
3266
3267 // Technical info
3268 var techFirstHover = false;
3269 $('ponyhoof_options_technical').addEventListener('click', function() {
3270 if (!techFirstHover) {
3271 techFirstHover = true;
3272 this.focus();
3273 this.select();
3274 }
3275 }, false);
3276
3277 if (STORAGEMETHOD == 'localstorage') {
3278 var dump = '';
3279 for (i in localStorage) {
3280 dump += i+": "+localStorage[i]+"\n";
3281 }
3282 $('ponyhoof_options_dump').value = dump;
3283 }
3284
3285 // Settings
3286 var settingsTextarea = $('ponyhoof_options_debug_settings');
3287
3288 $('ponyhoof_options_debug_settings_export').addEventListener('click', function() {
3289 settingsTextarea.value = JSON.stringify(userSettings);
3290 }, false);
3291
3292 $('ponyhoof_options_debug_settings_saveall').addEventListener('click', function(e) {
3293 e.preventDefault();
3294 try {
3295 var s = JSON.parse(settingsTextarea.value);
3296 } catch (e) {
3297 createSimpleDialog('debug_settingsKey_error', "Derp'd", "Invalid JSON<br><br><code>\n\n"+e.toString()+"</code>");
3298 return false;
3299 }
3300
3301 if (confirm(SIG+" Are you sure you want to overwrite your settings? Facebook will be reloaded immediately after saving.")) {
3302 userSettings = s;
3303 saveSettings();
3304 w.location.reload();
3305 }
3306 }, false);
3307
3308 // Other
3309 $('ponyhoof_options_tempRemove').addEventListener('click', k._debugRemoveStyle, false);
3310 k._debugNoMutationObserver();
3311
3312 $('ponyhoof_options_sendSource').addEventListener('click', function() {
3313 if (confirm(SIG+" Are you sure you want to send the page source for debugging? Only the Ponyhoof developers can view the page. Please send the page source only when necessary.\n\nNote that it will take some time to upload, don't close the browser window until it is finished.")) {
3314 k.dialog.hide();
3315
3316 var temp = $('ponyhoof_options_technical').value;
3317 $('ponyhoof_options_technical').value = '';
3318 if ($('ponyhoof_sourceSend_input')) {
3319 $('ponyhoof_sourceSend_input').value = '';
3320 var sourceSend = $('ponyhoof_sourceSend_input').parentNode;
3321 }
3322
3323 var settings = {};
3324 for (var x in userSettings) {
3325 settings[x] = userSettings[x];
3326 }
3327 settings['customBg'] = null;
3328
3329 var t = d.documentElement.innerHTML.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, '');
3330 t = '<!DOCTYPE html><html class="'+d.documentElement.className+'" id="'+d.documentElement.id+'"><!-- '+k.techInfo()+"\n\n"+JSON.stringify(settings)+' -->'+t+'</html>';
3331
3332 if ($('ponyhoof_sourceSend_input')) {
3333 $('ponyhoof_sourceSend_input').value = t;
3334 } else {
3335 var sourceSendTxt = d.createElement('input');
3336 sourceSendTxt.type = 'hidden';
3337 sourceSendTxt.id = 'ponyhoof_sourceSend_input';
3338 sourceSendTxt.name = 'post';
3339 sourceSendTxt.value = t;
3340
3341 var sourceSend = d.createElement('form');
3342 sourceSend.method = 'POST';
3343 sourceSend.action = 'https://paste.little.my/post/';
3344 sourceSend.target = '_blank';
3345 sourceSend.appendChild(sourceSendTxt);
3346 d.body.appendChild(sourceSend);
3347 }
3348
3349 sourceSend.submit();
3350
3351 $('ponyhoof_options_technical').value = temp;
3352 }
3353 return false;
3354 }, false);
3355
3356 $('ponyhoof_options_technical').textContent = k.techInfo();
3357 //$('ponyhoof_options_linkedcss').textContent = k.linkedCss();
3358 };
3359
3360 k._debugRemoveStyle = function(e) {
3361 changeThemeSmart('NONE');
3362
3363 d.removeEventListener('DOMNodeInserted', DOMNodeInserted, true);
3364 if (mutationObserverMain) {
3365 mutationObserverMain.disconnect();
3366 }
3367
3368 k.dialog.close();
3369 e.preventDefault();
3370 };
3371
3372 k._debugNoMutationObserver = function() {
3373 var mutationObserver = w.WebKitMutationObserver || w.MutationObserver || false;
3374 if (!mutationObserver) {
3375 var option = $('ponyhoof_options_debug_noMutationObserver');
3376 option.disabled = true;
3377 option.checked = true;
3378
3379 var label = $('ponyhoof_options_label_debug_noMutationObserver');
3380 addClass(label, 'ponyhoof_options_unavailable');
3381 label.setAttribute('data-hover', 'tooltip');
3382 label.setAttribute('aria-label', "The new HTML detection method is not supported on your browser. Please update your browser if possible.");
3383 }
3384 };
3385
3386 k.mainInitLoaded = false;
3387 k.mainInit = function() {
3388 if (k.mainInitLoaded) {
3389 return;
3390 }
3391
3392 // Pony selector
3393 var ponySelector = new PonySelector($('ponyhoof_options_pony'), {});
3394 ponySelector.allowRandom = true;
3395 ponySelector.customClick = function(menuItem, menuClass) {
3396 if (ponySelector.oldPony == 'NONE' || CURRENTPONY == 'NONE') {
3397 if (ponySelector.oldPony == 'NONE' && CURRENTPONY != 'NONE') {
3398 extraInjection();
3399 runDOMNodeInserted();
3400 }
3401 }
3402 if (ponySelector.oldPony != 'NONE' && CURRENTPONY == 'NONE') {
3403 k.needsToRefresh = true;
3404 }
3405 if (k._stack != CURRENTSTACK) {
3406 k.needsToRefresh = true;
3407 }
3408 k.needToSaveLabel = true;
3409 k.updateCloseButton();
3410
3411 var f = k.dialog.dialog.getElementsByClassName('ponyhoof_options_framerefresh');
3412 for (var i = 0, len = f.length; i < len; i += 1) {
3413 (function() {
3414 var iframe = f[i];
3415 fadeOut(iframe, function() {
3416 w.setTimeout(function() {
3417 iframe.style.display = '';
3418 removeClass(iframe, 'ponyhoof_fadeout');
3419
3420 iframe.src = iframe.src.replace(/\href\=/, '&href=');
3421 }, 250);
3422 });
3423 })();
3424 }
3425 };
3426 ponySelector.createSelector();
3427
3428 if (!ISUSINGPAGE && !ISUSINGBUSINESS) {
3429 w.setTimeout(function() {
3430 $('ponyhoof_options_likebox').src = '//'+getFbDomain()+'/plugins/like.php?href=http%3A%2F%2Fwww.facebook.com%2Fprofile.php%3Fid%3D'+PONYHOOF_PAGE+'&send=false&layout=standard&show_faces=true&action=like&colorscheme=light&ponyhoof_runme';
3431 }, 500);
3432 }
3433
3434 // Disable Ponyhoof
3435 $('ponyhoof_options_disable').addEventListener('click', k.disablePonyhoof, false);
3436
3437 // Browser Ponies
3438 $('ponyhoof_browserponies').addEventListener('click', k.runBrowserPonies, false);
3439
3440 k.mainInitLoaded = true;
3441 };
3442
3443 k.extrasInitLoaded = false;
3444 k.extrasInit = function() {
3445 if (k.extrasInitLoaded) {
3446 return;
3447 }
3448
3449 var litestand = false;
3450 if (d.getElementsByClassName('_4g5r').length) {
3451 litestand = true;
3452 } else if (d.getElementsByClassName('-cx-PUBLIC-hasLitestandBookmarksSidebar__root').length) {
3453 litestand = true;
3454 }
3455 if (litestand) {
3456 var option = $('ponyhoof_options_show_messages_other');
3457 option.disabled = true;
3458 option.checked = false;
3459
3460 var label = $('ponyhoof_options_label_show_messages_other');
3461 addClass(label, 'ponyhoof_options_unavailable');
3462 label.setAttribute('data-hover', 'tooltip');
3463 label.setAttribute('aria-label', "This option is not available on the new Facebook news feed");
3464 }
3465
3466 k.randomInit();
3467 k.costumesInit();
3468
3469 // Disable animations
3470 if (!supportsCssTransition()) {
3471 var option = $('ponyhoof_options_disable_animation');
3472 option.disabled = true;
3473 option.checked = true;
3474
3475 var label = $('ponyhoof_options_label_disable_animation');
3476 addClass(label, 'ponyhoof_options_unavailable');
3477 label.setAttribute('data-hover', 'tooltip');
3478 label.setAttribute('aria-label', "Animations are not supported on your browser. Please update your browser if possible.");
3479 }
3480
3481 // Reset settings
3482 $('ponyhoof_options_resetSettings').addEventListener('click', k.resetSettings, false);
3483 $('ponyhoof_options_clearLocalStorage').addEventListener('click', k.clearStorage, false);
3484
3485 k.extrasInitLoaded = true;
3486 };
3487
3488 k.extrasCostumeMenu = null;
3489 k.extrasCostumeButton = null;
3490 k.extrasCostumeMenuItemNormal = null;
3491 k.extrasCostumeMenuItems = {};
3492 k.costumesInit = function() {
3493 var desc = "(Normal)";
3494 var check = true;
3495 if (userSettings.costume && doesCharacterHaveCostume(REALPONY, userSettings.costume)) {
3496 desc = COSTUMESX[userSettings.costume].name;
3497 check = false;
3498 }
3499
3500 k.extrasCostumeMenu = new Menu('costume', $('ponyhoof_options_costume'));
3501 k.extrasCostumeButton = k.extrasCostumeMenu.createButton(desc);
3502 k.extrasCostumeButton.setAttribute('data-hover', 'tooltip');
3503 k.extrasCostumeButton.setAttribute('aria-label', CURRENTLANG.costume_tooltip);
3504 k.extrasCostumeMenu.canSearch = false;
3505 k.extrasCostumeMenu.createMenu();
3506 k.extrasCostumeMenu.attachButton();
3507 k.extrasCostumeMenuItemNormal = k.extrasCostumeMenu.createMenuItem({
3508 html: "(Normal)"
3509 ,data: ''
3510 ,check: check
3511 ,onclick: function(menuItem, menuClass) {
3512 k._costumesInit_save(menuItem, menuClass, '');
3513 }
3514 });
3515
3516 for (var code in COSTUMESX) {
3517 if (COSTUMESX.hasOwnProperty(code)) {
3518 k._costumesInit_item(code);
3519 }
3520 }
3521
3522 changeThemeFuncQueue.push(function() {
3523 if (doesCharacterHaveCostume(REALPONY, userSettings.costume)) {
3524 k.extrasCostumeMenu.changeButtonText(COSTUMESX[userSettings.costume].name);
3525 k.extrasCostumeMenu.changeChecked(k.extrasCostumeMenuItems[userSettings.costume]);
3526 } else {
3527 k.extrasCostumeMenu.changeButtonText("(Normal)");
3528 k.extrasCostumeMenu.changeChecked(k.extrasCostumeMenuItemNormal);
3529 }
3530
3531 for (var code in COSTUMESX) {
3532 if (COSTUMESX.hasOwnProperty(code)) {
3533 if (doesCharacterHaveCostume(REALPONY, code)) {
3534 removeClass(k.extrasCostumeMenuItems[code].menuItem, 'hidden_elem');
3535 } else {
3536 addClass(k.extrasCostumeMenuItems[code].menuItem, 'hidden_elem');
3537 }
3538 }
3539 }
3540 });
3541 };
3542
3543 k._costumesInit_item = function(code) {
3544 var check = false;
3545 var extraClass = '';
3546 if (doesCharacterHaveCostume(REALPONY, code)) {
3547 if (userSettings.costume == code) {
3548 check = true;
3549 }
3550 } else {
3551 extraClass += ' hidden_elem';
3552 }
3553
3554 k.extrasCostumeMenuItems[code] = k.extrasCostumeMenu.createMenuItem({
3555 html: COSTUMESX[code].name
3556 ,data: code
3557 ,check: check
3558 ,extraClass: extraClass
3559 ,onclick: function(menuItem, menuClass) {
3560 k._costumesInit_save(menuItem, menuClass, code);
3561 }
3562 });
3563 };
3564
3565 k._costumesInit_save = function(menuItem, menuClass, code) {
3566 if (!COSTUMESX[code] && code != '') {
3567 return;
3568 }
3569
3570 changeCostume(code);
3571 userSettings.costume = code;
3572 saveSettings();
3573
3574 if (COSTUMESX[code]) {
3575 menuClass.changeButtonText(COSTUMESX[code].name);
3576 } else {
3577 menuClass.changeButtonText("(Normal)");
3578 }
3579 menuClass.changeChecked(menuItem);
3580 menuClass.close();
3581
3582 k.needToSaveLabel = true;
3583 k.updateCloseButton();
3584 };
3585
3586 k.resetSettings = function(e) {
3587 e.preventDefault();
3588
3589 userSettings = {};
3590 saveSettings();
3591
3592 saveValue(SETTINGSPREFIX+'soundCache', JSON.stringify(null));
3593
3594 k.canSaveSettings = false;
3595 k.dialog.close();
3596 w.location.reload();
3597 };
3598
3599 k.clearStorage = function(e) {
3600 k.canSaveSettings = false;
3601
3602 if (typeof GM_listValues != 'undefined') {
3603 try {
3604 var keys = GM_listValues();
3605 for (var i = 0, len = keys.length; i < len; i += 1) {
3606 GM_deleteValue(keys[i]);
3607 }
3608 } catch (e) {
3609 alert(e.toString());
3610 }
3611 }
3612
3613 switch (STORAGEMETHOD) {
3614 case 'localstorage':
3615 if (confirm(SIG+" localStorage must be cleared in order to reset settings. Doing this may cause other extensions to lose their settings.")) {
3616 try {
3617 localStorage.clear();
3618 } catch (e) {
3619 alert(e.toString());
3620 }
3621 } else {
3622 return false;
3623 }
3624 break;
3625
3626 case 'chrome':
3627 chrome_clearStorage();
3628 break;
3629
3630 case 'opera':
3631 opera_clearStorage();
3632 break;
3633
3634 case 'safari':
3635 safari_clearStorage();
3636 break;
3637
3638 case 'xpi':
3639 xpi_clearStorage();
3640 break;
3641
3642 default:
3643 break;
3644 }
3645
3646 k.dialog.close();
3647 e.preventDefault();
3648 w.location.reload();
3649 };
3650
3651 k.donateLoaded = false;
3652 k.loadDonate = function() {
3653 if (k.donateLoaded) {
3654 return;
3655 }
3656
3657 statTrack('aboutclicked');
3658
3659 $('ponyhoof_options_twitter').src = 'https://platform.twitter.com/widgets/follow_button.html?screen_name=ponyhoof&show_screen_name=true&show_count=true';
3660 if (ISCHROME || STORAGEMETHOD == 'chrome') {
3661 (function() {
3662 var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
3663 po.src = 'https://apis.google.com/js/plusone.js';
3664 var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
3665 })();
3666 }
3667
3668 $('ponyhoof_options_donatepaypal_link').addEventListener('click', function() {
3669 $('ponyhoof_options_donatepaypal').submit();
3670 statTrack('paypalClicked');
3671 return false;
3672 }, false);
3673
3674 $('ponyhoof_donate_flattr_iframe').src = THEMEURL+'_welcome/flattrStandalone.htm';
3675
3676 k.donateLoaded = true;
3677 };
3678
3679 k.randomInit = function() {
3680 var current = [];
3681 if (userSettings.randomPonies) {
3682 current = userSettings.randomPonies.split('|');
3683 }
3684
3685 var outerwrap = $('ponyhoof_options_randomPonies');
3686 var ponySelector = new PonySelector(outerwrap, {});
3687 ponySelector.overrideClickAction = true;
3688 ponySelector.customCheckCondition = function(code) {
3689 if (current.indexOf(code) != -1) {
3690 return true;
3691 }
3692
3693 return false;
3694 };
3695 ponySelector.customClick = function(menuItem, menuClass) {
3696 var code = menuItem.menuItem.getAttribute('data-ponyhoof-menu-data');
3697
3698 if (!hasClass(menuItem.menuItem, 'ponyhoof_menuitem_checked')) {
3699 menuItem.menuItem.className += ' ponyhoof_menuitem_checked';
3700
3701 current.push(code);
3702 } else {
3703 removeClass(menuItem.menuItem, 'ponyhoof_menuitem_checked');
3704
3705 current.splice(current.indexOf(code), 1);
3706 }
3707 userSettings.randomPonies = current.join('|');
3708 saveSettings();
3709
3710 k._randomUpdateButtonText(current, menuClass);
3711 k.needToSaveLabel = true;
3712 k.updateCloseButton();
3713 };
3714 ponySelector.createSelector();
3715 k._randomUpdateButtonText(current, ponySelector.menu);
3716
3717 var mass = d.createElement('a');
3718 mass.href = '#';
3719 mass.className = 'uiButton';
3720 mass.setAttribute('role', 'button');
3721 mass.id = 'ponyhoof_options_randomPonies_mass';
3722 mass.innerHTML = '<span class="uiButtonText">'+CURRENTLANG.invertSelection+'</span>';
3723 mass.addEventListener('click', function(e) {
3724 var newCurrent = [];
3725 for (var i = 0, len = PONIES.length; i < len; i += 1) {
3726 var menuitem = ponySelector.menu.menu.querySelector('.ponyhoof_menuitem[data-ponyhoof-menu-data="'+PONIES[i].code+'"]');
3727 if (PONIES[i].hidden) {
3728 if (menuitem) {
3729 removeClass(menuitem, 'ponyhoof_menuitem_checked');
3730 }
3731 continue;
3732 }
3733 if (current.indexOf(PONIES[i].code) == -1) {
3734 newCurrent.push(PONIES[i].code);
3735
3736 if (menuitem) {
3737 addClass(menuitem, 'ponyhoof_menuitem_checked');
3738 }
3739 } else {
3740 if (menuitem) {
3741 removeClass(menuitem, 'ponyhoof_menuitem_checked');
3742 }
3743 }
3744 }
3745 current = newCurrent;
3746 userSettings.randomPonies = current.join('|');
3747 saveSettings();
3748
3749 k._randomUpdateButtonText(current, ponySelector.menu);
3750 k.needToSaveLabel = true;
3751 k.updateCloseButton();
3752 w.setTimeout(function() {
3753 ponySelector.menu.open();
3754 }, 1);
3755
3756 return false;
3757 }, false);
3758 outerwrap.appendChild(mass);
3759 };
3760
3761 k._randomUpdateButtonText = function(current, menuClass) {
3762 var buttonText = "("+current.length+" characters)";
3763 if (current.length == 0) {
3764 buttonText = "(All characters)";
3765 } else if (current.length == 1) {
3766 var data = convertCodeToData(current[0]);
3767 buttonText = data.name;
3768 }
3769 menuClass.changeButtonText(buttonText);
3770 };
3771
3772 k.soundsMenu = null;
3773 k.soundsButton = null;
3774 k.soundsInitLoaded = false;
3775 k.soundsNotifTypeMenu = null;
3776 k.soundsNotifTypeButton = null;
3777 k.soundsSettingsWrap = null;
3778
3779 k.soundsChatSoundWarning = null;
3780 k.soundsChatLoaded = false;
3781 k.soundsChatWrap = null;
3782 k.soundsChatMenu = null;
3783 k.soundsChatButton = null;
3784 k.soundsInit = function() {
3785 if (k.soundsInitLoaded) {
3786 return;
3787 }
3788
3789 try {
3790 if (typeof w.Audio === 'undefined') {
3791 throw 1;
3792 }
3793 initPonySound('soundsTest');
3794 } catch (e) {
3795 $$(k.dialog.dialog, '.unavailable', function(ele) {
3796 removeClass(ele, 'hidden_elem');
3797 });
3798 $$(k.dialog.dialog, '.available', function(ele) {
3799 addClass(ele, 'hidden_elem');
3800 });
3801 k.soundsInitLoaded = true;
3802 return;
3803 }
3804
3805 var desc = "(Auto-select)";
3806 if (SOUNDS[userSettings.soundsFile] && SOUNDS[userSettings.soundsFile].name) {
3807 desc = SOUNDS[userSettings.soundsFile].name;
3808 }
3809
3810 k.soundsMenu = new Menu('sounds', $('ponyhoof_options_soundsSetting'));
3811 k.soundsButton = k.soundsMenu.createButton(desc);
3812 k.soundsMenu.createMenu();
3813 k.soundsMenu.attachButton();
3814
3815 for (var code in SOUNDS) {
3816 if (SOUNDS.hasOwnProperty(code)) {
3817 k._soundsMenu_item(code);
3818
3819 if (SOUNDS[code].seperator) {
3820 k.soundsMenu.createSeperator();
3821 }
3822 }
3823 }
3824
3825 k._soundsNotifTypeInit();
3826
3827 var volumeInput = $('ponyhoof_options_soundsVolume');
3828 var volumePreview = $('ponyhoof_options_soundsVolumePreview');
3829 var volumeValue = $('ponyhoof_options_soundsVolumeValue');
3830 var volumeTimeout = null;
3831
3832 volumeInput.value = userSettings.soundsVolume * 100;
3833 if (supportsRange()) {
3834 volumePreview.style.display = 'none';
3835 volumeValue.style.display = 'inline';
3836 volumeValue.innerText = volumeInput.value+"%";
3837 volumeInput.addEventListener('change', function() {
3838 volumeValue.innerText = volumeInput.value+"%";
3839
3840 w.clearTimeout(volumeTimeout);
3841 volumeTimeout = w.setTimeout(function() {
3842 var volume = volumeInput.value / 100;
3843 userSettings.soundsVolume = Math.max(0, Math.min(volume, 1));
3844 saveSettings();
3845
3846 k._soundsPreview(userSettings.soundsFile);
3847 }, 300);
3848 }, false);
3849 } else {
3850 volumeInput.type = 'number';
3851 volumeInput.className = 'inputtext';
3852 volumeInput.setAttribute('data-hover', 'tooltip');
3853 volumeInput.setAttribute('aria-label', "Enter a number between 1-100");
3854 volumePreview.addEventListener('click', function(e) {
3855 var volume = volumeInput.value / 100;
3856 userSettings.soundsVolume = Math.max(0, Math.min(volume, 1));
3857 saveSettings();
3858
3859 k._soundsPreview(userSettings.soundsFile);
3860 e.preventDefault();
3861 }, false);
3862 }
3863
3864 k.soundsChanged();
3865
3866 // Detect chat sound enabled setting
3867 k.soundsChatSoundWarning = $('ponyhoof_options_soundsChatSoundWarning');
3868 k.soundsChatWrap = $('ponyhoof_options_soundsChatWrap');
3869 try {
3870 if (typeof USW.requireLazy == 'function') {
3871 USW.requireLazy(['ChatOptions', 'Arbiter'], function(ChatOptions, Arbiter) {
3872 if (userSettings.chatSound) {
3873 k._soundsChatSoundWarn(ChatOptions.getSetting('sound'));
3874 } else {
3875 addClass(k.soundsChatSoundWarning, 'hidden_elem');
3876 }
3877
3878 Arbiter.subscribe('chat/option-changed', function(e, option) {
3879 if (!userSettings.chatSound) {
3880 return;
3881 }
3882 if (option.name == 'sound') {
3883 k._soundsChatSoundWarn(option.value);
3884 }
3885 });
3886 });
3887 }
3888 } catch (e) {
3889 error("Unable to hook to ChatOptions and Arbiter");
3890 dir(e);
3891 }
3892 k._soundsChatLoad();
3893 k._soundsChatInit();
3894
3895 var button = k.soundsChatSoundWarning.getElementsByClassName('uiButton');
3896 button[0].addEventListener('click', function() {
3897 k._soundsTurnOnFbSound();
3898 }, false);
3899
3900 k.soundsInitLoaded = true;
3901 };
3902
3903 // Create a menu item for notification sounds
3904 // Used only on k.soundsInit()
3905 k._soundsMenu_item = function(code) {
3906 var check = false;
3907 if (userSettings.soundsFile == code) {
3908 check = true;
3909 }
3910
3911 k.soundsMenu.createMenuItem({
3912 html: SOUNDS[code].name
3913 ,title: SOUNDS[code].title
3914 ,data: code
3915 ,check: check
3916 ,onclick: function(menuItem, menuClass) {
3917 if (!SOUNDS[code] || !SOUNDS[code].name) {
3918 return;
3919 }
3920
3921 //$('ponyhoof_options_sounds').checked = true;
3922 //userSettings.sounds = true;
3923 userSettings.soundsFile = code;
3924 saveSettings();
3925
3926 k._soundsPreview(code);
3927
3928 menuClass.changeButtonText(menuItem.getText());
3929 menuClass.changeChecked(menuItem);
3930
3931 k.needToSaveLabel = true;
3932 k.updateCloseButton();
3933 }
3934 });
3935 };
3936
3937 // Warn people that Facebook's own chat sound needs to be enabled
3938 // Used 2 times on k.soundsInit()
3939 k._soundsChatSoundWarn = function(isFbSoundEnabled) {
3940 if (isFbSoundEnabled) {
3941 addClass(k.soundsChatSoundWarning, 'hidden_elem');
3942 $('ponyhoof_options_chatSound').disabled = false;
3943 if (userSettings.chatSound) {
3944 $('ponyhoof_options_chatSound').checked = true;
3945 }
3946 } else {
3947 removeClass(k.soundsChatSoundWarning, 'hidden_elem');
3948 $('ponyhoof_options_chatSound').disabled = true;
3949 $('ponyhoof_options_chatSound').checked = false;
3950 }
3951 };
3952
3953 // Turn on Facebook chat sounds
3954 // Used on k.soundsInit() and k.chatSound()
3955 k._soundsTurnOnFbSound = function() {
3956 try {
3957 if (typeof USW.requireLazy == 'function') {
3958 USW.requireLazy(['ChatOptions', 'ChatSidebarDropdown'], function(ChatOptions, ChatSidebarDropdown) {
3959 ChatOptions.setSetting('sound', 1);
3960 ChatSidebarDropdown.prototype.changeSetting('sound', 1);
3961 });
3962 }
3963 } catch (e) {
3964 error("Unable to hook to ChatOptions and ChatSidebarDropdown");
3965 dir(e);
3966 }
3967 };
3968
3969 k._soundsNotifTypeCurrent = [];
3970 // Initialize the notification sound blacklist and its HTML template
3971 // Used only on k.soundsInit()
3972 k._soundsNotifTypeInit = function() {
3973 if (userSettings.soundsNotifTypeBlacklist) {
3974 var current = userSettings.soundsNotifTypeBlacklist.split('|');
3975
3976 for (var code in SOUNDS_NOTIFTYPE) {
3977 if (current.indexOf(code) != -1) {
3978 k._soundsNotifTypeCurrent.push(code);
3979 }
3980 }
3981 }
3982
3983 k.soundsNotifTypeMenu = new Menu('soundsNotifType', $('ponyhoof_options_soundsNotifType'));
3984 k.soundsNotifTypeButton = k.soundsNotifTypeMenu.createButton('');
3985 k.soundsNotifTypeMenu.canSearch = false;
3986 k.soundsNotifTypeMenu.createMenu();
3987 k.soundsNotifTypeMenu.attachButton();
3988
3989 for (var code in SOUNDS_NOTIFTYPE) {
3990 if (SOUNDS_NOTIFTYPE.hasOwnProperty(code)) {
3991 k._soundsNotifTypeInit_item(code);
3992 }
3993 }
3994 k._soundsNotifTypeUpdateButtonText(k._soundsNotifTypeCurrent, k.soundsNotifTypeMenu);
3995 };
3996
3997 // Create a menu item for notification sound blacklist
3998 // Used only on k._soundsNotifTypeInit()
3999 k._soundsNotifTypeInit_item = function(code) {
4000 var check = false;
4001 if (k._soundsNotifTypeCurrent.indexOf(code) != -1) {
4002 check = true;
4003 }
4004
4005 k.soundsNotifTypeMenu.createMenuItem({
4006 html: SOUNDS_NOTIFTYPE[code].name
4007 ,data: code
4008 ,check: check
4009 ,onclick: function(menuItem, menuClass) {
4010 if (!SOUNDS_NOTIFTYPE[code] || !SOUNDS_NOTIFTYPE[code].name) {
4011 return;
4012 }
4013
4014 if (!hasClass(menuItem.menuItem, 'ponyhoof_menuitem_checked')) {
4015 menuItem.menuItem.className += ' ponyhoof_menuitem_checked';
4016
4017 k._soundsNotifTypeCurrent.push(code);
4018 } else {
4019 removeClass(menuItem.menuItem, 'ponyhoof_menuitem_checked');
4020
4021 k._soundsNotifTypeCurrent.splice(k._soundsNotifTypeCurrent.indexOf(code), 1);
4022 }
4023 userSettings.soundsNotifTypeBlacklist = k._soundsNotifTypeCurrent.join('|');
4024 saveSettings();
4025
4026 k._soundsNotifTypeUpdateButtonText(k._soundsNotifTypeCurrent, menuClass);
4027 k.needToSaveLabel = true;
4028 k.updateCloseButton();
4029 }
4030 });
4031 };
4032
4033 // Update the notification sound blacklist button text, perhaps after changes
4034 // Used on k._soundsNotifTypeInit() and k._soundsNotifType_item()
4035 k._soundsNotifTypeUpdateButtonText = function(current, menuClass) {
4036 var buttonText = "("+current.length+" types)";
4037 if (current.length == 0) {
4038 buttonText = "(None)";
4039 } else if (current.length == 1) {
4040 buttonText = SOUNDS_NOTIFTYPE[current[0]].name;
4041 }
4042 menuClass.changeButtonText(buttonText);
4043 };
4044
4045 // Hide/show the extra sound options if the main sound option id disabled/enabled
4046 // Used on k.soundsInit(), the sound option is changed, or DOMNodeInserted is disabled
4047 k.soundsChanged = function() {
4048 k.soundsSettingsWrap = k.soundsSettingsWrap || $('ponyhoof_options_soundsSettingsWrap');
4049 if (userSettings.sounds && !userSettings.disableDomNodeInserted) {
4050 removeClass(k.soundsSettingsWrap, 'hidden_elem');
4051 } else {
4052 addClass(k.soundsSettingsWrap, 'hidden_elem');
4053 }
4054 };
4055
4056 // Calls the main function k.soundsChanged(), and also performs extra cleanup duties, e.g. if the user disable sounds, we need to update the Close button to "Save and Reload"
4057 // Used when the sound option is changed
4058 k.soundsClicked = function() {
4059 k.soundsChanged();
4060
4061 if (userSettings.sounds) {
4062 turnOffFbNotificationSound();
4063 } else {
4064 // We already nuked Facebook's sounds, so we need to reload
4065 k.needsToRefresh = true;
4066 k.updateCloseButton();
4067 }
4068 };
4069
4070 // The wording of this function is a bit confusing
4071 // Hide/show the extra chat sound options if the chat sound option is disabled/enabled
4072 // Used on k.soundsInit() and k.chatSound()
4073 k._soundsChatInit = function() {
4074 if (userSettings.chatSound) {
4075 removeClass(k.soundsChatWrap, 'hidden_elem');
4076 } else {
4077 addClass(k.soundsChatSoundWarning, 'hidden_elem');
4078 addClass(k.soundsChatWrap, 'hidden_elem');
4079 }
4080 };
4081
4082 // Initialize the chat sounds options and its HTML template
4083 // Used only on k.soundsInit()
4084 k._soundsChatLoad = function() {
4085 if (k.soundsChatLoaded) {
4086 return;
4087 }
4088
4089 var desc = "(Select a chat sound)";
4090 if (SOUNDS_CHAT[userSettings.chatSoundFile] && SOUNDS_CHAT[userSettings.chatSoundFile].name) {
4091 desc = SOUNDS_CHAT[userSettings.chatSoundFile].name;
4092 }
4093 k.soundsChatMenu = new Menu('sounds_chat', $('ponyhoof_options_soundsChatSetting'));
4094 k.soundsChatButton = k.soundsChatMenu.createButton(desc);
4095 k.soundsChatMenu.canSearch = false;
4096 k.soundsChatMenu.createMenu();
4097 k.soundsChatMenu.attachButton();
4098 for (var code in SOUNDS_CHAT) {
4099 if (SOUNDS_CHAT.hasOwnProperty(code)) {
4100 k._soundsChatLoad_item(code);
4101 }
4102 }
4103 k.soundsChatLoaded = true;
4104 };
4105
4106 // Create a menu item for chat sound options
4107 // Used only on k._soundsChatLoad()
4108 k._soundsChatLoad_item = function(code) {
4109 var check = false;
4110 if (userSettings.chatSoundFile == code) {
4111 check = true;
4112 }
4113
4114 k.soundsChatMenu.createMenuItem({
4115 html: SOUNDS_CHAT[code].name
4116 ,title: SOUNDS_CHAT[code].title
4117 ,data: code
4118 ,check: check
4119 ,onclick: function(menuItem, menuClass) {
4120 if (!SOUNDS_CHAT[code] || !SOUNDS_CHAT[code].name) {
4121 return;
4122 }
4123
4124 userSettings.chatSoundFile = code;
4125 saveSettings();
4126
4127 k._soundsPreview(code);
4128 changeChatSound(code);
4129
4130 menuClass.changeButtonText(menuItem.getText());
4131 menuClass.changeChecked(menuItem);
4132
4133 k.needToSaveLabel = true;
4134 k.updateCloseButton();
4135 }
4136 });
4137 };
4138
4139 // When the user enables chat sounds, we will turn it on immediately, while if the user chooses to turn it off, we would change the Close button to "Save and Reload"
4140 // Also calls k._soundsChatInit()
4141 // Used when the chat sound option is changed
4142 k.chatSound = function() {
4143 if (userSettings.chatSound) {
4144 // Enable Facebook's chat sound automatically
4145 k._soundsTurnOnFbSound();
4146 if (SOUNDS_CHAT[userSettings.chatSoundFile] && SOUNDS_CHAT[userSettings.chatSoundFile].name) {
4147 changeChatSound(userSettings.chatSoundFile);
4148 }
4149 } else {
4150 // Chat sounds are already ponified, we need to reload to clear it
4151 k.needsToRefresh = true;
4152 k.updateCloseButton();
4153 }
4154 k._soundsChatInit();
4155 };
4156
4157 // Run a sound preview
4158 k._soundsPreview = function(code) {
4159 var sound = code;
4160 if (code == 'AUTO') {
4161 sound = '_sound/defaultNotification';
4162
4163 var data = convertCodeToData(REALPONY);
4164 if (data.soundNotif) {
4165 sound = data.soundNotif;
4166 }
4167 }
4168 try {
4169 var ps = initPonySound('soundsTest', THEMEURL+sound+'.EXT');
4170 ps.respectSettings = false;
4171 ps.wait = 0;
4172 ps.play();
4173 } catch (e) {}
4174 };
4175
4176 k.bgError = null;
4177 k.bgTab = null;
4178 k.bgDrop = null;
4179 k.bgClearCustomBg = false;
4180 k.bgInitLoaded = false;
4181 k.bgInit = function() {
4182 if (k.bgInitLoaded) {
4183 return;
4184 }
4185
4186 k.bgError = $('ponyhoof_options_background_error');
4187 k.bgTab = $('ponyhoof_options_tabs_background');
4188 k.bgDrop = $('ponyhoof_options_background_drop');
4189
4190 if (userSettings.customBg) {
4191 addClass(k.bgTab, 'hasCustom');
4192 addClass($('ponyhoof_options_background_custom'), 'active');
4193 } else if (userSettings.login_bg) {
4194 addClass($('ponyhoof_options_background_loginbg'), 'active');
4195 } else {
4196 addClass($('ponyhoof_options_background_cutie'), 'active');
4197 }
4198
4199 $$(k.bgTab, '.ponyhoof_options_fatradio a', function(ele) {
4200 ele.addEventListener('click', function() {
4201 $$(k.bgTab, '.ponyhoof_options_fatradio a', function(ele2) {
4202 removeClass(ele2.parentNode, 'active');
4203 });
4204
4205 var parent = this.parentNode;
4206 var attr = parent.getAttribute('data-ponyhoof-background');
4207 if (attr == 'custom') {
4208 userSettings.login_bg = false;
4209 changeCustomBg(userSettings.customBg);
4210 k.bgClearCustomBg = false;
4211 } else if (attr == 'loginbg') {
4212 userSettings.login_bg = true;
4213 changeCustomBg(null);
4214 addClass(d.documentElement, 'ponyhoof_settings_login_bg');
4215 k.bgClearCustomBg = true;
4216 } else {
4217 userSettings.login_bg = false;
4218 changeCustomBg(null);
4219 k.bgClearCustomBg = true;
4220 }
4221 addClass(parent, 'active');
4222 saveSettings();
4223
4224 k.needToSaveLabel = true;
4225 k.updateCloseButton();
4226
4227 return false;
4228 }, false);
4229 });
4230
4231 $('ponyhoof_options_background_select').addEventListener('change', function(e) {
4232 if (this.files && this.files[0]) {
4233 k.bgProcessFile(this.files[0]);
4234 }
4235 }, false);
4236
4237 k.bgDropInit();
4238
4239 k.bgInitLoaded = true;
4240 };
4241
4242 k.bgDropInit = function() {
4243 if (typeof w.FileReader == 'undefined') {
4244 k.bgError.textContent = "Custom background images are not supported on your browser. Please update your browser if possible.";
4245 removeClass(k.bgError, 'hidden_elem');
4246 addClass(k.bgDrop, 'hidden_elem');
4247 return;
4248 }
4249
4250 k.bgDrop.addEventListener('drop', function(e) {
4251 e.stopPropagation();
4252 e.preventDefault();
4253
4254 removeClass(this, 'ponyhoof_dropping');
4255
4256 if (e.dataTransfer.files && e.dataTransfer.files[0]) {
4257 k.bgProcessFile(e.dataTransfer.files[0]);
4258 }
4259 }, false);
4260
4261 k.bgDrop.addEventListener('dragover', function(e) {
4262 e.stopPropagation();
4263 e.preventDefault();
4264
4265 e.dataTransfer.dropEffect = 'copy';
4266 }, false);
4267
4268 k.bgDrop.addEventListener('dragenter', function(e) {
4269 addClass(k.bgDrop, 'ponyhoof_dropping');
4270 }, false);
4271
4272
4273 k.bgDrop.addEventListener('dragend', function(e) {
4274 removeClass(k.bgDrop, 'ponyhoof_dropping')
4275 }, false);
4276 }
4277
4278 k.bgProcessFile = function(file) {
4279 if (!file.type.match(/image.*/)) {
4280 if (file.type) {
4281 k.bgError.textContent = "The file ("+file.name+") doesn't seem to be an image ("+file.type+").";
4282 } else {
4283 k.bgError.textContent = "The file ("+file.name+") doesn't seem to be an image.";
4284 }
4285 removeClass(k.bgError, 'hidden_elem');
4286 return;
4287 }
4288
4289 if (file.size > 1024*1024) {
4290 if (file.type && file.type != 'image/jpeg') {
4291 k.bgError.textContent = "Sorry, the file size of your image is too big (over 1 MB) and may not save properly. Try saving your image as a JPEG or resize your image.";
4292 } else {
4293 k.bgError.textContent = "Sorry, the file size of your image is too big (over 1 MB) and may not save properly. Try resizing your image.";
4294 }
4295 removeClass(k.bgError, 'hidden_elem');
4296 return;
4297 }
4298
4299 var reader = new w.FileReader();
4300 reader.onload = function(e) {
4301 addClass(k.bgError, 'hidden_elem');
4302 addClass(k.bgTab, 'hasCustom');
4303
4304 $$(k.bgTab, '.ponyhoof_options_fatradio a', function(ele2) {
4305 removeClass(ele2.parentNode, 'active');
4306 });
4307 addClass($('ponyhoof_options_background_custom'), 'active');
4308 k.bgClearCustomBg = false;
4309
4310 userSettings.login_bg = false;
4311 userSettings.customBg = e.target.result;
4312 saveSettings();
4313
4314 k.needToSaveLabel = true;
4315 k.updateCloseButton();
4316
4317 changeCustomBg(e.target.result);
4318 };
4319 reader.onerror = function(e) {
4320 k.bgError.textContent = "An error occurred reading the file. Please try again.";
4321 dir(e);
4322 removeClass(k.bgError, 'hidden_elem');
4323 };
4324 reader.readAsDataURL(file);
4325 };
4326
4327 k.disableDomNodeInserted = function() {
4328 k.soundsChanged(); // to set k.soundsSettingsWrap
4329
4330 var affectedOptions = ['sounds', 'debug_dominserted_console', 'debug_noMutationObserver', 'debug_mutationDebug', 'debug_betaFacebookLinks'];
4331 //'disableCommentBrohoofed','debug_mutationObserver'
4332 for (var i = 0, len = affectedOptions.length; i < len; i += 1) {
4333 var option = $('ponyhoof_options_'+affectedOptions[i]);
4334 var label = $('ponyhoof_options_label_'+affectedOptions[i]);
4335 if (userSettings.disableDomNodeInserted) {
4336 if (ranDOMNodeInserted) {
4337 k.needsToRefresh = true;
4338 k.updateCloseButton();
4339 }
4340
4341 option.disabled = true;
4342 option.checked = false;
4343
4344 addClass(label, 'ponyhoof_options_unavailable');
4345 label.setAttribute('data-hover', 'tooltip');
4346 label.setAttribute('aria-label', "This feature is not available because HTML detection is disabled, re-enable it at the Misc tab");
4347 } else {
4348 var option = $('ponyhoof_options_'+affectedOptions[i]);
4349 option.disabled = false;
4350 if (userSettings[affectedOptions[i]]) {
4351 option.checked = true;
4352 }
4353
4354 removeClass(label, 'ponyhoof_options_unavailable');
4355 label.removeAttribute('data-hover');
4356 label.removeAttribute('aria-label');
4357 label.removeAttribute('aria-owns');
4358 label.removeAttribute('aria-controls');
4359 label.removeAttribute('aria-haspopup');
4360 }
4361 }
4362 k._debugNoMutationObserver();
4363 };
4364
4365 k.disableDomNodeInsertedClicked = function() {
4366 if (!userSettings.disableDomNodeInserted) {
4367 runDOMNodeInserted();
4368 }
4369 k.disableDomNodeInserted();
4370 };
4371
4372 k.debug_disablelog = function() {
4373 if ($('ponyhoof_options_debug_disablelog').checked) {
4374 CANLOG = false;
4375 } else {
4376 CANLOG = true;
4377 }
4378 };
4379
4380 k.disableDialog = null;
4381 k.disablePonyhoof = function() {
4382 if ($('ponyhoof_dialog_disable')) {
4383 $('ponyhoof_disable_allowLoginScreen').checked = !globalSettings.allowLoginScreen;
4384 $('ponyhoof_disable_runForNewUsers').checked = !globalSettings.runForNewUsers;
4385
4386 k.dialog.hide();
4387 k.disableDialog.show();
4388 $('ponyhoof_disable_ok').focus();
4389 return false;
4390 }
4391
4392 var c = '';
4393 c += "<strong>Are you sure you want to disable Ponyhoof for yourself?</strong><br><br>";
4394 c += "You can re-enable Ponyhoof for yourself at any time by going back to Ponyhoof Options and re-select a character.<br><br>";
4395 c += '<div class="uiInputLabel"><input type="checkbox" class="uiInputLabelCheckbox" id="ponyhoof_disable_allowLoginScreen"><label for="ponyhoof_disable_allowLoginScreen">Don\'t run Ponyhoof on the Facebook login screen</label></div>';
4396 c += '<div class="uiInputLabel" data-hover="tooltip" aria-label="'+CURRENTLANG['settings_disable_runForNewUsers_explain']+'"><input type="checkbox" class="uiInputLabelCheckbox" id="ponyhoof_disable_runForNewUsers"><label for="ponyhoof_disable_runForNewUsers">Don\'t run Ponyhoof for new users <a href="#" class="uiHelpLink"></a></label></div>';
4397
4398 var bottom = '';
4399 bottom += '<a href="#" class="uiButton uiButtonLarge uiButtonConfirm" role="button" id="ponyhoof_disable_ok"><span class="uiButtonText">Disable</span></a>';
4400 bottom += '<a href="#" class="uiButton uiButtonLarge" role="button" id="ponyhoof_disable_no"><span class="uiButtonText">Cancel</span></a>';
4401
4402 k.dialog.hide();
4403 k.disableDialog = new Dialog('disable');
4404 k.disableDialog.alwaysModal = true;
4405 k.disableDialog.create();
4406 k.disableDialog.changeTitle("Disable Ponyhoof");
4407 k.disableDialog.changeContent(c);
4408 k.disableDialog.changeBottom(bottom);
4409
4410 $('ponyhoof_disable_allowLoginScreen').checked = !globalSettings.allowLoginScreen;
4411 $('ponyhoof_disable_runForNewUsers').checked = !globalSettings.runForNewUsers;
4412
4413 k.disableDialog.show();
4414 k.disableDialog.onclose = function() {
4415 k.dialog.show();
4416 };
4417
4418 $('ponyhoof_disable_ok').focus();
4419 $('ponyhoof_disable_ok').addEventListener('click', function() {
4420 userSettings.theme = 'NONE';
4421 saveSettings();
4422
4423 globalSettings.allowLoginScreen = !$('ponyhoof_disable_allowLoginScreen').checked;
4424 globalSettings.runForNewUsers = !$('ponyhoof_disable_runForNewUsers').checked;
4425 saveGlobalSettings();
4426
4427 k.disableDialog.canCloseByEscapeKey = false;
4428 d.body.style.cursor = 'progress';
4429 $('ponyhoof_disable_allowLoginScreen').disabled = true;
4430 $('ponyhoof_disable_runForNewUsers').disabled = true;
4431 $('ponyhoof_disable_ok').className += ' uiButtonDisabled';
4432 $('ponyhoof_disable_no').className += ' uiButtonDisabled';
4433 w.location.reload();
4434
4435 return false;
4436 }, false);
4437
4438 $('ponyhoof_disable_no').addEventListener('click', function() {
4439 k.disableDialog.close();
4440 return false;
4441 }, false);
4442
4443 return false;
4444 };
4445
4446 k.browserPonies = null;
4447 k.runBrowserPonies = function() {
4448 var link = this;
4449 if (hasClass(link, 'ponyhoof_browserponies_loading')) {
4450 return false;
4451 }
4452
4453 var alreadyLoaded = !!k.browserPonies;
4454 addClass(link, 'ponyhoof_browserponies_loading');
4455
4456 if (!alreadyLoaded) {
4457 k.browserPonies = new BrowserPoniesHoof();
4458 }
4459 k.browserPonies.doneCallback = function() {
4460 k.dialog.close();
4461 removeClass(link, 'ponyhoof_browserponies_loading');
4462 if (!alreadyLoaded) {
4463 k.browserPonies.copyrightDialog();
4464 }
4465 k.browserPonies.createDialog();
4466 };
4467 k.browserPonies.errorCallback = function(error) {
4468 removeClass(link, 'ponyhoof_browserponies_loading');
4469 k.browserPonies.createErrorDialog(error);
4470 };
4471 k.browserPonies.run();
4472
4473 return false;
4474 }
4475
4476 k.checkboxStore = {};
4477 k.generateCheckbox = function(id, label, data) {
4478 data = data || {};
4479 var ex = '';
4480 var checkmark = '';
4481
4482 if ((!data.global && userSettings[id]) || (data.global && globalSettings[id])) {
4483 checkmark += ' CHECKED';
4484 }
4485 data.extraClass = data.extraClass || '';
4486 if (data.title) {
4487 label += ' <a href="#" class="uiHelpLink"></a>';
4488 ex += ' data-hover="tooltip" aria-label="'+data.title+'"';
4489 }
4490 if (data.tip) {
4491 label += ' <a href="#" class="uiHelpLink ponyhoof_tip_trigger"><div class="ponyhoof_tip_wrapper"><span class="ponyhoof_tip"><span class="ponyhoof_tip_body">'+data.tip+'</span><span class="ponyhoof_tip_arrow"></span></span></div></a>';
4492 }
4493
4494 k.checkboxStore[id] = data;
4495
4496 return '<div class="uiInputLabel '+data.extraClass+'"'+ex+' id="ponyhoof_options_label_'+id+'"><input type="checkbox" class="uiInputLabelCheckbox" id="ponyhoof_options_'+id+'" data-ponyhoof-checkmark="'+id+'" '+checkmark+'><label for="ponyhoof_options_'+id+'">'+label+'</label></div>';
4497 };
4498
4499 k.checkboxInit = function() {
4500 var extras = $('ponyhoof_dialog_options').querySelectorAll('input[type="checkbox"]');
4501 for (var i = 0, len = extras.length; i < len; i += 1) {
4502 var checkmark = extras[i].getAttribute('data-ponyhoof-checkmark');
4503 var data = {};
4504 if (k.checkboxStore[checkmark]) {
4505 data = k.checkboxStore[checkmark];
4506 }
4507 if (data.tooltipPosition) {
4508 extras[i].parentNode.setAttribute('data-tooltip-position', data.tooltipPosition);
4509 }
4510
4511 extras[i].addEventListener('click', function() {
4512 var checkmark = this.getAttribute('data-ponyhoof-checkmark');
4513 var data = {};
4514 if (k.checkboxStore[checkmark]) {
4515 data = k.checkboxStore[checkmark];
4516 }
4517
4518 if (!data.global) {
4519 userSettings[checkmark] = this.checked;
4520 saveSettings();
4521 } else {
4522 globalSettings[checkmark] = this.checked;
4523 saveGlobalSettings();
4524 }
4525
4526 if (this.checked) {
4527 addClass(d.documentElement, 'ponyhoof_settings_'+checkmark);
4528 } else {
4529 removeClass(d.documentElement, 'ponyhoof_settings_'+checkmark);
4530 }
4531 if (data.refresh) {
4532 k.needsToRefresh = true;
4533 }
4534 if (data.customFunc) {
4535 data.customFunc();
4536 }
4537
4538 k.needToSaveLabel = true;
4539 k.updateCloseButton();
4540 }, true);
4541 }
4542 };
4543
4544 k.tabsExposeDebug = 0;
4545 k.tabsInit = function() {
4546 var tabs = k.dialog.dialog.querySelectorAll('.ponyhoof_tabs a');
4547 for (var i = 0, len = tabs.length; i < len; i += 1) {
4548 tabs[i].addEventListener('click', function(e) {
4549 var tabName = this.getAttribute('data-ponyhoof-tab');
4550 if (tabName == 'extras') {
4551 if (!userSettings.debug_exposed && k.tabsExposeDebug < 5) {
4552 k.tabsExposeDebug += 1;
4553 if (k.tabsExposeDebug >= 5) {
4554 addClass(k.dialog.dialog, 'ponyhoof_options_debugExposed');
4555 k.switchTab('advanced');
4556 return;
4557 }
4558 }
4559 } else {
4560 k.tabsExposeDebug = 0;
4561 }
4562
4563 k.switchTab(tabName);
4564 e.preventDefault();
4565 }, false);
4566 }
4567 };
4568
4569 k.switchTab = function(tabName) {
4570 var tabActions = {
4571 'main': k.mainInit
4572 ,'background': k.bgInit
4573 ,'sounds': k.soundsInit
4574 ,'extras': k.extrasInit
4575 ,'advanced': k.debugInfo
4576 ,'about': k.loadDonate
4577 };
4578 removeClass(k.dialog.dialog.querySelector('.ponyhoof_tabs a.active'), 'active');
4579 addClass(k.dialog.dialog.querySelector('.ponyhoof_tabs a[data-ponyhoof-tab="'+tabName+'"]'), 'active');
4580
4581 try {
4582 if (tabActions[tabName]) {
4583 tabActions[tabName]();
4584 }
4585 } catch (e) {
4586 dir(e);
4587 ponyhoofError(e.toString());
4588 }
4589
4590 $$(k.dialog.dialog, '.ponyhoof_tabs_section', function(section) {
4591 section.style.display = 'none';
4592 });
4593 $('ponyhoof_options_tabs_'+tabName).style.display = 'block';
4594
4595 k.dialog.cardSpaceTick();
4596 };
4597
4598 k.saveButtonClick = function() {
4599 k.dialog.close();
4600 return false;
4601 };
4602
4603 k.dialogOnClose = function() {
4604 d.removeEventListener('keydown', k.kf, true);
4605
4606 if (k.debugLoaded) {
4607 if ($('ponyhoof_options_customcss').value == "Enter any custom CSS to load after Ponyhoof is loaded.") {
4608 userSettings.customcss = '';
4609 } else {
4610 userSettings.customcss = $('ponyhoof_options_customcss').value;
4611 }
4612 }
4613 if (k.canSaveSettings) {
4614 saveSettings();
4615 }
4616
4617 if (k.needsToRefresh) {
4618 w.location.reload();
4619 }
4620 };
4621
4622 k.dialogOnCloseFinish = function() {
4623 k.saveButton.getElementsByClassName('uiButtonText')[0].innerHTML = CURRENTLANG.close;
4624
4625 if (k.canSaveSettings) {
4626 if (k.bgClearCustomBg) {
4627 removeClass(k.bgTab, 'hasCustom');
4628 userSettings.customBg = null;
4629 saveSettings();
4630 }
4631 }
4632 };
4633
4634 k.updateCloseButton = function() {
4635 var button = k.saveButton.getElementsByClassName('uiButtonText')[0];
4636 var text = CURRENTLANG.close;
4637
4638 if (k.needToSaveLabel) {
4639 text = "Save & Close";
4640 }
4641
4642 if (k.needsToRefresh) {
4643 text = "Save & Reload";
4644 }
4645
4646 button.innerHTML = text;
4647 };
4648
4649 k.injectStyle = function() {
4650 var css = '';
4651 //css += '#ponyhoof_options_tabs_main .clearfix {margin-bottom:10px;}';
4652 css += '#ponyhoof_dialog_options .generic_dialog_popup, #ponyhoof_dialog_options .popup {width:480px;}';
4653 css += '#ponyhoof_options_likebox_div {height:80px;}';
4654 //css += 'html.ponyhoof_isusingpage #ponyhoof_options_likebox_div {display:none;}';
4655 css += '#ponyhoof_options_likebox {border:none;overflow:hidden;width:100%;height:80px;}';
4656 css += '#ponyhoof_options_pony {margin:8px 0 16px;}';
4657 css += '.ponyhoof_options_fatlink {display:block;margin-top:10px;}';
4658 css += '.ponyhoof_options_unavailable label {cursor:default;}';
4659 css += '#ponyhoof_dialog_options .usingPage, html.ponyhoof_isusingpage #ponyhoof_dialog_options .notPage {display:none;}';
4660 css += 'html.ponyhoof_isusingpage #ponyhoof_dialog_options .usingPage {display:block;}';
4661 css += 'html.ponyhoof_isusingbusiness #ponyhoof_dialog_options .notBusiness {display:none;}';
4662
4663 css += '#ponyhoof_dialog_options .uiHelpLink {margin-left:2px;}';
4664 css += '#ponyhoof_dialog_options textarea, #ponyhoof_options_tabs_advanced input[type="text"] {font-family:Consolas,"Andale Mono WT","Andale Mono","Lucida Console","Lucida Sans Typewriter","DejaVu Sans Mono","Bitstream Vera Sans Mono","Liberation Mono","Nimbus Mono L",Monaco,"Courier New",Courier,monospace;}';
4665 css += '#ponyhoof_dialog_options textarea {resize:vertical;width:100%;height:60px;min-height:60px;line-height:normal;}';
4666 css += '#ponyhoof_dialog_options .ponyhoof_tabs > a[data-ponyhoof-tab="advanced"] {display:none;}';
4667 css += '#ponyhoof_dialog_options.ponyhoof_options_debugExposed .ponyhoof_tabs > a[data-ponyhoof-tab="advanced"] {display:block;}';
4668
4669 // 214px
4670 css += '.ponyhoof_options_fatradio {margin:8px 0;}';
4671 css += '.ponyhoof_options_fatradio li {width:222px;float:left;margin-left:12px;}';
4672 css += '#ponyhoof_options_tabs_background.hasCustom .ponyhoof_options_fatradio li {width:144px;}';
4673 css += '.ponyhoof_options_fatradio li:first-child {margin:0;}';
4674 css += '.ponyhoof_options_fatradio a {border:1px solid rgba(0,0,0,.3);display:block;text-align:center;width:100%;text-decoration:none;-moz-border-radius:3px;border-radius:3px;-webkit-transition:all .2s ease-in-out;-moz-transition:all .2s ease-in-out;-o-transition:all .2s ease-in-out;transition:all .2s ease-in-out;}';
4675 css += '.ponyhoof_options_fatradio a:hover {-moz-box-shadow:0 0 8px rgba(0,0,0,.3);box-shadow:0 0 8px rgba(0,0,0,.3);}';
4676 css += '.ponyhoof_options_fatradio a:active {background:#ECEFF5;-moz-box-shadow:0 0 8px rgba(0,0,0,.7);box-shadow:0 0 8px rgba(0,0,0,.7);}';
4677 css += '.ponyhoof_options_fatradio li.active a {background-color:#6D84B4;border-color:#3b5998;color:#fff;}';
4678 css += '.ponyhoof_options_fatradio span {padding:4px;display:block;}';
4679 css += '.ponyhoof_options_fatradio .wrap i {height:200px;width:100%;display:block;=webkit-transition:all .2s ease-in;-moz-transition:.2s ease-in;-o-transition:.2s ease-in;transition:.2s ease-in;}';
4680 css += '#ponyhoof_options_tabs_background.hasCustom .ponyhoof_options_fatradio .wrap i {height:144px;}';
4681 css += '#ponyhoof_options_background_cutie .wrap {padding:8px;}';
4682 css += '#ponyhoof_options_background_cutie .wrap i {width:206px;height:184px;}';
4683 css += '#ponyhoof_options_tabs_background.hasCustom #ponyhoof_options_background_cutie .wrap i {width:128px;height:128px;}';
4684 css += '#ponyhoof_options_background_custom {display:none;}';
4685 css += '#ponyhoof_options_tabs_background.hasCustom #ponyhoof_options_background_custom {display:block;}';
4686 css += '#ponyhoof_options_background_custom .wrap i {background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAYAAAByDd+UAAABiElEQVRIx82WMWrDQBBFhQtXJoWr4DP4AD6ACxGCEEj/CVwZFyFHCCkCOYJJkfMYFzmBi1SpjAvjwpUwKZwiDihiV7uOJJOBrVYzbzUz+2eD4AwDYmCXZdkxy7IjsAPioC0rworQWkElPQAHYCMpLO6VYT+r5I+kBfAiqeeCPZVOnxehLqCkWcl/aYVKmpqCATlwA8Q2IBBLurfsLSV1TfWZ2wLWXcDYBBwBeUvAoS2tYdNQSTNX44TA50VgJ2AX2DaQxq2xWQzASUWQtSSiKBpEUTSQBLCu+MOJU64qYO+S+oYD9oGVh/+3DPrATqdNqzTWM827wLcmYRheVZSh5xvn8kDflFaNobNSKikF9h4fr2o2zd7YBx7XIpV0fVrp2dfCALxrStaSJLl1waYNi3ZeHuLFwg9bmhQ5MDIBxy3Ow7lRtCW9WRw+fKQPOFiaZ2q9wMDSMGI6klKH7HVM8xR4djVOD3iVtJDEH15tIbABDpIeaz0hfYAF6/zPh7Aj3b9k0CpXFfYF15zYxmWum1cAAAAASUVORK5CYII=") no-repeat center center;}';
4687
4688 css += '#ponyhoof_options_background_error {margin-bottom:10px;}';
4689 css += '#ponyhoof_options_background_drop {background:#fff;border:2px dashed #75a3f5;padding:8px;position:relative;}'; //margin-bottom:8px;
4690 css += '#ponyhoof_options_background_drop_dropping {background:#fff;background:rgba(255,255,255,.95);border:2px dashed #75a3f5;color:#75a3f5;position:absolute;top:-2px;left:-2px;width:100%;height:100%;font-size:16px;line-height:64px;text-align:center;font-weight:bold;display:none;}';
4691 css += '#ponyhoof_options_background_drop.ponyhoof_dropping #ponyhoof_options_background_drop_dropping {display:block;}';
4692
4693 css += '#ponyhoof_options_tabs_main .ponyhoof_message {margin-top:10px;}';
4694 css += '#ponyhoof_browserponies .ponyhoof_loading {display:none;margin-top:0;vertical-align:text-bottom;}';
4695 css += '#ponyhoof_browserponies.ponyhoof_browserponies_loading .ponyhoof_loading {display:inline-block;}';
4696 css += '#ponyhoof_options_randomPonies .ponyhoof_loading {display:none !important;}';
4697 css += '#ponyhoof_options_randomPonies .ponyhoof_menuitem_checked {display:block;}';
4698 //css += '#ponyhoof_options_tabs_sounds .ponyhoof_message.unavailable {margin-bottom:10px;}';
4699 css += '#ponyhoof_options_soundsSettingsWrap {margin-top:-14px;}';
4700 css += '#ponyhoof_options_soundsVolume {vertical-align:middle;width:50px;}';
4701 css += '#ponyhoof_options_soundsVolume[type="range"] {cursor:pointer;width:200px;}';
4702 css += '#ponyhoof_options_soundsVolumePreview {vertical-align:middle;}';
4703 css += '#ponyhoof_options_soundsVolumeValue {display:none;padding-left:3px;}';
4704 css += '#ponyhoof_options_soundsChatSoundWarning {margin-bottom:10px;}';
4705 css += '#ponyhoof_options_tabs_extras .ponyhoof_show_if_injected + .uiInputLabel, #ponyhoof_options_tabs_extras .uiInputLabel + .ponyhoof_show_if_injected, #ponyhoof_options_tabs_advanced .uiInputLabel + .ponyhoof_show_if_injected {margin-top:3px;}';
4706 css += '#ponyhoof_options_tabs_advanced .ponyhoof_hide_if_injected.ponyhoof_message {margin-bottom:10px;}';
4707 css += '.ponyhoof_options_aboutsection {border-top:1px solid #ccc;margin:10px -10px 0;}';
4708 css += '.ponyhoof_options_aboutsection > .inner {border-top:1px solid #E9E9E9;padding:10px 10px 0;}';
4709 css += '#ponyhoof_options_devpic {display:block;}';
4710 css += '#ponyhoof_options_devpic img {width:50px !important;height:50px !important;}';
4711 css += '#ponyhoof_options_twitter {margin-top:10px;width:100%;height:20px;}';
4712 css += '#ponyhoof_options_plusone {margin-top:10px;height:23px;}';
4713
4714 css += '.ponyhoof_tip_wrapper {position:relative;z-index:10;}';
4715 css += '.ponyhoof_tip_trigger, .ponyhoof_tip_trigger:hover {text-decoration:none;}';
4716 css += '.ponyhoof_tip_trigger:hover .ponyhoof_tip {display:block;}';
4717 css += '.ponyhoof_options_unavailable .ponyhoof_tip_trigger {display:none !important;}';
4718 css += '.ponyhoof_tip {text-align:left;position:absolute;z-index:-1;display:none;top:11px;padding:4px 0 0;right:-7px;color:#000;font-weight:normal;}';
4719 css += '.ponyhoof_tip_body {line-height:15px;width:300px;white-space:normal;background:#fff;border:1px solid;border-color:#888 #999;display:block;left:0;padding:6px 8px;-moz-box-shadow:0 1px 0 rgba(0,0,0,.1);box-shadow:0 1px 0 rgba(0,0,0,.1);}';
4720 css += '.ponyhoof_tip_arrow {position:absolute;top:0;right:10px;border:solid transparent;border-width:0 3px 5px 4px;border-bottom-color:#888;}';
4721
4722 css += '#ponyhoof_donate {background:#EDEFF4;border:1px solid #D2DBEA;color:#9CADCF;font-family:Helvetica,Arial,sans-serif;-webkit-font-smoothing:antialiased;}';
4723 css += '#ponyhoof_donate .inner {background:#EDEFF4;display:block;font-size:16px;font-weight:bold;height:75px;line-height:75px;text-align:center;float:left;width:50%;}';
4724 css += '#ponyhoof_donate a {display:block;width:100%;color:#9CADCF;text-decoration:none;}';
4725 css += '#ponyhoof_options_donatepaypal {border-right:1px solid #D2DBEA;}';
4726 //css += '#ponyhoof_donate_flattr {background-image:url("//api.flattr.com/button/flattr-badge-large.png");background-position:center center;background-repeat:no-repeat;text-indent:-99999px;}';
4727 css += '#ponyhoof_donate_flattr_iframe {width:55px;height:62px;margin-top:6px;}';
4728 css += '#ponyhoof_donate a:hover {background-color:#DEDFE7;color:#3B5998;}';
4729
4730 injectManualStyle(css, 'options');
4731 };
4732
4733 k.show = function() {
4734 if (!k.created) {
4735 k.create();
4736 }
4737 k.dialog.show();
4738 };
4739
4740 k.kr = false;
4741 k.ks = [];
4742 k.kc = '\x33\x38\x2C\x33\x38\x2C\x34\x30\x2C\x34\x30\x2C\x33\x37\x2C\x33\x39\x2C\x33\x37\x2C\x33\x39\x2C\x36\x36\x2C\x36\x35';
4743 k.kf = function(e) {
4744 if (k.kr) {
4745 return;
4746 }
4747
4748 k.ks.push(e.which);
4749 if (k.ks.join(',').indexOf(k.kc) > -1) {
4750 k.kr = true;
4751 k.dialog.close();
4752
4753 var width = 720;
4754 var height = 405;
4755
4756 injectManualStyle('#ponyhoof_dialog_ky .generic_dialog_popup,#ponyhoof_dialog_ky .popup{width:740px;}#ponyhoof_dialog_ky .generic_dialog{z-index:250 !important;}#ponyhoof_kc_align{margin:8px auto 0;text-align:center;}', 'kx');
4757 var di = new Dialog('ky');
4758 di.alwaysModal = true;
4759 di.create();
4760 di.changeTitle("\x54\x48\x45\x20\x55\x4C\x54\x49\x4D\x41\x54\x45\x20\x42\x52\x4F\x4E\x59\x20\x43\x48\x41\x4C\x4C\x45\x4E\x47\x45");
4761 di.changeContent('<iframe src="//hoof.little.my/files/zR7V_bCyZe0.htm" width="100%" height="405" scrolling="auto" frameborder="0" allowTransparency="true"></iframe><div id="ponyhoof_kc_align"><a href="#" class="uiButton uiButtonSpecial ponyhoof_noShareIsCare" id="ponyhoof_kc_share" role="button" data-hover="tooltip" aria-label="\x53\x4F\x20\x4D\x55\x43\x48\x20\x50\x4F\x4E\x59" data-tooltip-alignh="center"><span class="uiButtonText">\x53\x48\x41\x52\x45\x20\x57\x49\x54\x48\x20\x59\x4F\x55\x52\x20\x50\x41\x4C\x53\x21</span></a></div>');
4762 di.addCloseButton();
4763 di.onclosefinish = function() {
4764 di.changeContent('');
4765 };
4766
4767 $('ponyhoof_kc_share').addEventListener('click', function() {
4768 var width = 657;
4769 var height = 412;
4770 w.open('//'+getFbDomain()+'/sharer/sharer.php?u=http://www.youtube.com/watch?v=zR7V_bCyZe0', 'ponyhoof_kc_sharer', 'left='+((screen.width-width)/2)+',top='+(((screen.height-height)/2)-50)+',width='+width+',height='+height);
4771 return false;
4772 }, false);
4773 }
4774 };
4775
4776 k.ki = function() {
4777 d.addEventListener('keydown', k.kf, true);
4778 };
4779 };
4780
4781 var optionsGlobal = null;
4782 function optionsOpen() {
4783 log("Opening options...");
4784
4785 if (!optionsGlobal) {
4786 optionsGlobal = new Options();
4787 }
4788 optionsGlobal.create();
4789 optionsGlobal.show();
4790
4791 $$($('ponyhoof_dialog_options'), '#ponyhoof_options_pony .ponyhoof_button_menu', function(button) {
4792 try {
4793 button.focus();
4794 } catch (e) {}
4795 });
4796 }
4797
4798 // Welcome
4799 var WelcomeUI = function(param) {
4800 var k = this;
4801
4802 if (param) {
4803 k.param = param;
4804 } else {
4805 k.param = {};
4806 }
4807 k.dialogFirst = null;
4808 k.dialogPinkie = null;
4809 k.dialogFinish = null;
4810
4811 k._stack = '';
4812
4813 k.start = function() {
4814 k.injectStyle();
4815 k.createScenery();
4816 addClass(d.documentElement, 'ponyhoof_welcome_html');
4817 statTrack('welcomeUI');
4818
4819 k.showWelcome();
4820 };
4821
4822 k.showWelcome = function() {
4823 if ($('ponyhoof_dialog_welcome')) {
4824 return;
4825 }
4826
4827 addClass(d.documentElement, 'ponyhoof_welcome_html_scenery_loaded');
4828
4829 var co = '';
4830 co += '<div class="uiBoxYellow ponyhoof_message ponyhoof_updater_newVersion">';
4831 co += '<a href="#" class="uiButton uiButtonSpecial rfloat ponyhoof_updater_updateNow" role="button"><span class="uiButtonText">Update now</span></a>';
4832 co += '<span class="wrap">An update (v<span class="ponyhoof_updater_versionNum"></span>) for Ponyhoof is available.</span>';
4833 co += '</div>';
4834
4835 co += '<strong>Select your favorite character to get started:</strong>';
4836 co += '<div id="ponyhoof_welcome_pony"></div>';
4837 co += '<div id="ponyhoof_welcome_afterClose">You can re-select your character in Ponyhoof Options at the Account menu.</div>';
4838
4839 var bottom = '';
4840 bottom += '<a href="#" class="uiButton uiButtonLarge uiButtonConfirm uiButtonDisabled" role="button" id="ponyhoof_welcome_next"><span class="uiButtonText">Next</span></a>';
4841
4842 DIALOGCOUNT += 5;
4843
4844 k.dialogFirst = new Dialog('welcome');
4845 k.dialogFirst.canCardspace = false;
4846 k.dialogFirst.canCloseByEscapeKey = false;
4847 k.dialogFirst.create();
4848 k.dialogFirst.generic_dialogDiv.className += ' generic_dialog_fixed_overflow';
4849 if (BRONYNAME) {
4850 k.dialogFirst.changeTitle("Welcome to Ponyhoof, "+BRONYNAME+"!");
4851 } else {
4852 k.dialogFirst.changeTitle("Welcome to Ponyhoof!");
4853 }
4854 k.dialogFirst.changeContent(co);
4855 k.dialogFirst.changeBottom(bottom);
4856
4857 DIALOGCOUNT += 4;
4858
4859 var menuClosed = false;
4860 var ponySelector = new PonySelector($('ponyhoof_welcome_pony'), k.param);
4861 ponySelector.createSelector();
4862 w.setTimeout(function() {
4863 ponySelector.menu.open();
4864 }, 1);
4865 ponySelector.menu.afterClose = function() {
4866 if (!menuClosed) {
4867 menuClosed = true;
4868 addClass($('ponyhoof_welcome_afterClose'), 'show');
4869
4870 addClass(d.documentElement, 'ponyhoof_welcome_showmedemo');
4871 if ($('navAccount')) {
4872 addClass($('navAccount'), 'openToggler');
4873 }
4874 //addClass($('ponyhoof_account_options'), 'active');
4875
4876 w.setTimeout(function() {
4877 removeClass($('ponyhoof_welcome_next'), 'uiButtonDisabled');
4878 }, 200);
4879 }
4880 };
4881
4882 w.setTimeout(function() {
4883 changeThemeSmart(CURRENTPONY);
4884 }, 10);
4885 k._stack = CURRENTSTACK;
4886
4887 w.setTimeout(function() {
4888 var update = new Updater();
4889 update.checkForUpdates();
4890 }, 500);
4891
4892 // Detect if the Facebook's chat sound setting is turned off
4893 // We need to do this here as it is async
4894 try {
4895 if (typeof USW.requireLazy == 'function') {
4896 USW.requireLazy(['ChatOptions'], function(ChatOptions) {
4897 if (!ChatOptions.getSetting('sound')) {
4898 userSettings.chatSound = false;
4899 }
4900 });
4901 }
4902 } catch (e) {
4903 error("Unable to hook to ChatOptions");
4904 dir(e);
4905 }
4906
4907 $('ponyhoof_welcome_next').addEventListener('click', function(e) {
4908 if (hasClass(this, 'uiButtonDisabled')) {
4909 e.preventDefault();
4910 return false;
4911 }
4912
4913 k.dialogFirst.close();
4914 fadeOut($('ponyhoof_welcome_scenery'));
4915
4916 w.setTimeout(function() {
4917 removeClass(d.documentElement, 'ponyhoof_welcome_showmedemo');
4918 removeClass($('navAccount'), 'openToggler');
4919 removeClass($('ponyhoof_account_options'), 'active');
4920 }, 100);
4921
4922 userSettings.theme = CURRENTPONY;
4923 userSettings.chatSound1401 = true;
4924 // Detect Social Fixer
4925 if ($('bfb_options_button')) {
4926 userSettings.show_messages_other = false;
4927 }
4928 saveSettings();
4929
4930 globalSettings.lastVersion = VERSION;
4931 saveGlobalSettings();
4932
4933 if (CURRENTPONY == 'pinkie') {
4934 k.pinkieWelcome();
4935 } else {
4936 k.createFinalDialog();
4937 }
4938
4939 e.preventDefault();
4940 }, false);
4941 };
4942
4943 k.pinkieWelcome = function() {
4944 removeClass(d.documentElement, 'ponyhoof_welcome_html_scenery_loaded');
4945
4946 var width = 720;
4947 var height = 405;
4948
4949 var bottom = '';
4950 bottom += '<a href="#" class="uiButton uiButtonLarge uiButtonConfirm" role="button" id="ponyhoof_welcome_pinkie_next"><span class="uiButtonText">Stop being silly, Pinkie</span></a>';
4951
4952 k.dialogPinkie = new Dialog('welcome_pinkie');
4953 k.dialogPinkie.alwaysModal = true;
4954 k.dialogPinkie.create();
4955 k.dialogPinkie.changeTitle("\x59\x4F\x55\x20\x43\x48\x4F\x4F\x53\x45\x20\x50\x49\x4E\x4B\x49\x45\x21\x3F\x21");
4956 k.dialogPinkie.changeContent('<iframe src="//hoof.little.my/files/aEPDsG6R4dY.htm" width="100%" height="405" scrolling="auto" frameborder="0" allowTransparency="true"></iframe>');
4957 k.dialogPinkie.changeBottom(bottom);
4958 k.dialogPinkie.onclose = function() {
4959 fadeOut($('ponyhoof_welcome_scenery'));
4960 k.createFinalDialog();
4961 };
4962 k.dialogPinkie.onclosefinish = function() {
4963 k.dialogPinkie.changeContent('');
4964 };
4965
4966 $('ponyhoof_welcome_pinkie_next').addEventListener('click', function(e) {
4967 k.dialogPinkie.close();
4968 e.preventDefault();
4969 }, false);
4970 };
4971
4972 k.createFinalDialog = function() {
4973 removeClass(d.documentElement, 'ponyhoof_welcome_html');
4974 removeClass(d.documentElement, 'ponyhoof_welcome_html_scenery_loaded');
4975
4976 var c = '';
4977
4978 var lang = getDefaultUiLang();
4979 if (lang != 'en_US' && lang != 'en_GB') {
4980 c += '<div class="ponyhoof_message uiBoxYellow"><'+'a href="//'+getFbDomain()+'/ajax/intl/language_dialog.php" rel="dialog" id="ponyhoof_welcome_final_changelanguage">For the best Ponyhoof experience, we recommend switching your Facebook language to English (US). Why? Because ponies!</a></div><br>';
4981 }
4982
4983 if (!ISUSINGBUSINESS) {
4984 c += '<span class="ponyhoof_brohoof_button">'+capitaliseFirstLetter(CURRENTSTACK['like'])+'</span> us to receive news and help for Ponyhoof!';
4985 c += '<iframe src="about:blank" id="ponyhoof_welcome_like" scrolling="no" frameborder="0" allowTransparency="true"></iframe>';
4986 c += 'Got somepony else that you want to suggest? Want to leave some feedback? <a href="'+w.location.protocol+PONYHOOF_URL+'" target="_top" id="ponyhoof_welcome_posttowall">Let us know at our page!</a>';
4987 } else {
4988 c += '<a href="'+w.location.protocol+PONYHOOF_URL+'" target="_top" id="ponyhoof_welcome_posttowall">Visit our Ponyhoof page for the latest news!</a>';
4989 }
4990
4991 var successText = '';
4992 var ponyData = convertCodeToData(CURRENTPONY);
4993 if (ponyData.successText) {
4994 successText = ponyData.successText;
4995 } else {
4996 successText = "Yay!";
4997 }
4998
4999 k.dialogFinish = new Dialog('welcome_final');
5000 if (k._stack != CURRENTSTACK) {
5001 k.dialogFinish.alwaysModal = true;
5002 }
5003 k.dialogFinish.create();
5004 k.dialogFinish.changeTitle(successText);
5005 k.dialogFinish.changeContent(c);
5006 var buttonText = CURRENTLANG.done;
5007 if (k._stack != CURRENTSTACK) {
5008 buttonText = CURRENTLANG.finish;
5009 }
5010 k.dialogFinish.changeBottom('<a href="#" class="uiButton uiButtonLarge uiButtonConfirm" role="button" id="ponyhoof_welcomefinal_ok"><span class="uiButtonText">'+buttonText+'</span></a>');
5011 k.dialogFinish.onclose = function() {
5012 if (k._stack != CURRENTSTACK) {
5013 w.location.reload();
5014 }
5015 };
5016
5017 $('ponyhoof_welcomefinal_ok').addEventListener('click', k.dialogFinishOk, false);
5018 $('ponyhoof_welcomefinal_ok').focus();
5019
5020 if (!ISUSINGBUSINESS) {
5021 w.setTimeout(function() {
5022 $('ponyhoof_welcome_like').src = '//'+getFbDomain()+'/plugins/likebox.php?href=http%3A%2F%2Fwww.facebook.com%2Fprofile.php%3Fid%3D'+PONYHOOF_PAGE+'&width=292&height=62&colorscheme=light&show_faces=false&stream=false&header=false&ponyhoof_runme';
5023 }, 1);
5024 }
5025
5026 $('ponyhoof_welcome_posttowall').addEventListener('click', function(e) {
5027 k.dialogFinish.onclose = function() {};
5028 k.dialogFinish.close();
5029 }, false);
5030 };
5031
5032 k.dialogFinishOk = function(e) {
5033 if (k._stack != CURRENTSTACK) {
5034 if (hasClass(this, 'uiButtonDisabled')) {
5035 return false;
5036 }
5037
5038 this.className += ' uiButtonDisabled';
5039 w.location.reload();
5040 } else {
5041 k.dialogFinish.close();
5042 }
5043 e.preventDefault();
5044 };
5045
5046 k.createScenery = function() {
5047 if ($('ponyhoof_welcome_scenery')) {
5048 $('ponyhoof_welcome_scenery').style.display = 'block';
5049 return;
5050 }
5051
5052 var n = d.createElement('div');
5053 n.id = 'ponyhoof_welcome_scenery';
5054 d.body.appendChild(n);
5055
5056 return n;
5057 };
5058
5059 k.injectStyle = function() {
5060 var css = '';
5061 css += 'html.ponyhoof_welcome_html {overflow:hidden;}';
5062 css += 'html.ponyhoof_welcome_html .fbPageBanner, html.ponyhoof_welcome_html .uiLayer[data-ownerid="userNavigationLabel"], html.ponyhoof_welcome_html ._50d1, html.ponyhoof_welcome_html .-cx-PUBLIC-notificationBeeper__list {display:none !important;}';
5063 css += 'html #ponyhoof_dialog_welcome .generic_dialog_fixed_overflow {background:transparent !important;}';
5064 css += '#ponyhoof_welcome_scenery {width:100%;height:100%;position:fixed;top:0;left:0;background-color:#fff;background-color:rgba(252,252,252,.9);background-repeat:no-repeat;background-position:center center;z-index:'+(DIALOGCOUNT-6)+';}';
5065
5066 //css += '#ponyhoof_dialog_welcome .generic_dialog {z-index:401 !important;}';
5067 css += '#ponyhoof_dialog_welcome .generic_dialog_popup, #ponyhoof_dialog_welcome .popup {width:475px !important;}';
5068 //css += '#ponyhoof_dialog_welcome .content {-webkit-transition:.3s linear;-webkit-transition-property:min-height, padding-top;-moz-transition:.3s linear;-moz-transition-property:min-height, padding-top;-o-transition:.3s linear;-o-transition-property:min-height, padding-top;transition:.3s linear;transition-property:min-height, padding-top;}';
5069 css += '#ponyhoof_dialog_welcome .ponyhoof_updater_newVersion {margin-bottom:10px;}';
5070
5071 css += '#ponyhoof_welcome_newVersion {display:none;margin:0 0 10px;}';
5072 css += '#ponyhoof_welcome_pony {margin:8px 0;}';
5073 css += '#ponyhoof_welcome_afterClose {visibility:hidden;opacity:0;}';
5074 css += '#ponyhoof_welcome_afterClose.show {visibility:visible;opacity:1;-webkit-transition:opacity .3s linear;-moz-transition:opacity .3s linear;-o-transition:opacity .3s linear;transition:opacity .3s linear;}';
5075
5076 css += 'html.ponyhoof_welcome_html_scenery_loaded #blueBar, html.ponyhoof_welcome_html_scenery_loaded #blueBar.fixed_elem {opacity:0;-webkit-transition:opacity .3s linear;-moz-transition:opacity .3s linear;-o-transition:opacity .3s linear;transition:opacity .3s linear;}';
5077 css += 'html.ponyhoof_welcome_showmedemo {cursor:not-allowed;}';
5078 css += 'html.ponyhoof_welcome_showmedemo .popup {cursor:default;}';
5079 css += 'html.ponyhoof_welcome_showmedemo #blueBar #pageHead {width:981px !important;padding-right:0 !important;}';
5080 css += 'html.sidebarMode.ponyhoof_welcome_showmedemo #pageHead, html.sidebarMode.ponyhoof_welcome_showmedemo .sidebarMode #globalContainer {left:0 !important;}';
5081 css += 'html.ponyhoof_welcome_showmedemo #blueBar, html.ponyhoof_welcome_showmedemo.tinyViewport #blueBar, html.ponyhoof_welcome_showmedemo #blueBar.fixed_elem, html.ponyhoof_welcome_showmedemo.tinyViewport #blueBar.fixed_elem {position:fixed !important;z-index:'+(DIALOGCOUNT-4)+';opacity:1;margin-left:0 !important;left:0 !important;right:0 !important;top:0 !important;}';
5082
5083 css += '#ponyhoof_dialog_welcome_pinkie .generic_dialog_popup, #ponyhoof_dialog_welcome_pinkie .popup {width:720px;}';
5084 css += '#ponyhoof_dialog_welcome_pinkie .content {line-height:0;padding:0;}';
5085
5086 css += '#ponyhoof_welcome_like {border:none;overflow:hidden;width:292px;height:62px;margin:8px 0;display:block;}';
5087
5088 injectManualStyle(css, 'welcome');
5089 };
5090 };
5091
5092 // Theme
5093 function getFaviconTag() {
5094 var l = d.getElementsByTagName('link');
5095 for (var i = 0, len = l.length; i < len; i += 1) {
5096 if (l[i].getAttribute('rel') == 'shortcut icon') {
5097 return l[i];
5098 }
5099 }
5100
5101 return false;
5102 }
5103
5104 function changeFavicon(character) {
5105 if (userSettings.noFavicon) {
5106 return;
5107 }
5108
5109 var favicon = getFaviconTag();
5110
5111 if (favicon) {
5112 var newIcon = favicon.cloneNode(true);
5113 } else {
5114 var newIcon = d.createElement('link');
5115 newIcon.rel = 'shortcut icon';
5116 }
5117
5118 if (character != 'NONE') {
5119 newIcon.type = 'image/png';
5120
5121 var data = convertCodeToData(character);
5122 if (data.icon16) {
5123 newIcon.href = THEMEURL+data.icon16;
5124 } else {
5125 newIcon.href = THEMEURL+character+'/icon16.png';
5126 }
5127 } else {
5128 newIcon.type = 'image/x-icon';
5129 newIcon.href = '//fbstatic-a.akamaihd.net/rsrc.php/y9/r/FXHC9IQ-JIj.ico';
5130 }
5131
5132 if (favicon) {
5133 favicon.parentNode.replaceChild(newIcon, favicon);
5134 } else {
5135 d.head.appendChild(newIcon);
5136 }
5137 }
5138
5139 function changeStack(character) {
5140 var pony = convertCodeToData(character);
5141 CURRENTSTACK = STACKS_LANG[0];
5142 if (pony.stack) {
5143 for (var i = 0, len = STACKS_LANG.length; i < len; i += 1) {
5144 if (STACKS_LANG[i].stack == pony.stack) {
5145 CURRENTSTACK = STACKS_LANG[i];
5146 break;
5147 }
5148 }
5149 }
5150
5151 if (UILANG == 'fb_LT') {
5152 if (CURRENTSTACK['people'] == 'ponies') {
5153 CURRENTSTACK['people'] = 'pwnies';
5154 }
5155 if (CURRENTSTACK['person'] == 'pony') {
5156 CURRENTSTACK['person'] = 'pwnie';
5157 }
5158 if (CURRENTSTACK['like'] == 'brohoof') {
5159 CURRENTSTACK['like'] = '/)';
5160 }
5161 if (CURRENTSTACK['likes'] == 'brohoofs') {
5162 CURRENTSTACK['likes'] = '/)';
5163 }
5164 //if (CURRENTSTACK['unlike'] == 'unbrohoof') {
5165 // CURRENTSTACK['unlike'] = '/)(\\';
5166 //}
5167 if (CURRENTSTACK['like_past'] == 'brohoof') {
5168 CURRENTSTACK['like_past'] = '/)';
5169 }
5170 if (CURRENTSTACK['likes_past'] == 'brohoofs') {
5171 CURRENTSTACK['likes_past'] = '/)';
5172 }
5173 if (CURRENTSTACK['liked'] == 'brohoof\'d') {
5174 CURRENTSTACK['liked'] = '/)';
5175 }
5176 if (CURRENTSTACK['liked_button'] == 'brohoof\'d') {
5177 CURRENTSTACK['liked_button'] = '/)';
5178 }
5179 if (CURRENTSTACK['liking'] == 'brohoofing') {
5180 CURRENTSTACK['liking'] = '/)';
5181 }
5182 }
5183 }
5184
5185 var changeThemeFuncQueue = [];
5186 function changeTheme(character) {
5187 addClass(d.documentElement, 'ponyhoof_injected');
5188
5189 REALPONY = character;
5190 d.documentElement.setAttribute('data-ponyhoof-character', character);
5191
5192 changeFavicon(character);
5193 changeStack(character);
5194 buildStackLang();
5195
5196 if (changeThemeFuncQueue) {
5197 for (var x in changeThemeFuncQueue) {
5198 if (changeThemeFuncQueue.hasOwnProperty(x) && changeThemeFuncQueue[x]) {
5199 changeThemeFuncQueue[x]();
5200 }
5201 }
5202 }
5203
5204 // Did we injected our theme already?
5205 if ($('ponyhoof_userscript_style')) {
5206 changeCostume(userSettings.costume);
5207 $('ponyhoof_userscript_style').href = THEMECSS+character+THEMECSS_EXT;
5208 return;
5209 }
5210
5211 addClass(d.documentElement, 'ponyhoof_initial');
5212 w.setTimeout(function() {
5213 removeClass(d.documentElement, 'ponyhoof_initial');
5214 }, 1000);
5215
5216 var n = d.createElement('link');
5217 n.href = THEMECSS+character+THEMECSS_EXT;
5218 n.type = 'text/css';
5219 n.rel = 'stylesheet';
5220 n.id = 'ponyhoof_userscript_style';
5221 d.head.appendChild(n);
5222
5223 changeCostume(userSettings.costume);
5224 }
5225
5226 function getRandomPony() {
5227 while (1) {
5228 var r = randNum(0, PONIES.length-1);
5229 if (!PONIES[r].hidden) {
5230 return PONIES[r].code;
5231 }
5232 }
5233 }
5234
5235 function getRandomMane6() {
5236 while (1) {
5237 var r = randNum(0, PONIES.length-1);
5238 if (PONIES[r].mane6) {
5239 return PONIES[r].code;
5240 }
5241 }
5242 }
5243
5244 function convertCodeToData(code) {
5245 for (var i = 0, len = PONIES.length; i < len; i += 1) {
5246 if (PONIES[i].code == code) {
5247 return PONIES[i];
5248 }
5249 }
5250
5251 return false;
5252 }
5253
5254 function changeThemeSmart(theme) {
5255 switch (theme) {
5256 case 'NONE':
5257 removeClass(d.documentElement, 'ponyhoof_injected');
5258 changeFavicon('NONE');
5259 changeCostume(null);
5260
5261 var style = $('ponyhoof_userscript_style');
5262 if (style) {
5263 style.parentNode.removeChild(style);
5264 }
5265 break;
5266
5267 case 'RANDOM':
5268 var current = [];
5269 if (userSettings.randomPonies) {
5270 current = userSettings.randomPonies.split('|');
5271 changeTheme(current[Math.floor(Math.random() * current.length)]);
5272 } else {
5273 changeTheme(getRandomPony());
5274 }
5275
5276 break;
5277
5278 default:
5279 if (theme == 'login' || convertCodeToData(theme)) {
5280 changeTheme(theme);
5281 } else {
5282 error("changeThemeSmart: "+theme+" is not a valid theme");
5283 userSettings.theme = null;
5284 CURRENTPONY = REALPONY = 'NONE';
5285 }
5286 break;
5287 }
5288 }
5289
5290 function changeCustomBg(base64) {
5291 if (!base64) {
5292 removeClass(d.documentElement, 'ponyhoof_settings_login_bg');
5293 removeClass(d.documentElement, 'ponyhoof_settings_customBg');
5294
5295 var style = $('ponyhoof_style_custombg');
5296 if (style) {
5297 style.parentNode.removeChild(style);
5298 }
5299 return;
5300 }
5301
5302 addClass(d.documentElement, 'ponyhoof_settings_login_bg');
5303 addClass(d.documentElement, 'ponyhoof_settings_customBg');
5304
5305 if (!$('ponyhoof_style_custombg')) {
5306 injectManualStyle('', 'custombg');
5307 }
5308 $('ponyhoof_style_custombg').textContent = '/* '+SIG+' */html,.fbIndex{background-position:center center !important;background-image:url("'+base64+'") !important;}';
5309 }
5310
5311 var changeCostume = function(costume) {
5312 // Make sure the costume exists
5313 if (!COSTUMESX[costume]) {
5314 removeCostume();
5315 return false;
5316 }
5317
5318 // Make sure the character has the costume
5319 if (!doesCharacterHaveCostume(REALPONY, costume)) {
5320 //removeCostume(); // leaving the costume alone wouldn't hurt...
5321 return false;
5322 }
5323
5324 d.documentElement.setAttribute('data-ponyhoof-costume', costume);
5325 };
5326
5327 var removeCostume = function() {
5328 d.documentElement.removeAttribute('data-ponyhoof-costume');
5329 };
5330
5331 var doesCharacterHaveCostume = function(character, costume) {
5332 return (COSTUMESX[costume] && COSTUMESX[costume].characters && COSTUMESX[costume].characters.indexOf(character) != -1);
5333 }
5334
5335 function getBronyName() {
5336 var name = d.querySelector('.headerTinymanName, #navTimeline > .navLink, .fbxWelcomeBoxName, ._521h ._4g5y, .-cx-PRIVATE-litestandSidebarBookmarks__profilewrapper .-cx-PRIVATE-litestandSidebarBookmarks__name');
5337 if (name) {
5338 BRONYNAME = name.textContent;
5339 }
5340
5341 return BRONYNAME;
5342 }
5343
5344 function getDefaultUiLang() {
5345 if (!d.body) {
5346 return false;
5347 }
5348 var classes = d.body.className.split(' ');
5349 for (var i = 0, len = classes.length; i < len; i += 1) {
5350 if (classes[i].indexOf('Locale_') == 0) {
5351 return classes[i].substring('Locale_'.length);
5352 }
5353 }
5354
5355 return false;
5356 }
5357
5358 // Screen saver
5359 var screenSaverTimer = null;
5360 var screenSaverActive = false;
5361 var screenSaverInactivity = function() {
5362 if (!screenSaverActive) {
5363 addClass(d.body, 'ponyhoof_screensaver');
5364 }
5365 screenSaverActive = true;
5366 };
5367 var screenSaverActivity = function() {
5368 if (screenSaverActive) {
5369 removeClass(d.body, 'ponyhoof_screensaver');
5370 }
5371 screenSaverActive = false;
5372
5373 w.clearTimeout(screenSaverTimer);
5374 screenSaverTimer = w.setTimeout(screenSaverInactivity, 30000);
5375 };
5376 var screenSaverActivate = function() {
5377 var mousemoveX = 0;
5378 var mousemoveY = 0;
5379
5380 d.addEventListener('click', screenSaverActivity, true);
5381 d.addEventListener('mousemove', function(e) {
5382 if (mousemoveX == e.clientX && mousemoveY == e.clientY) {
5383 return;
5384 }
5385 mousemoveX = e.clientX;
5386 mousemoveY = e.clientY;
5387
5388 screenSaverActivity();
5389 }, true);
5390 d.addEventListener('keydown', screenSaverActivity, true);
5391 d.addEventListener('contextmenu', screenSaverActivity, true);
5392 d.addEventListener('mousewheel', screenSaverActivity, true);
5393 d.addEventListener('touchstart', screenSaverActivity, true);
5394
5395 screenSaverActivity();
5396 };
5397
5398 // DOMNodeInserted
5399 var domReplaceText = function(ele, cn, deeper, regex, text) {
5400 var t = '';
5401 var id = ele.getAttribute('id');
5402 if ((cn == '' && deeper == '') || (cn && hasClass(ele, cn)) || (cn && id && id == nc)) {
5403 t = ele.innerHTML;
5404 t = t.replace(regex, text);
5405 if (ele.innerHTML != t) {
5406 ele.innerHTML = t;
5407 }
5408
5409 return;
5410 }
5411
5412 if (deeper) {
5413 var query = ele.querySelectorAll(deeper);
5414 if (query.length) {
5415 for (var i = 0, len = query.length; i < len; i += 1) {
5416 t = query[i].innerHTML;
5417 t = t.replace(regex, text);
5418 if (query[i].innerHTML != t) {
5419 query[i].innerHTML = t;
5420 }
5421 }
5422 }
5423 }
5424 };
5425
5426 var _fb_input_placeholderChanged = false;
5427 var domChangeTextbox = function(ele, cn, text) {
5428 var query = ele.querySelectorAll(cn);
5429 if (!query.length) {
5430 return;
5431 }
5432 if (!_fb_input_placeholderChanged) {
5433 contentEval(function(arg) {
5434 try {
5435 if (typeof window.requireLazy == 'function') {
5436 window.requireLazy(['Input'], function(Input) {
5437 var _setPlaceholder = Input.setPlaceholder;
5438 Input.setPlaceholder = function(textbox, t) {
5439 if (!textbox.getAttribute('data-ponyhoof-ponified-overridefb')) {
5440 if (textbox != document.activeElement) {
5441 _setPlaceholder(textbox, t);
5442 }
5443 textbox.setAttribute('data-ponyhoof-ponified-overridefb', 1);
5444 } else {
5445 // we already overridden, now FB wants to change the placeholder
5446 if (textbox.getAttribute('placeholder') == '' && t) {
5447 if (textbox.title) {
5448 // for composer
5449 _setPlaceholder(textbox, textbox.title);
5450 } else {
5451 // for typeahead (share dialog > private message)
5452 _setPlaceholder(textbox, t);
5453 }
5454 } else if (t == '') {
5455 // allow blanking placeholder (for typeahead)
5456 _setPlaceholder(textbox, t);
5457 }
5458 }
5459 };
5460 });
5461 }
5462 } catch (e) {
5463 if (arg.CANLOG && typeof console != 'undefined' && console.log && console.dir) {
5464 console.log("Unable to override Input.setPlaceholder()");
5465 console.dir(e);
5466 }
5467 }
5468 }, {"CANLOG":CANLOG});
5469 _fb_input_placeholderChanged = true;
5470 }
5471
5472 var placeholders = [];
5473 for (var i = 0, len = query.length; i < len; i += 1) {
5474 var textbox = query[i];
5475 if (textbox.getAttribute('data-ponyhoof-ponified')) {
5476 continue;
5477 }
5478 textbox.setAttribute('data-ponyhoof-ponified', 1);
5479
5480 if (typeof text == 'function') {
5481 placeholders[i] = text(textbox);
5482 } else {
5483 placeholders[i] = text;
5484 }
5485
5486 textbox.title = placeholders[i];
5487 textbox.setAttribute('aria-label', placeholders[i]);
5488 textbox.setAttribute('placeholder', placeholders[i]);
5489
5490 if (hasClass(textbox, 'DOMControl_placeholder')) {
5491 textbox.value = placeholders[i];
5492 }
5493 }
5494
5495 /*try {
5496 if (typeof USW.requireLazy == 'function') {
5497 USW.requireLazy(['TextAreaControl'], function(TextAreaControl) {
5498 for (var i = 0; i < query.length; i++) {
5499 if (placeholders[i]) {
5500 //if (query[i] != d.activeElement) {
5501 TextAreaControl.getInstance(query[i]).setPlaceholderText(placeholders[i]);
5502 //}
5503 }
5504 }
5505 });
5506 } else {*/
5507 for (var i = 0, len = query.length; i < len; i += 1) {
5508 if (placeholders[i]) {
5509 var textbox = query[i];
5510 if (!textbox.getAttribute('data-ponyhoof-ponified-overridefb')) {
5511 textbox.setAttribute('aria-label', placeholders[i]);
5512 textbox.setAttribute('placeholder', placeholders[i]);
5513 textbox.setAttribute('data-ponyhoof-ponified-overridefb', 1);
5514 if (textbox == d.activeElement) {
5515 continue;
5516 }
5517 if (textbox.value == '' || hasClass(textbox, 'DOMControl_placeholder')) {
5518 if (placeholders[i]) {
5519 addClass(textbox, 'DOMControl_placeholder');
5520 } else {
5521 removeClass(textbox, 'DOMControl_placeholder');
5522 }
5523 textbox.value = placeholders[i] || '';
5524 }
5525 }
5526 }
5527 }
5528 /*}
5529 } catch (e) {
5530 error("Unable to hook to TextAreaControl");
5531 dir(e);
5532 }*/
5533 };
5534
5535 var domReplaceFunc = function(ele, cn, deeper, func) {
5536 if (!ele || (cn == '' && deeper == '')) {
5537 return;
5538 }
5539
5540 var id = ele.getAttribute('id');
5541 if ((cn && hasClass(ele, cn)) || (cn && id && id == cn)) {
5542 func(ele);
5543 return;
5544 }
5545
5546 if (deeper) {
5547 var query = ele.querySelectorAll(deeper);
5548 if (query.length) {
5549 for (var i = 0, len = query.length; i < len; i += 1) {
5550 func(query[i]);
5551 }
5552 }
5553 }
5554 };
5555
5556 var replaceText = function(arr, t) {
5557 var lowercase = t.toLowerCase();
5558 for (var i = 0, len = arr.length; i < len; i += 1) {
5559 if (arr[i][0] instanceof RegExp) {
5560 t = t.replace(arr[i][0], arr[i][1]);
5561 } else {
5562 if (arr[i][0].toLowerCase() == lowercase) {
5563 t = arr[i][1];
5564 }
5565 }
5566 }
5567
5568 return t;
5569 };
5570
5571 var loopChildText = function(ele, func) {
5572 if (!ele || !ele.childNodes) {
5573 return;
5574 }
5575 for (var i = 0, len = ele.childNodes.length; i < len; i += 1) {
5576 func(ele.childNodes[i]);
5577 }
5578 };
5579
5580 var buttonTitles = [];
5581 var dialogTitles = [];
5582 var tooltipTitles = [];
5583 var headerTitles = [];
5584 var menuTitles = [];
5585 var menuPrivacyOnlyTitles = [];
5586 var dialogDerpTitles = [];
5587 var headerInsightsTitles = [];
5588 var dialogDescriptionTitles = [];
5589 function buildStackLang() {
5590 var ponyData = convertCodeToData(REALPONY);
5591
5592 buttonTitles = [
5593 ["Done", "Eeyup"]
5594 ,["Okay", "Eeyup"]
5595 ,["Done Editing", "Eeyup"]
5596 ,["Save Changes", "Eeyup"]
5597 ,["OK", "Eeyup"]
5598
5599 ,[/everyone/i, "Everypony"] // for Everyone (Most Recent)
5600 ,["Everybody", "Everypony"]
5601 ,["Public", "Everypony"]
5602 ,["Anyone", "Anypony"]
5603 ,["Friends of Friends", capitaliseFirstLetter(CURRENTSTACK['friends'])+" of "+capitaliseFirstLetter(CURRENTSTACK['friends'])]
5604 ,["Friends", capitaliseFirstLetter(CURRENTSTACK['friends'])]
5605 ,["Friends of Guests", capitaliseFirstLetter(CURRENTSTACK['friends'])+" of Guests"]
5606 ,["Only Me", "Alone"]
5607 ,["Only me", "Alone"]
5608 ,["Only Me (+)", "Alone (+)"]
5609 ,["Only me (+)", "Alone (+)"]
5610 ,["No One", "Alone"]
5611 ,["Nobody", "Nopony"]
5612
5613 ,["Add Friend", "Add "+capitaliseFirstLetter(CURRENTSTACK['friend'])]
5614 ,["Friend Request Sent", "Friendship Request Sent"]
5615 ,["Respond to Friend Request", "Respond to Friendship Request"]
5616 ,["Like", capitaliseFirstLetter(CURRENTSTACK['like'])]
5617 ,["Liked", capitaliseFirstLetter(CURRENTSTACK['liked_button'])]
5618 ,["Unlike", capitaliseFirstLetter(CURRENTSTACK['unlike'])]
5619 ,["Like Page", capitaliseFirstLetter(CURRENTSTACK['like'])+" Page"]
5620 ,["Like This Page", capitaliseFirstLetter(CURRENTSTACK['like'])+" This Page"]
5621 ,["Suggest Friends", "Suggest "+capitaliseFirstLetter(CURRENTSTACK['friends'])]
5622 ,["Suggest Friend", "Suggest "+capitaliseFirstLetter(CURRENTSTACK['friend'])]
5623 ,["All Friends", "All "+capitaliseFirstLetter(CURRENTSTACK['friends'])]
5624 ,["All friends", "All "+CURRENTSTACK['friends']]
5625 ,["Poke", "Nuzzle"]
5626
5627 ,["Likes", capitaliseFirstLetter(CURRENTSTACK['likes'])]
5628 ,["Friends' Posts", capitaliseFirstLetter(CURRENTSTACK['friends'])+"' Posts"]
5629
5630 ,["Photos", "Pony Pics"]
5631 ,["People", capitaliseFirstLetter(CURRENTSTACK['people'])]
5632 ,["Banned", "Banished to Moon"]
5633 ,["Blocked", "Banished to Moon"]
5634 ,["People who like this", capitaliseFirstLetter(CURRENTSTACK.people)+" that "+CURRENTSTACK.like_past+" this"]
5635 ,["Pages that like this", "Pages that "+CURRENTSTACK.like_past+" this"]
5636
5637 ,["Delete and Ban User", "Nuke and Banish to Moon"]
5638 ,["Remove from Friends", "Banish to Moon"]
5639 ,["Delete", "Nuke"]
5640 ,["Delete Photo", "Nuke Pony Pic"]
5641 ,["Delete Page", "Nuke Page"]
5642 ,["Delete All", "Nuke All"]
5643 ,["Delete Selected", "Nuke Selected"]
5644 ,["Delete Conversation", "Nuke Conversation"]
5645 ,["Delete Message", "Nuke Friendship Report"]
5646 ,["Delete Messages", "Nuke Friendship Reports"]
5647 ,["Delete Post", "Nuke Post"]
5648 ,["Remove", "Nuke"]
5649 ,["Delete Report", "Nuke This Whining"]
5650 ,["Report", "Whine"]
5651 ,["Report as Spam", "Whine as Spam"]
5652 ,["Clear Searches", "Nuke Searches"]
5653 ,["Report/Remove Tags", "Whine/Nuke Tags"]
5654 ,["Untag Photo", "Untag Pony Pic"]
5655 ,["Untag Photos", "Untag Pony Pics"]
5656 ,["Delete My Account", "Nuke My Account"]
5657 ,["Allowed on Timeline", "Allowed on Journal"]
5658 ,["Hidden from Timeline", "Hidden from Journal"]
5659 ,["Unban", "Unbanish"]
5660 ,["Delete Album", "Nuke Album"]
5661 ,["Cancel Report", "Cancel Whining"]
5662 ,["Unfriend", "Banish to Moon"]
5663 ,["Delete List", "Nuke List"]
5664
5665 ,["Messages", "Trough"]
5666 ,["New Message", "Write a Friendship Report"]
5667 ,["Other Messages", "Other Friendship Reports"]
5668
5669 ,["Share Photo", "Share Pony Pic"]
5670 ,["Share Application", "Share Magic"]
5671 ,["Share Note", "Share Scroll"]
5672 ,["Share Question", "Share Query"]
5673 ,["Share Event", "Share Adventure"]
5674 ,["Share Group", "Share Herd"]
5675 ,["Send Message", "Send Friendship Letter"]
5676 ,["Share Photos", "Share Pony Pics"]
5677 ,["Share This Note", "Share This Scroll"] // entstream
5678 ,["Share This Photo", "Share This Pony Pic"]
5679
5680 ,["Add Friends", "Add "+capitaliseFirstLetter(CURRENTSTACK['friends'])]
5681 ,["Go to App", "Go to Magic"]
5682 ,["Back to Timeline", "Back to Journal"]
5683 ,["Add App", "Add Magic"]
5684 ,["Get More Likes", "Get More "+capitaliseFirstLetter(CURRENTSTACK['likes'])]
5685 ,["Advertise Your App", "Advertise Your Magic"]
5686 ,["Leave App", "Leave Magic"]
5687 ,["Find another app", "Find another magic"]
5688 ,["Post on your timeline", "Post on your journal"]
5689 ,["App Center", "Magic Center"]
5690 ,["View App Center", "View Magic Center"]
5691
5692 ,["Events", "Adventures"]
5693 ,["Page Events", "Page Adventures"]
5694 ,["Suggested Events", "Suggested Adventures"]
5695 ,["Past Events", "Past Adventures"]
5696 ,["Declined Events", "Declined Adventures"]
5697 ,["Create Event", "Plan an Adventure"]
5698 ,["Save Event", "Save Adventure"]
5699 ,["Back to Event", "Back to Adventure"]
5700 ,["Invite Friends", "Invite "+capitaliseFirstLetter(CURRENTSTACK['friends_logic'])]
5701 ,["Page Event", "Page Adventures"]
5702 ,["Upcoming Events", "Upcoming Adventures"]
5703 ,["Group Events", "Herd Adventures"]
5704 ,["Change Event Photo", "Change Pony Pic for Adventure"]
5705 ,["Add Event Photo", "Add Pony Pic for Adventure"]
5706 ,["+ Create an Event", "+ Plan an Adventure"]
5707
5708 ,["Friend Activity", capitaliseFirstLetter(CURRENTSTACK['friend'])+" Activity"]
5709 ,["Activity Log", "Adventure Log"]
5710
5711 ,["Invite More Friends", "Invite More Pals"]
5712 ,["Find Friends", "Find Friendship"]
5713 ,["Pages I Like", "Pages I "+capitaliseFirstLetter(CURRENTSTACK['like_past'])]
5714 ,["Find My Friends", "Find Friendship"]
5715
5716 ,["Leave Group", "Leave Herd"]
5717 ,["Set Up Group Address", "Set Up Herd Address"]
5718 ,["Change Group Photo", "Change Herd Pony Pic"]
5719 ,["Notifications", "Sparks"]
5720 ,["Start Chat", "Start Whinny Chat"]
5721 ,["Create Group", "Create Herd"]
5722 ,["Add People", "Add "+capitaliseFirstLetter(CURRENTSTACK['people'])]
5723 ,["Groups", "Herds"]
5724 ,["Join Group", "Join the Herd"]
5725 ,["View group", "View herd"]
5726 ,["Create New Group", "Create New Herd"]
5727 ,["Set Up Group", "Set Up Herd"] // tour
5728
5729 ,["Move photo", "Move pony pic"]
5730 ,["Delete Photos", "Nuke Pony Pics"]
5731 ,["Keep Photos", "Keep Pony Pics"]
5732 ,["Save Photo", "Save Pony Pic"]
5733 ,["Tag Photos", "Tag Pony Pics"]
5734 ,["Add Photos", "Add Pony Pics"]
5735 ,["Upload Photos", "Upload Pony Pics"]
5736 ,["Tag Photo", "Tag Pony Pic"]
5737 ,["Add More Photos", "Add More Pony Pics"]
5738 ,["Post Photos", "Post Pony Pics"]
5739 ,["Add Photos to Map", "Add Pony Pics to Map"]
5740 ,["Add Photo", "Add Pony Pic"]
5741
5742 ,["On your own timeline", "On your own journal"]
5743 ,["On a friend's timeline", "On a "+CURRENTSTACK['friend']+"'s journal"]
5744 ,["In a group", "In a herd"]
5745 ,["In a private Message", "In a private Friendship Report"]
5746
5747 ,["Timeline", "Journal"]
5748 ,["Notes", "Scrolls"]
5749 ,["Comments", "Friendship Letters"]
5750 ,["Posts and Apps", "Posts and Magic"]
5751 ,["Timeline Review", "Journal Review"]
5752 ,["Pokes", "Nuzzles"]
5753 ,["Add to Timeline", "Add to Journal"]
5754
5755 ,["Photo", "Pony Pic"]
5756 ,["Question", "Query"]
5757
5758 //,["Create List", "Create Directory"]
5759 ,["See All Friends", "See All "+capitaliseFirstLetter(CURRENTSTACK['friends'])]
5760 //,["Manage List", "Manage Directory"]
5761 ,["Write a Note", "Write a Scroll"]
5762 ,["Add Note", "Add Scroll"]
5763 ,["Edit Featured Likes", "Edit Featured "+capitaliseFirstLetter(CURRENTSTACK['likes'])]
5764 ,["Add Featured Likes", "Add Featured "+capitaliseFirstLetter(CURRENTSTACK['likes'])]
5765 ,["Add profile picture", "Add journal pony pic"]
5766 ,["Edit Profile Picture", "Edit Journal Pony Pic"]
5767 //,["Create an Ad", "Buy a Cupcake"]
5768 //,["On This List", "On This Directory"]
5769 ,["Friend Requests", "Friendship Requests"]
5770 //,["Add Friends to List", "Add "+capitaliseFirstLetter(CURRENTSTACK['friends'])+" to Directory"]
5771 ,["Add Friends to List", "Add "+capitaliseFirstLetter(CURRENTSTACK['friends'])+" to List"]
5772
5773 ,["Pages I like", "Pages I "+capitaliseFirstLetter(CURRENTSTACK.like)]
5774 ,["My Friends", "My "+capitaliseFirstLetter(CURRENTSTACK.friends)]
5775 ,["Tell Friends", "Tell "+capitaliseFirstLetter(CURRENTSTACK.friends)]
5776
5777 ,["Add to Profile", "Add to Journal"]
5778 ,["Add Likes", "Add "+capitaliseFirstLetter(CURRENTSTACK.likes)]
5779 ,["Set as Profile Picture", "Set as Journal Pony Pic"]
5780 ,["View Activity Log", "View Adventure Log"]
5781 ,["Invite Your Friends", "Invite Your "+capitaliseFirstLetter(CURRENTSTACK['friends'])]
5782 ,["Suggest Photo", "Suggest Pony Pic"]
5783 ,["All Apps", "All Magic"]
5784 ,["Link My Profile to Twitter", "Link My Journal to Twitter"]
5785 ,["Link profile to Twitter", "Link journal to Twitter"]
5786 ,["The app sends you a notification", "The magic sends you a spark"]
5787 ,["Upload a Photo", "Upload a Pony Pic"]
5788 ,["Take a Photo", "Take a Pony Pic"]
5789 ,["Take a Picture", "Take a Pony Pic"] // edit page
5790
5791 ,["Search All Friends", "Search All "+capitaliseFirstLetter(CURRENTSTACK.friends)] // invite friends
5792 ,["Top Comments", "Top Friendship Letters"] // comment resort
5793 ,["Likers", "Brohoofers"] // graph search @todo likers
5794 ,["Go to Activity Log", "Go to Adventure Log"] // checkpoint
5795
5796 ,["Create New App", "Create New Magic"]
5797 ,["Submit App Detail Page", "Submit Magic Detail Page"]
5798 ,["Edit App", "Edit Magic"]
5799 ,["Promote App", "Promote Magic"]
5800 ,["Make Friends", "Make "+capitaliseFirstLetter(CURRENTSTACK['friends'])]
5801 ,["Add to Other Apps", "Add to Other Magic"]
5802 ];
5803
5804 dialogTitles = [
5805 [/People who like /i, capitaliseFirstLetter(CURRENTSTACK['people'])+" who "+CURRENTSTACK['like_past']+" "]
5806 ,[/Friends who like /i, capitaliseFirstLetter(CURRENTSTACK['friends_logic'])+" who "+CURRENTSTACK['like_past']+" "]
5807 ,["People who voted for this option", capitaliseFirstLetter(CURRENTSTACK['people'])+" who voted for this option"]
5808 ,["People who are following this question", capitaliseFirstLetter(CURRENTSTACK['people'])+" who are following this question"]
5809 ,[/People Connected to /, capitaliseFirstLetter(CURRENTSTACK['people'])+" Connected to "]
5810 ,["People who saw this", capitaliseFirstLetter(CURRENTSTACK['people'])+" who saw this"]
5811 ,["Added Friends", "Added "+capitaliseFirstLetter(CURRENTSTACK.friends)]
5812 ,["People who can repro this", capitaliseFirstLetter(CURRENTSTACK['people'])+" who can repro this"]
5813 ,["Friends that like this", capitaliseFirstLetter(CURRENTSTACK['friends_logic'])+" that "+CURRENTSTACK['like_past']+" this"]
5814
5815 ,["Share this Profile", "Share this Journal"]
5816 ,["Share This Photo", "Share This Pony Pic"]
5817 //,["Share this Album", ""]
5818 ,["Share this Note", "Share this Scroll"]
5819 ,["Share this Group", "Share this Herd"]
5820 ,["Share this Event", "Share this Adventure"]
5821 //,["Share this Ad", ""]
5822 ,["Share this Application", "Share this Magic"]
5823 //,["Share this Video", ""]
5824 //,["Share this Page", "Share this Landmark"]
5825 //,["Share this Page", "You gotta share!"]
5826 //,["Share this Job", ""]
5827 //,["Share this Status", "You gotta share!"]
5828 ,["Share this Question", "Share this Query"]
5829 //,["Share this Link", "You gotta share!"]
5830 ,["Share", "You gotta share!"]
5831 //,["Share this Help Content", ""]
5832 ,["Send This Photo", "Send This Pony Pic"]
5833 ,["Share Photo", "Share Pony Pic"]
5834
5835 ,["Timeline and Tagging", "Journal and Tagging"]
5836 ,["Timeline Review", "Journal Review"]
5837 //,["Friends Can Check You Into Places", capitaliseFirstLetter(CURRENTSTACK['friends_logic'])+" Can Check You Into Landmarks"]
5838 //,["Limit The Audience for Old Posts on Your Timeline", "Limit The Audience for Old Posts on Your Journal"]
5839 //,["How people bring your info to apps they use", "How "+CURRENTSTACK['people']+" bring your info to magic they use"]
5840 //,["Turn off Apps, Plugins and Websites", "Turn off Magic, Plugins and Websites"]
5841
5842 ,["Likes", capitaliseFirstLetter(CURRENTSTACK['likes'])]
5843 ,["Edit Featured Likes", "Edit Featured "+capitaliseFirstLetter(CURRENTSTACK['likes'])]
5844 ,["Change Date", "Time Travel"]
5845 ,["Date Saved", "Time Traveled"]
5846
5847 ,["Delete", "Nuke"]
5848 ,["Delete Comment", "Nuke Friendship Letter"]
5849 ,["Delete Photo", "Nuke Pony Pic"]
5850 ,["Remove Picture?", "Nuke Pony Pic?"]
5851 ,["Delete Video?", "Nuke Video?"]
5852 ,["Delete Milestone", "Nuke Milestone"]
5853 ,["Delete Page?", "Nuke Page?"]
5854 ,["Delete this Message?", "Nuke this Friendship Report?"]
5855 ,["Delete This Entire Conversation?", "Nuke This Entire Conversation?"]
5856 ,["Delete These Messages?", "Nuke These Friendship Reports?"]
5857 ,["Delete Post", "Nuke Post"]
5858 ,["Delete Post?", "Nuke Post?"]
5859 ,["Delete Page Permanently?", "Nuke Page Permanently?"]
5860 ,["Unlike", capitaliseFirstLetter(CURRENTSTACK['unlike'])]
5861 ,["Remove Search", "Nuke Search"]
5862 //,["Clear Searches", "Nuke Searches"]
5863 ,["Untag Photo", "Untag Pony Pic"]
5864 ,["Untag Photos", "Untag Pony Pics"]
5865 ,["Permanently Delete Account", "Permanently Nuke Account"]
5866 ,["Remove", "Nuke"]
5867 ,["Delete and Ban Member", "Nuke and Banish to Moon"]
5868 ,["Delete Album", "Nuke Album"]
5869 ,["Are you sure you want to clear all your searches?", "Are you sure you want to nuke all your searches?"]
5870 ,["Remove Photo?", "Nuke Pony Pic?"]
5871 ,["Removed Group Photo", "Nuked Herd Pony Pic"]
5872 ,["Post Deleted", "Post Nuked"]
5873 ,["Remove Event", "Nuke Adventure"]
5874 ,["Delete Entry?", "Nuke Entry?"]
5875 ,["Delete Video", "Nuke Video"]
5876 ,["Delete Event", "Nuke Adventure"] // for group admin
5877
5878 ,["Report and/or Block This Person", "Whine and/or Block This Pony"] // 0
5879 ,["Report This Photo", "Whine About This Pony Pic"]
5880 ,["Report This Event", "Whine About This Adventure"]
5881 ,["Report Conversation", "Whine About Conversation"]
5882 ,["Report as Spam?", "Whine as Spam?"]
5883 ,["Invalid Report", "Invalid Whining"]
5884 ,["Report This Page", "Whine About This Page"]
5885 ,["Report This Doc Revision", "Whine About This Doc Revision"]
5886 ,["Confirm Report", "Confirm Whining"]
5887 ,["Report This Place", "Whine About This Place"] // 64
5888 ,["Thanks For This Report", "Thanks For Whining"]
5889 ,["Send Message", "Send Friendship Report"] // social report
5890 ,["Send Messages", "Send Friendship Reports"]
5891 ,["Why don't you like these photos?", "Why don't you like these pony pics?"]
5892 ,["Photos Untagged and Messages Sent", "Pony Pics Untagged and Friendship Reports Sent"]
5893 ,["Report This Post", "Whine About This Post"] // report lists as a page
5894 ,["Report This?", "Whine About This?"]
5895 ,["Report Recommendation", "Whine About Recommendation"] // 108
5896 ,["Why don't you like this photo?", "Why don't you like this pony pic?"]
5897 ,["Report Spam or Abuse", "Whine as Spam or Abuse"] // messages
5898 ,["Report Incorrect External Link", "Whine About Incorrect External Link"] // page vertex // 87
5899
5900 // report types: 5: links / 125: status / 70: group post / 86: og post
5901 ,["Is this post about you or a friend?", "Is this post about you or a "+CURRENTSTACK.friend+"?"]
5902 ,["Why are you reporting this Page?", "Why are you whining about this Page?"] // 23
5903 ,["Is this group about you or a friend?", "Is this herd about you or a "+CURRENTSTACK['friend']+"?"] // 1
5904 ,["Is this comment about you or a friend?", "Is this friendship letter about you or a "+CURRENTSTACK['friend']+"?"] // 71 / 74: page comment
5905 //,["Is this list about you or a friend?", "Is this directory about you a "+CURRENTSTACK.friend+"?"] // 92
5906 ,["Is this list about you or a friend?", "Is this list about you a "+CURRENTSTACK.friend+"?"] // 92
5907 ,["Is this photo about you or a friend?", "Is this pony pic about you or a "+CURRENTSTACK['friend']+"?"] // 2
5908 ,["Is this note about you or a friend?", "Is this scroll about you or a "+CURRENTSTACK['friend']+"?"] // 4
5909 ,["Is this video about you or a friend?", "Is this video about you or a "+CURRENTSTACK['friend']+"?"] // 13
5910 ,["Is this event about you or a friend?", "Is this adventure about you or a "+CURRENTSTACK['friend']+"?"] // 81
5911
5912 ,["How to Report Posts", "How to Whine About Posts"]
5913 ,["How to Report Posts on My Timeline", "How to Whine About Posts on My Journal"]
5914 ,["How to Report the Profile Picture", "How to Whine About the Journal Pony Pic"]
5915 ,["Why are you reporting this photo?", "Why are you whining about this pony pic?"]
5916 ,["How to Report the Cover", "How to Whine About the Cover"]
5917 ,["How to Report Messages", "How to Whine About Friendship Reports"]
5918 ,["How to Report a Page", "How to Whine About a Page"]
5919 ,["How to Report a Group", "How to Whine About a Herd"]
5920 ,["How to Report an Event", "How to Whine About an Adventure"]
5921 ,["How to Report Page Posts", "How to Whine About Page Posts"]
5922
5923 ,["New Message", "Write a Friendship Report"]
5924 ,["Forward Message", "Forward this Friendship Report"]
5925 ,["Delete This Message?", "Nuke This Friendship Report?"]
5926 ,["Message Not Sent", "Friendship Report Not Sent"]
5927 ,["Add People", "Add "+capitaliseFirstLetter(CURRENTSTACK['people'])]
5928 ,["Add Photos", "Add Pony Pics"]
5929 ,["People in this message", capitaliseFirstLetter(CURRENTSTACK['people'])+" in this friendship report"]
5930 ,["Message Sent", "Friendship Report Sent"]
5931 ,["Message Filtering Preferences", "Friendship Report Filtering Preferences"]
5932
5933 ,["Create New Group", "Create New Herd"]
5934 ,[/Create New Event/, "Plan an Adventure"]
5935 ,["Notification Settings", "Spark Settings"]
5936 ,["Create Group Email Address", "Create Herd Email Address"]
5937 ,["Set Up Group Web and Email Address", "Set Up Herd Web and Email Address"]
5938 ,["Mute Chat?", "Mute Whinny Chat?"]
5939 ,["Add Friends to Group", "Add "+capitaliseFirstLetter(CURRENTSTACK['friends_logic'])+" to the Herd"]
5940 ,["Add People to Group", "Add "+capitaliseFirstLetter(CURRENTSTACK['people'])+" to the Herd"]
5941 ,["Not a member of the group", "Not a member of the herd"]
5942 ,["Invite People to Group by Email", "Invite "+capitaliseFirstLetter(CURRENTSTACK.people)+" to Herd by Email"]
5943 ,["Remove Group Admin", "Remove Herd Admin"]
5944 ,["Add Group Admin", "Add Herd Admin"]
5945
5946 ,["Cancel Event?", "Cancel Adventure?"]
5947 ,["Change Event Photo", "Change Pony Pic for Adventure"]
5948 ,["Add Event Photo", "Add Adventure Pony Pic"]
5949 ,["Export Event", "Export Adventure"]
5950 ,["Edit Event Info", "Edit Adventure Info"]
5951 ,["Create Repeat Event", "Plan a Repeat Adventure"]
5952 ,["Event Invites", "Adventure Invites"]
5953
5954 ,["Hide all recent profile changes?", "Hide all recent journal changes?"]
5955 ,["Edit your profile story settings", "Edit your journal story settings"]
5956 ,["Edit your timeline recent activity settings", "Edit your journal recent activity settings"]
5957 ,["Hide all recent likes activity?", "Hide all recent "+CURRENTSTACK.likes+" activity?"]
5958 ,["Edit Privacy of Likes", "Edit Privacy of "+capitaliseFirstLetter(CURRENTSTACK.likes)]
5959
5960 ,["Edit News Feed Settings", "Edit Feed Bag Settings"]
5961 //,["Create New List", "Create New Directory"]
5962 ,["Invite Friends", "Invite "+capitaliseFirstLetter(CURRENTSTACK['friends_logic'])]
5963 ,["Advanced Chat Settings", "Advanced Whinny Chat Settings"]
5964 ,["Notifications Updated", "Sparks Updated"]
5965 ,["Move photo to another album?", "Move pony pic to another album?"]
5966 ,["Group Muted", "Herd Muted"]
5967 ,["Block App?", "Block Magic?"]
5968 //,["List Notification Settings", "Directory Spark Settings"]
5969 ,["List Notification Settings", "List Spark Settings"]
5970 ,["Like This Photo?", "Like This Pony Pic?"]
5971 ,["Friends", capitaliseFirstLetter(CURRENTSTACK['friends'])]
5972 ,["All Friends", "All "+capitaliseFirstLetter(CURRENTSTACK['friends'])]
5973 ,["Suggest Friend", "Suggest "+capitaliseFirstLetter(CURRENTSTACK.friend)]
5974 ,["Blocked People", "Blocked "+capitaliseFirstLetter(CURRENTSTACK.people)]
5975 ,["Block People", "Block "+capitaliseFirstLetter(CURRENTSTACK.people)]
5976 ,["Tag Friends", "Tag "+capitaliseFirstLetter(CURRENTSTACK.friends)]
5977 ,["Unable to edit Group", "Unable to edit Herd"]
5978 ,["Thanks for Inviting Your Friends", "Thanks for Inviting Your "+capitaliseFirstLetter(CURRENTSTACK.friends)]
5979 ,["Timeline Gift Preview", "Journal Gift Preview"]
5980 ,["Friend Request Setting", "Friendship Request Setting"]
5981 ,["Invalid Question", "Invalid Query"]
5982 //,["List Subscribers", "Directory Subscribers"]
5983 ,["People Who Shared This", capitaliseFirstLetter(CURRENTSTACK.people)+" Who Shared This"]
5984 //,["Edit List Settings", "Edit Directory Settings"]
5985 ,["Remove App", "Remove Magic"]
5986 ,["Turn Off Chat", "Turn Off Whinny Chat"]
5987 ,["Access Log", "Adventure Log"]
5988 ,["Post to Your Wall", "Post to Your Journal"]
5989
5990 ,["Take a Profile Picture", "Take a Journal Pony Pic"]
5991 ,["Choosing Your Cover Photo", "Choosing Your Cover Pony Pic"]
5992 ,["Choose from Group Photos", "Choose from Herd Pony Pics"]
5993 ,["Group Albums", "Herd Albums"]
5994 ,["Choose From Your Photos", "Choose From Your Pony Pics"]
5995 ,["Choose from Photos", "Choose from Pony Pics"]
5996 ,["Choose Your Cover Photo", "Choose Your Cover Pony Pic"]
5997 ,["Choose from your synced photos", "Choose from your synced pony pics"]
5998
5999 ,["Create New App", "Create New Magic"]
6000 ,["Add Test Users to other Apps", "Add Test Users to other Magic"]
6001 ];
6002 if (ponyData.successText) {
6003 dialogTitles.push(["Success", ponyData.successText]);
6004 dialogTitles.push(["Success!", ponyData.successText]);
6005 }
6006
6007 tooltipTitles = [
6008 [/everyone/gi, "Everypony"]
6009 //,[/\bpublic\b/g, "everypony"]
6010 ,[/\bPublic\b/g, "Everypony"]
6011 ,["People you're not friends with can follow you and see only your public posts.", capitaliseFirstLetter(CURRENTSTACK.people)+" you're not pals with can follow you and see only your public posts."]
6012 //,["These people subscribe to the lists you're featured on", "These "+capitaliseFirstLetter(CURRENTSTACK['people'])+" subscribe to the directories you're featured on"]
6013 ,["These people subscribe to the lists you're featured on", "These "+capitaliseFirstLetter(CURRENTSTACK['people'])+" subscribe to the lists you're featured on"]
6014 ,["Friends of anyone going to this event", capitaliseFirstLetter(CURRENTSTACK['friends'])+" of anypony going to this adventure"]
6015 ,["Friends of guests going to this event can see and join it", capitaliseFirstLetter(CURRENTSTACK['friends'])+" of guests going to this adventure can see and join it"]
6016 ,["Anyone can see and join this event", "Anypony can see and join this adventure"]
6017 ,["Your friends will see your comment in News Feed.", "Your "+CURRENTSTACK['friends']+" will see your friendship letter in Feed Bag."]
6018 ,[/\bfriends in group\b/, CURRENTSTACK['friends']+" in herd"]
6019 ,[/\bfriends of friends\b/g, CURRENTSTACK['friends']+" of "+CURRENTSTACK['friends']]
6020 ,[/\bFriends of Friends\b/g, capitaliseFirstLetter(CURRENTSTACK['friends'])+" of "+capitaliseFirstLetter(CURRENTSTACK['friends'])]
6021 ,[/\bfriends\b/g, CURRENTSTACK['friends']]
6022 ,[/\bFriends\b/g, capitaliseFirstLetter(CURRENTSTACK['friends'])]
6023 ,["Only Me", "Alone"]
6024 ,["Only me", "Alone"]
6025 ,["No One", "Alone"]
6026 ,["Only you", "Alone"]
6027 ,["Anyone tagged", "Anypony tagged"]
6028 //,[/cover photos are everypony/i, "Everypony can see your cover pony pics"]
6029 ,["Cover photos are public", "Everypony can see your cover pony pics"]
6030 ,[/any other information you made Everypony/i, "any other information that everypony can see"]
6031 ,["Anyone can see this Everypony comment", "Everypony can see this public friendship letter"]
6032 //,["Remember: all place ratings are Everypony.", "Remember: everypony can see all place ratings."]
6033 ,["Everypony can see posts on this Everypony page.", "Everypony can see posts on this public page."]
6034 ,["Name, profile picture, age range, gender, language, country and other public info", "Name, profile picture, age range, gender, language, country and other public info"]
6035 //,["Name, profile picture, age range, gender, language, country and other Everypony info", "Name, profile picture, age range, gender, language, country and other public info"]
6036 ,["This will hide you from Everypony attribution", "This will hide you from public attribution"]
6037 ,["Remember: all place ratings are public.", "Remember: everypony can see all place ratings."]
6038 ,["Shared with: Anyone who can see this page", "Shared with: Anypony who can see this page"]
6039 ,["Anyone can see the group, who's in it, and what members post.", "Anypony can see the herd, who's in it, and what members post."]
6040 ,["Anyone can see the group and who's in it. Only members see posts.", "Anypony can see the herd and who's in it. Only members see posts."]
6041 ,["Only members see the group, who's in it, and what members post.", "Only members see the herd, who's in it, and what members post."]
6042
6043 ,["Show comments", "Show friendship letters"]
6044 ,["Comment deleted", "Friendship letter nuked"]
6045 ,[/Comments/, "Friendship Letters"]
6046 ,[/Comment/, "Friendship Letter"]
6047
6048 ,["Remove", "Nuke"]
6049 ,["Edit or Delete", "Edit or Nuke"]
6050 ,["Edit or Remove", "Edit or Nuke"]
6051 ,["Delete Post", "Nuke Post"]
6052 ,["Remove or Report", "Nuke or Whine"]
6053 ,["Report", "Whine"]
6054 ,["Report/Mark as Spam", "Whine/Mark as Spam"]
6055 ,["Report as not relevant", "Whine as not relevant"]
6056 ,["Remove Invite", "Nuke Invite"]
6057 ,["Report/Remove Tag", "Whine/Nuke Tag"]
6058 ,["Delete", "Nuke"]
6059 ,["Delete and Ban", "Nuke and Banish"]
6060 ,["Report Place", "Whine About Place"]
6061
6062 ,["Shown on Timeline", "Shown on Journal"]
6063 ,["Allow on Timeline", "Allow on Journal"]
6064 ,["Highlighted on Timeline", "Highlighted on Journal"]
6065 ,["Allowed on Timeline", "Allowed on Journal"]
6066 ,["Hidden from Timeline", "Hidden from Journal"]
6067
6068 //,[/likes? this/g, "brohoof'd this"]
6069 ,["Sent from chat", "Sent from whinny chat"]
6070 ,["New Message", "Write a Friendship Report"]
6071
6072 //,[/\bpeople\b/gi, "ponies"]
6073 ,[/See who likes this/gi, "See who "+CURRENTSTACK['likes']+" this"]
6074 ,[/people like this\./gi, CURRENTSTACK['people']+" "+CURRENTSTACK['like_past']+" this."] // entstream
6075 ,[/like this\./gi, CURRENTSTACK['like_past']+" this."]
6076 ,[/likes this\./gi, CURRENTSTACK['likes_past']+" this."]
6077
6078 // top right pages
6079 ,["Status", "Take a Note"]
6080 ,["Photo / Video", "Add a Pic"]
6081 ,["Event, Milestone +", "Adventure, Milestone +"]
6082
6083 ,["Onsite Notifications", "Onsite Sparks"]
6084 ,["Create Event", "Plan an Adventure"]
6085 ,["Search messages in this conversation", "Search friendship reports in this conversation"]
6086 ,["Open photo viewer", "Open pony pic viewer"]
6087 ,["Choose a unique image for the cover of your timeline.", "Choose a unique pony pic for the cover of your journal."]
6088 ,["Remove from Dashboard", "Remove from Dashieboard"]
6089 ,["Choose a unique cover photo to express what your Page is about.", "Choose a unique cover pony pic to express what your Page is about."]
6090
6091 ,["Each photo has its own privacy setting", "Each pony pic has its own privacy setting"]
6092 ,["You can change the audience for each photo in this album", "You can change the audience for each pony pic in this album"]
6093
6094 ,["View Photo", "View Pony Pic"]
6095
6096 // litestand navigation when collapsed
6097 ,["News Feed", "Feed Bag"]
6098 ,["Messages", "Trough"]
6099 ,["Pokes", "Nuzzles"]
6100 ,["Manage Apps", "Manage Magic"]
6101 ,["Events", "Adventures"]
6102 ,["App Center", "Magic Center"]
6103
6104 // photo comments
6105 ,["Attach a Photo", "Attach a Pony Pic"]
6106
6107 ,["Dismiss and go to most recent message", "Dismiss and go to most recent friendship letter"] // messages
6108 ,["To create an offer, your Page needs at least 100 likes.", "To create an offer, your Page needs at least 100 "+CURRENTSTACK['likes']+"."] // page composer
6109
6110 // developers
6111 ,["Enable the newsfeed ticker", "Enable the feedbag ticker"]
6112 ,["Add selected users to other apps you own.", "Add selected users to other magic you own."]
6113 ,["Remove selected users from this app.", "Remove selected users from this magic."]
6114
6115 // insights
6116 ,["The total number of clicks on your posts, not including likes, comments, or shares, which are broken out above.", "The total number of clicks on your posts, not including "+CURRENTSTACK['likes']+", comments, or shares, which are broken out above."]
6117 ,["The percentage of people who liked, commented, shared or clicked on your post after having seen it.", "The percentage of people who "+CURRENTSTACK['liked']+", commented, shared or clicked on your post after having seen it."]
6118 ];
6119 if (ponyData.loadingText) {
6120 tooltipTitles.push(["Loading...", ponyData.loadingText]);
6121 }
6122
6123 headerTitles = [
6124 //["List Suggestions", "Directory Suggestions"]
6125 ["People You May Know", capitaliseFirstLetter(CURRENTSTACK.people)+" You May Know"]
6126 ,["Sponsored", "Cupcake Money"]
6127 ,["Pokes", "Nuzzles"]
6128 ,["People To Follow", capitaliseFirstLetter(CURRENTSTACK.people)+" To Follow"]
6129 ,["Poke Suggestions", "Nuzzle Suggestions"]
6130 ,["Suggested Groups", "Suggested Herds"]
6131 ,["Find More Friends", "Find Friendship"]
6132 ,["Rate Recently Used Apps", "Rate Recently Used Magic"]
6133 ,["Friends' Photos", "Pals' Pony Pics"]
6134 ,["Add a Location to Your Photos", "Add a Location to Your Pony Pics"]
6135 ,["Suggest Friends", "Suggest "+capitaliseFirstLetter(CURRENTSTACK.friends)]
6136 ,["Other Pages You Like", "Other Pages You "+capitaliseFirstLetter(CURRENTSTACK.like)]
6137 ,["Entertainment Pages You Might Like", "Entertainment Pages You Might "+capitaliseFirstLetter(CURRENTSTACK.like)]
6138 ,["Music Pages You Might Like", "Music Pages You Might "+capitaliseFirstLetter(CURRENTSTACK.like)]
6139 ,["Add Personal Contacts as Friends", "Add Personal Contacts as "+capitaliseFirstLetter(CURRENTSTACK.friends)]
6140 ,["Find Friends", "Find Friendship"]
6141 //,[/On This List/, "On This Directory"]
6142 //,["On this list", "On this directory"]
6143 //,["On This List", "On This Directory"]
6144 ,["Related Groups", "Related Herds"]
6145
6146 ,["Notifications", "Sparks"]
6147 ,["New Likes", "New "+capitaliseFirstLetter(CURRENTSTACK['likes'])]
6148 ,["Invite Friends", "Invite "+capitaliseFirstLetter(CURRENTSTACK['friends'])]
6149 ,["Get More Likes", "Get More "+capitaliseFirstLetter(CURRENTSTACK['likes'])]
6150 ,["Added Apps", "Added Magic"]
6151 ,["Apps You May Like", "Magic You May "+capitaliseFirstLetter(CURRENTSTACK.like)]
6152 ,["Your Apps", "Your Magic"]
6153 ,["People Talking About This", capitaliseFirstLetter(CURRENTSTACK.people)+" Blabbering About This"]
6154 ,["Total Likes", "Total "+capitaliseFirstLetter(CURRENTSTACK['likes'])]
6155 ,["Games You May Like", "Games You May "+capitaliseFirstLetter(CURRENTSTACK.like)]
6156
6157 ,["Messages", "Trough"]
6158 ,["Other Messages", "Other Friendship Reports"]
6159 ,["Unread Messages", "Unread Friendship Reports"]
6160 ,["Sent Messages", "Sent Friendship Reports"]
6161 ,["Archived Messages", "Archived Friendship Reports"]
6162
6163 ,["Groups", "Herds"]
6164 //,["Pages and Ads", "Landmarks and Ads"]
6165 ,["Apps", "Magic"]
6166 ,[/Friends who like /gi, capitaliseFirstLetter(CURRENTSTACK['friends_logic'])+" who "+CURRENTSTACK['like_past']+" "]
6167 ,["Favorites", capitaliseFirstLetter(CURRENTSTACK['likes'])]
6168 ,["Likes", capitaliseFirstLetter(CURRENTSTACK['likes'])]
6169 ,["Events", "Adventures"]
6170 ,["Friends", capitaliseFirstLetter(CURRENTSTACK['friends'])]
6171 ,["Ads", "Cupcakes"]
6172 ,["Mutual Likes", "Mutual "+capitaliseFirstLetter(CURRENTSTACK.likes)]
6173 ,[/Mutual Friends/, "Mutual "+capitaliseFirstLetter(CURRENTSTACK.friends)]
6174
6175 ,["Notes", "Scrolls"]
6176 ,["My Notes", "My Scrolls"]
6177 ,["Notes About Me", "Scrolls About Me"]
6178 ,["Write a Note", "Write a Scroll"]
6179 ,["Edit Note", "Edit Scroll"]
6180
6181 ,["Timeline and Tagging", "Journal and Tagging"]
6182 ,["Ads, Apps and Websites", "Ads, Magic and Websites"]
6183 ,["Blocked People and Apps", "Banished "+capitaliseFirstLetter(CURRENTSTACK['people'])+" and Magic"]
6184 ,["Notifications Settings", "Sparks Settings"]
6185 ,["App Settings", "Magic Settings"]
6186 ,["Friend Requests", "Friendship Requests"]
6187 ,["People Who Shared This", capitaliseFirstLetter(CURRENTSTACK.people)+" Who Shared This"]
6188 ,["Your Notifications", "Your Sparks"]
6189 ,["Timeline and Tagging Settings", "Journal and Tagging Settings"]
6190 ,["Delete My Account", "Nuke My Account"]
6191
6192 ,["Posts in Groups", "Posts in Herds"]
6193 ,["People", capitaliseFirstLetter(CURRENTSTACK['people'])]
6194
6195 ,["Posts by Friends", "Posts by "+capitaliseFirstLetter(CURRENTSTACK.friends)]
6196 ,["Support Dashboard", "Support Dashieboard"]
6197 ,["Event Invitations", "Adventure Invitations"]
6198 ,["Who Is in These Photos?", "Who Is in These Pony Pics?"]
6199 ,["People who like this", capitaliseFirstLetter(CURRENTSTACK.people)+" that "+CURRENTSTACK.like_past+" this"]
6200 //,["List Subscribers", "Directory Subscribers"]
6201 ,["Upcoming Events", "Upcoming Adventures"]
6202 ,["Photos and Videos", "Pony Pics and Videos"]
6203 ,["People Who Are Going", capitaliseFirstLetter(CURRENTSTACK.people)+" Who Are Going"]
6204 ,["Would you like to opt out of this email notification?", "Would you like to opt out of this email spark?"]
6205 ,["Confirm Like", "Confirm "+capitaliseFirstLetter(CURRENTSTACK['like'])]
6206
6207 ,["Invite Friends You Email", "Invite "+capitaliseFirstLetter(CURRENTSTACK['friends'])+" You Email "]
6208 ,["Invite Your Friends", "Invite Your "+capitaliseFirstLetter(CURRENTSTACK['friends'])]
6209
6210 ,["Account Groups", "Account Herds"]
6211 ,["Ads Email Notifications", "Ads Email Soarks"]
6212 ,["Ads Notifications on Facebook", "Ads Sparks on Facebook"]
6213
6214 ,["App Restrictions", "Magic Restrictions"]
6215 ,["App Info", "Magic Info"]
6216
6217 ,["Tagged Photos", "Tagged Pony Pics"]
6218
6219 ,["Add Groups", "Add Herds"] // /addgroup
6220 ];
6221
6222 menuTitles = [
6223 ["Everyone", "Everypony"]
6224 ,["Everybody", "Everypony"]
6225 ,["Public", "Everypony"]
6226 ,["Anyone", "Anypony"]
6227 ,["Friends of Friends", capitaliseFirstLetter(CURRENTSTACK['friends'])+" of "+capitaliseFirstLetter(CURRENTSTACK['friends'])]
6228 ,["Friends except Acquaintances", capitaliseFirstLetter(CURRENTSTACK['friends'])+" except Acquaintances"]
6229 ,["Friends", capitaliseFirstLetter(CURRENTSTACK['friends'])]
6230 ,["Friends ", capitaliseFirstLetter(CURRENTSTACK['friends'])]
6231 ,["Friends of Guests", capitaliseFirstLetter(CURRENTSTACK['friends'])+" of Guests"]
6232 ,["Only Me", "Alone"]
6233 ,["Only me", "Alone"]
6234 ,["No One", "Alone"]
6235 ,["Nobody", "Nopony"]
6236 //,["See all lists...", "See entire directory..."]
6237
6238 ,["Mutual Friends", "Mutual "+capitaliseFirstLetter(CURRENTSTACK['friends'])]
6239 ,["People You May Know", "Ponies You May Know"]
6240 ,["Poke...", "Nuzzle..."]
6241 ,["Poke", "Nuzzle"]
6242 ,["All Friends", "All "+capitaliseFirstLetter(CURRENTSTACK['friends'])]
6243 ,["All friends", "All "+CURRENTSTACK['friends']]
6244
6245 ,["On your own timeline", "On your own journal"]
6246 ,["On a friend's timeline", "On a "+CURRENTSTACK['friend']+"'s journal"]
6247 ,["In a group", "In a herd"]
6248 ,["In a private Message", "In a private Friendship Report"]
6249
6250 ,["Friends' Posts", capitaliseFirstLetter(CURRENTSTACK['friends'])+"' Posts"]
6251 ,["Friend Activity", capitaliseFirstLetter(CURRENTSTACK['friend'])+" Activity"]
6252
6253 ,["Change Date...", "Time Travel..."]
6254 ,["Reposition Photo...", "Reposition Pony Pic..."]
6255 ,["Manage Notifications", "Manage Sparks"]
6256 ,["Use Activity Log", "Use Adventure Log"]
6257 ,["See Banned Users...", "See Ponies who were Banished to the Moon..."]
6258 ,["Invite Friends...", "Invite "+capitaliseFirstLetter(CURRENTSTACK['friends'])+"..."]
6259 ,["Like As Your Page...", capitaliseFirstLetter(CURRENTSTACK.like)+" As Your Page..."]
6260 ,["Add App to Page", "Add Magic to App"]
6261 ,["Change Primary Photo", "Change Primary Pony Pic"]
6262 ,["Change Date", "Time Travel"]
6263
6264 ,["People", capitaliseFirstLetter(CURRENTSTACK['people'])]
6265 //,["Pages", "Landmarks"]
6266 ,["Banned", "Banished to Moon"]
6267 ,["Blocked", "Banished to Moon"]
6268 ,["People who like this", capitaliseFirstLetter(CURRENTSTACK.people)+" who "+CURRENTSTACK.like_past+" this"]
6269 ,["Pages that like this", "Pages that "+CURRENTSTACK.like_past+" this"]
6270
6271 ,["Unlike", capitaliseFirstLetter(CURRENTSTACK['unlike'])]
6272 ,["Unlike...", capitaliseFirstLetter(CURRENTSTACK['unlike'])+"..."]
6273 ,["Show in News Feed", "Show in Feed Bag"]
6274 ,["Suggest Friends...", "Suggest "+capitaliseFirstLetter(CURRENTSTACK['friends'])+"..."]
6275 ,["Unfriend...", "Banish to Moon..."]
6276 ,["Unfriend", "Banish to Moon"]
6277 //,["New List...", "New Directory..."]
6278 ,["Get Notifications", "Get Sparks"]
6279 //,["Add to another list...", "Add to another directory..."]
6280
6281 ,["Create Event", "Plan an Adventure"]
6282 ,["Edit Group", "Edit Herd"]
6283 ,["Report Group", "Whine about Herd"]
6284 ,["Leave Group", "Leave Herd"]
6285 ,["Edit Group Settings", "Edit Herd Settings"]
6286 ,["Choose from Group Photos", "Choose from Herd Pony Pics"]
6287 ,["Upload a Photo", "Upload a Pony Pic"]
6288 ,["Remove from Group", "Banish to Moon"]
6289 ,["Share Group", "Share Herd"]
6290 ,["Create Group", "Create Herd"]
6291 ,["Change group settings", "Change herd settings"]
6292 ,["Add People to Group", "Add "+capitaliseFirstLetter(CURRENTSTACK['people'])+" to the Herd"]
6293 ,["Send Message", "Send Friendship Report"]
6294 ,["View Group", "View Herd"]
6295 ,["Add People", "Add "+capitaliseFirstLetter(CURRENTSTACK['people'])]
6296
6297 ,["Remove App", "Remove Magic"]
6298 ,["Uninstall App", "Uninstall Magic"]
6299 ,["Report App", "Whine about Magic"]
6300 ,["Block App", "Block Magic"]
6301 ,["Find More Apps", "Find More Magic"]
6302 ,["No more apps to add.", "No more magic to add."]
6303
6304 ,["Delete Post And Remove User", "Nuke Post And Banish to Moon"]
6305 ,["Delete Post And Ban User", "Nuke Post And Banish to Moon"]
6306 ,["Hide from Timeline", "Hide from Journal"]
6307 ,["Delete", "Nuke"]
6308 ,["Delete...", "Nuke..."]
6309 ,["Delete Photo", "Nuke Pony Pic..."]
6310 ,["Delete This Photo", "Nuke This Pony Pic"]
6311 ,["Delete Messages...", "Nuke Friendship Reports..."]
6312 ,["Delete Post", "Nuke Post"]
6313 ,["Delete Comment", "Nuke Friendship Letter..."]
6314 ,["Show on Timeline", "Show on Journal"]
6315 ,["Show on Profile", "Show on Journal"]
6316 ,["Shown on Timeline", "Shown on Journal"]
6317 ,["Allow on Timeline", "Allow on Journal"]
6318 ,["Highlighted on Timeline", "Highlighted on Journal"]
6319 ,["Allowed on Timeline", "Allowed on Journal"]
6320 ,["Hidden from Timeline", "Hidden from Journal"]
6321 ,["Remove", "Nuke"]
6322 ,["Delete Photo...", "Nuke Pony Pic..."]
6323 ,["Remove this photo", "Nuke this pony pic"]
6324 ,["Remove photo", "Nuke pony pic"]
6325 ,["Remove...", "Nuke..."]
6326 ,["Delete Conversation...", "Nuke Conversation..."]
6327 ,["Delete Album", "Nuke Album"]
6328 ,["Delete Comment...", "Nuke Friendship Letter..."]
6329 ,["Hide Comment...", "Hide Friendship Letter..."]
6330 ,["Hide Event", "Hide Adventure"]
6331 ,["Hide Comment", "Hide Friendship Letter"]
6332 ,["Delete Post...", "Nuke Post..."]
6333 ,["Delete Video", "Nuke Video"]
6334 ,["Delete Event", "Nuke Adventure"] // for group admin
6335
6336 ,["Report/Block...", "Whine/Block..."]
6337 ,["Report/Mark as Spam", "Whine/Mark as Spam"]
6338 ,["Report Page", "Whine about Page"]
6339 ,["Report Story or Spam", "Whine about Story or Spam"]
6340 ,["Report/Mark as Spam...", "Whine/Mark as Spam..."]
6341 ,["Report story...", "Whine about story..."]
6342 ,["Report as Spam or Abuse...", "Whine as Spam or Abuse..."]
6343 ,["Report Spam or Abuse...", "Whine as Spam or Abuse..."]
6344 ,["Report as Spam...", "Whine as Spam..."]
6345 ,["Report Conversation...", "Whine about Conversation..."]
6346 ,["Report This Photo", "Whine About This Pony Pic"]
6347 ,["Report/Remove Tag", "Whine/Nuke Tag"]
6348 ,["Mark as Spam", "Whine as Spam"]
6349 ,["Report/Remove Tag...", "Whine/Nuke Tag..."]
6350 ,["Report Content", "Whine about Content"]
6351 ,["Report Profile", "Whine about Journal"]
6352 ,["Report User", "Whine about This Pony"]
6353 ,["Report", "Whine"]
6354 ,["Report Place", "Whine about Place"]
6355 ,["Report App", "Whine about Magic"]
6356 //,["Report list", "Whine about directory"]
6357 ,["Report list", "Whine about list"]
6358 ,["Event at a place", "Adventure at a place"]
6359
6360 ,["Hide this recent activity story from Timeline", "Hide this recent activity story from Journal"]
6361 ,["Hide Similar Activity from Timeline...", "Hide Similar Activity from Journal..."]
6362 //,["Hide All Recent Lists from Timeline...", "Hide All Recent Directories from Journal..."]
6363 ,["Hide All Recent Lists from Timeline...", "Hide All Recent Lists from Journal..."]
6364 ,["Hide all Friend Highlights from Timeline", "Hide all "+capitaliseFirstLetter(CURRENTSTACK.friend)+" Highlights from Journal"]
6365 ,["Hide This Action from Profile...", "Hide This Action from Journal..."]
6366 ,["Hide All Recent profile changes from Profile...", "Hide All Recent journal changes from Journal..."]
6367 ,["Hide All Recent Pages from Timeline...", "Hide All Recent Pages from Journal..."]
6368 ,["See Photos Hidden From Timeline", "See Pony Pics Hidden From Journal"]
6369 ,["Hide Similar Activity from Timeline", "Hide Similar Activity from Journal"]
6370
6371 ,["Upcoming Events", "Upcoming Adventures"]
6372 ,["Suggested Events", "Suggested Adventures"]
6373 ,["Past Events", "Past Adventures"]
6374 ,["Past events", "Past adventures"]
6375 ,["Declined Events", "Declined Adventures"]
6376 ,["Export Events...", "Export Adventures..."]
6377 ,["Add Event Photo", "Add Adventure Pony Pic"]
6378 ,["Cancel Event", "Cancel Adventure"]
6379 ,["Export Event", "Export Adventure"]
6380 ,["Share Event", "Share Adventure"]
6381 ,["Turn Off Notifications", "Turn Off Sparks"]
6382 ,["Turn On Notifications", "Turn On Sparks"]
6383 ,["Promote Event", "Promote Adventure"]
6384 ,["Create Repeat Event", "Create Repeat Adventure"]
6385 ,["Message Guests", "Start Whinny Chat with Guests"]
6386 ,["Edit Event", "Edit Adventure"]
6387 ,["Publish Event on Timeline", "Publish Adventure on Journal"]
6388
6389 ,["Add Friends to Chat...", "Add "+capitaliseFirstLetter(CURRENTSTACK.friends)+" to Whinny Chat..."]
6390 ,["Chat Sounds", "Whinny Chat Sounds"]
6391 ,["Add People...", "Add "+capitaliseFirstLetter(CURRENTSTACK['people'])+"..."]
6392 ,["Unread Messages", "Unread Friendship Reports"]
6393 ,["Archived Messages", "Archived Friendship Reports"]
6394 ,["Sent Messages", "Sent Friendship Reports"]
6395 ,["Forward Messages...", "Forward Friendship Reports..."]
6396 ,["Turn Off Chat", "Turn Off Whinny Chat"]
6397 ,["Open in Chat", "Open in Whinny Chat"]
6398 ,["Create Group...", "Create Herd..."]
6399 ,["Turn On Chat", "Turn On Whinny Chat"]
6400
6401 ,["Add/Remove Friends...", "Add/Remove "+capitaliseFirstLetter(CURRENTSTACK.friends)+"..."]
6402 ,["Comments and Likes", "Friendship Letters and Brohoofs"]
6403 //,["Archive List", "Archive Directory"]
6404 //,["On This List", "On This Directory"]
6405 //,["Restore List", "Restore Directory"]
6406
6407 //,["Rename List", "Rename Directory"]
6408 //,["Edit List", "Edit Directory"]
6409 ,["Notification Settings...", "Spark Settings..."]
6410 //,["Delete List", "Nuke Directory"]
6411 ,["Delete List", "Nuke List"]
6412
6413 ,["Likes", capitaliseFirstLetter(CURRENTSTACK['likes'])]
6414 ,["Photos", "Pony Pics"]
6415 ,["Comments", "Friendship Letters"]
6416 ,["Questions", "Queries"]
6417 ,["Events", "Adventures"]
6418 ,["Groups", "Herds"]
6419 ,["Timeline", "Journal"]
6420 ,["Notes", "Scrolls"]
6421 ,["Posts and Apps", "Posts and Magic"]
6422 ,["Recent Likes", "Recent "+capitaliseFirstLetter(CURRENTSTACK['likes'])]
6423 ,["Recent Comments", "Recent Friendship Letters"]
6424 ,["Timeline Review", "Journal Review"]
6425 ,["Pokes", "Nuzzles"]
6426 ,["Activity Log...", "Adventure Log..."]
6427 ,["Activity Log", "Adventure Log"]
6428 ,["Timeline Settings", "Journal Settings"]
6429 ,["Likers", "Brohoofers"] // @todo likers
6430 ,["Open Groups", "Open Herds"]
6431 ,["Cancel Friend Request", "Cancel Friendship Request"] // activity log
6432
6433 ,["Choose from Photos...", "Choose from Pony Pics..."]
6434 ,["Upload Photo...", "Upload Pony Pic..."]
6435 ,["Take Photo...", "Take Pony Pic..."]
6436 ,["Choose from my Photos", "Choose from my Pony Pics"]
6437 ,["Reposition Photo", "Reposition Pony Pic"]
6438 ,["Add Synced Photo...", "Add Synced Pony Pic..."]
6439 ,["Change Primary Photo...", "Change Primary Pony Pic..."]
6440 ,["Choose from Photo Albums...", "Choose from Pony Pic Albums..."]
6441 ,["Suggest this photo...", "Suggest this pony pic..."]
6442
6443 ,["Photo", "Pony Pic"]
6444 ,["Question", "Query"]
6445
6446 ,["Pages I like", "Pages I "+capitaliseFirstLetter(CURRENTSTACK.like)]
6447 ,["My Friends", "My "+capitaliseFirstLetter(CURRENTSTACK.friends)]
6448 ,["All Notifications", "All Sparks"]
6449 ,["Search All Friends", "Search All "+capitaliseFirstLetter(CURRENTSTACK.friends)]
6450 ,["All Apps", "All Magic"]
6451
6452 ,["Page Likes", "Page "+capitaliseFirstLetter(CURRENTSTACK.likes)]
6453 ,["Mentions and Photo Tags", "Mentions and Pony Pic Tags"]
6454
6455 ,["Suggest photos", "Suggest pony pics"]
6456
6457 ,["Make Profile Picture", "Make Journal Pony Pic"]
6458 ,["Make Profile Picture for Page", "Make Journal Pony Pic for Page"]
6459 ,["Make Cover Photo", "Make Cover Pony Pic"]
6460
6461 ,["The app sends you a notification", "The magic sends you a spark"]
6462
6463 // comment resort
6464 ,["Top Comments", "Top Friendship Letters"]
6465
6466 // insights
6467 ,["Post Clicks / Likes, Comments & Shares", "Post Clicks / "+capitaliseFirstLetter(CURRENTSTACK['likes'])+", Comments & Shares"]
6468 ,["Likes / Comments / Shares", capitaliseFirstLetter(CURRENTSTACK['likes'])+" / Comments / Shares"]
6469 ,["Post Hides, Hides of All Posts, Reports of Spam, Unlikes of Page", "Post Hides, Hides of All Posts, Whining of Spam, Unbrohoofs of Page"] // @todo
6470 ,["Likes, Comments & Shares", capitaliseFirstLetter(CURRENTSTACK['likes'])+", Comments & Shares"]
6471 ];
6472
6473 menuPrivacyOnlyTitles = [
6474 ["Everyone", "Everypony"]
6475 ,["Public", "Everypony"]
6476 ,["Anyone", "Anypony"]
6477 ,["Friends of Friends", capitaliseFirstLetter(CURRENTSTACK['friends'])+" of "+capitaliseFirstLetter(CURRENTSTACK['friends'])]
6478 ,["Friends except Acquaintances", capitaliseFirstLetter(CURRENTSTACK['friends'])+" except Acquaintances"]
6479 ,["Friends", capitaliseFirstLetter(CURRENTSTACK['friends'])]
6480 ,["Friends ", capitaliseFirstLetter(CURRENTSTACK['friends'])]
6481 ,["Friends of Guests", capitaliseFirstLetter(CURRENTSTACK['friends'])+" of Guests"]
6482 ,["Only Me", "Alone"]
6483 ,["Only me", "Alone"]
6484 //,["See all lists...", "See entire directory..."]
6485 ];
6486
6487 dialogDerpTitles = [
6488 "Insufficient send permissions"
6489 ,"Update Failed"
6490 ,"Failed to upload photo."
6491 ,"Hide Photo Failed"
6492 ,"Undo Mark Spam Failed"
6493 ,"Your Request Couldn't be Processed"
6494 ,"Sorry! The blocking system is overloaded"
6495 ,"Invalid Request"
6496 ,"Block! You are engaging in behavior that may be considered annoying or abusive by other users."
6497 ,"Already connected."
6498 ,"Cannot connect."
6499 ,"Database Down"
6500 ,"Failure to hide minifeed story."
6501 ,"Object cannot be liked"
6502 ,"Sorry, something went wrong"
6503 ,"Authentication Failure"
6504 ,"Unknown error"
6505 ,"Not Logged In"
6506 ,"No Permission to Add Comment or Trying to Comment on Deleted Post"
6507 ,"Could not determine coordinates of place"
6508 ,"Sorry, your account is temporarily unavailable."
6509 ,"Don't Have Permission"
6510 ,"Oops"
6511 ,"No Languages Provided ForUpdate"
6512 ,"Comment Does Not Exist"
6513 ,"Sorry, we got confused"
6514 ,"Database Write Failed"
6515 ,"Editing Bookmarks Failed"
6516 ,"Required Field Missing"
6517 ,"Could Not Load Story"
6518 ,"Invalid Name"
6519 ,"Cannot connect to yourself."
6520 ,"This content is no longer available"
6521 ,"Error" // poking someone who hasn't poked back yet
6522 ,"Please Try Again Later"
6523 ,"Submitting Documentation Feedback Failed"
6524 ,"Bad Request"
6525 ,"Internal Error"
6526 ,"Mark as Spam Failed"
6527 ,"Could not post to Wall"
6528 ,"No permissions"
6529 ,"Messages Unavailable"
6530 ,"Don't have Permission"
6531 ,"No file specified."
6532 ,"Storage Failure"
6533 ,"Invalid Date"
6534 ,"Vote submission failed."
6535 ,"Web Address is Invalid"
6536 ,"Oops!"
6537 ,"Invalid Recipients"
6538 ,"Add Fan Status Failed"
6539 ,"Adding Member Failed"
6540 ,"Post Has Been Removed"
6541 ,"Unable to edit Group"
6542 ,"Invalid Photo Selected"
6543 ,"Cannot backdate photo"
6544 ,"Invalid Search Query"
6545 ,"Unable to Add Friend"
6546 ,"Cannot Add Member"
6547 ,"Bad Image"
6548 ,"Missing Field"
6549 ,"Invalid Custom Privacy Setting"
6550 ,"Empty Friend List"
6551 ,"Unable to Add Attachment"
6552 ,"Unable to Change Date"
6553 ,"Invalid Whining"
6554 ,"Your Page Can't Be Promoted"
6555 ,"Cannot Send Gift"
6556 ,"An error occurred."
6557 ];
6558
6559 headerInsightsTitles = [
6560 ["People Who Like Your Page (Demographics and Location)", capitaliseFirstLetter(CURRENTSTACK.people)+" Who "+capitaliseFirstLetter(CURRENTSTACK.like)+" Your Page (Demographics and Location)"]
6561 ,["Where Your Likes Came From", "Where Your "+capitaliseFirstLetter(CURRENTSTACK.likes)+" Came From"]
6562 ,["How You Reached People (Reach and Frequency)", "How You Reached "+capitaliseFirstLetter(CURRENTSTACK.people)+" (Reach and Frequency)"]
6563 ,["How People Are Talking About Your Page", "How "+capitaliseFirstLetter(CURRENTSTACK.people)+" Are Talking About Your Page"]
6564 ];
6565
6566 dialogDescriptionTitles = [
6567 ["Are you sure you want to delete this?", "Are you sure you want to nuke this?"]
6568 ,["Are you sure you want to delete this video?", "Are you sure you want to nuke this video?"]
6569 ,["Are you sure you want to delete this photo?", "Are you sure you want to nuke this pony pic?"]
6570 ,["Are you sure you want to delete this comment?", "Are you sure you want to nuke this friendship letter?"]
6571 ,["Are you sure you want to delete this event?", "Are you sure you want to nuke this adventure?"]
6572 ,["Are you sure you want to delete this post?", "Are you sure you want to nuke this post?"]
6573 ,["Are you sure you want to remove this picture?", "Are you sure you want to nuke this pony pic?"]
6574 ,["The post or object that you were commenting has been removed by its owner and can no longer be commented on.", "The post or object that you were commenting has been nuked by its owner and can no longer be commented on."]
6575 ,["Are you sure you want to remove this event?", "Are you sure you want to nuke this adventure?"]
6576
6577 ,["Report this if it's not relevant to your search results.", "Whine about this if it's not relevant to your search results."]
6578 ];
6579 }
6580
6581 var DOMNodeInserted = function(dom) {
6582 domNodeHandlerMain.run(dom);
6583 };
6584
6585 var domNodeHandler = function() {
6586 var k = this;
6587 k.snowliftPinkieInjected = false;
6588 //k.ufiData = {};
6589
6590 k.run = function(dom) {
6591 if (INTERNALUPDATE) {
6592 return;
6593 }
6594
6595 if (k.shouldIgnore(dom)) {
6596 return;
6597 }
6598
6599 k.dumpConsole(dom);
6600
6601 // Start internal update
6602 var iu = INTERNALUPDATE;
6603 INTERNALUPDATE = true;
6604
6605 // Buttons
6606 if (dom.target.parentNode && dom.target.parentNode.parentNode) {
6607 var stop = true;
6608 var replacer = buttonTitles;
6609 if (hasClass(dom.target.parentNode, 'uiButtonText')) {
6610 var buttonText = dom.target.parentNode;
6611 var button = dom.target.parentNode.parentNode;
6612 stop = false;
6613
6614 if (button.parentNode && button.parentNode.parentNode && hasClass(button.parentNode.parentNode, 'audienceSelector')) {
6615 replacer = menuPrivacyOnlyTitles;
6616 }
6617 } else if (hasClass(dom.target.parentNode, '_42ft') || hasClass(dom.target.parentNode, '-cx-PRIVATE-abstractButton__root')) {
6618 // dropdown on close friends list dialog
6619 // <a class="-cx-PRIVATE-abstractButton__root -cx-PRIVATE-uiButton__root -cx-PRIVATE-uiPopoverButton__root autofocus -cx-PRIVATE-uiPopover__trigger" role="button" href="#" style="max-width: 200px;" aria-haspopup="true" aria-expanded="true" rel="toggle" id="u_i_b" aria-owns="u_i_9">On This List<i class="mls img sp_8noqk7 sx_706bf4"></i></a>
6620 var buttonText = dom.target;
6621 var button = dom.target.parentNode;
6622 stop = false;
6623 } else if (hasClass(dom.target.parentNode.parentNode, '_42ft') || hasClass(dom.target.parentNode.parentNode, '-cx-PRIVATE-abstractButton__root')) {
6624 // hasClass(buttonText, '_55pe') || hasClass(buttonText, '-cx-PUBLIC-abstractPopoverButton__label')
6625 // "share to" dropdown on sharer dialog
6626 // comment resort on entstream
6627 var buttonText = dom.target;
6628 var button = dom.target.parentNode.parentNode;
6629 stop = false;
6630 }
6631
6632 if (!stop) {
6633 if (buttonText.nodeType == 3) {
6634 var orig = buttonText.textContent;
6635 } else {
6636 var orig = buttonText.innerHTML;
6637 }
6638 var replaced = replaceText(replacer, orig);
6639 if (hasClass(button, 'uiButton') || hasClass(button, '_42ft') || hasClass(button, '-cx-PRIVATE-abstractButton__root')) {
6640 // button text that didn't get ponified needs to be considered, e.g. share dialog's "On your Page"
6641 if (button.getAttribute('data-hover') != 'tooltip') {
6642 if (orig != replaced) {
6643 // ponified text
6644 if (button.title == '') {
6645 // tooltip is blank, so it would be OK to set our own
6646 button.title = orig;
6647 } else {
6648 // tooltip is NOT blank, this means (1) FB added their own tooltip or (2) we already added our own tooltip
6649 if (button.title == button.getAttribute('data-ponyhoof-button-orig')) {
6650 button.title = orig;
6651 }
6652 }
6653 } else {
6654 button.title = '';
6655 }
6656 }
6657 button.setAttribute('data-ponyhoof-button-orig', orig);
6658 button.setAttribute('data-ponyhoof-button-text', replaced);
6659 }
6660 if (orig != replaced) {
6661 if (buttonText.nodeType == 3) {
6662 buttonText.textContent = replaced;
6663 } else {
6664 buttonText.innerHTML = replaced;
6665 }
6666 }
6667 }
6668 }
6669
6670 // Text nodes
6671 if (dom.target.nodeType == 3) {
6672 //k.textNodes(dom);
6673 // firefox in mutationObserver goes to here when it should be characterData
6674 k.mutateCharacterData(dom);
6675 INTERNALUPDATE = iu;
6676 return;
6677 }
6678
6679 injectOptionsLink();
6680
6681 k.snowliftPinkie(dom);
6682 k.notificationsFlyoutSettings(dom);
6683
6684 // .ufb-button-input => mutateAttributes
6685 domReplaceFunc(dom.target, '', '.uiButtonText, .uiButton input, ._42ft, .-cx-PRIVATE-abstractButton__root, ._42fu, .-cx-PRIVATE-uiButton__root, ._4jy0, .-cx-PRIVATE-xuiButton__root', function(ele) {
6686 // <a class="uiButton uiButtonConfirm uiButtonLarge" href="#" role="button"><span class="uiButtonText">Finish</span></a>
6687 // <label class="uiButton uiButtonConfirm"><input value="Okay" type="submit"></label>
6688
6689 // <button class="_42ft _42fu _11b selected _42g-" type="submit">Post</button>
6690 // <a class="_42ft _42fu" role="button" href="#"><i class="mrs img sp_8jfoef sx_d2d7c4"></i>Promote App</a>
6691 var button = ele;
6692 var replacer = buttonTitles;
6693 var tagName = ele.tagName.toUpperCase();
6694 if (tagName != 'A' && tagName != 'LABEL' && tagName != 'BUTTON') {
6695 button = ele.parentNode;
6696
6697 // new message
6698 var potentialLabel = button.querySelector('._6q-, .-cx-PUBLIC-mercuryComposer__button');
6699 if (potentialLabel) {
6700 ele = potentialLabel;
6701 }
6702 } else {
6703 var potentialLabel = button.querySelector('._55pe, .-cx-PUBLIC-abstractPopoverButton__label');
6704 if (potentialLabel) {
6705 ele = potentialLabel;
6706 } else {
6707 // Get More Likes button on page admin panel
6708 // <button value="1" class="_42ft _42fu selected _42g- _42gy" id="fanAcquisitionPanelPreviewBodyConfirmButton" type="submit"><span id="u_x_a">Get More Likes</span></button>
6709 }
6710 // Get More Likes (above)
6711 // comment resort on entstream
6712 if (ele.childNodes && ele.childNodes.length == 1 && ele.childNodes[0].tagName && ele.childNodes[0].tagName.toUpperCase() == 'SPAN') {
6713 ele = ele.childNodes[0];
6714 }
6715 }
6716 if (button &&
6717 (button.getAttribute('data-ponyhoof-button-orig') == null || (hasClass(button, '_for') || hasClass(button, '-cx-PRIVATE-fbVaultBadgedButton__button'))) && // vault buttons are crapped
6718 (hasClass(button, 'uiButton') || hasClass(button, '_42ft') || hasClass(button, '-cx-PRIVATE-abstractButton__root') /*|| hasClass(button, '_42fu') || hasClass(button, '-cx-PRIVATE-uiButton__root') || hasClass(button, '_4jy0') || hasClass(button, '-cx-PRIVATE-xuiButton__root')*/)
6719 ) {
6720 if (button.parentNode && button.parentNode.parentNode && hasClass(button.parentNode.parentNode, 'audienceSelector')) {
6721 replacer = menuPrivacyOnlyTitles;
6722 }
6723
6724 if (tagName == 'INPUT') {
6725 var orig = ele.value;
6726 button.setAttribute('data-ponyhoof-button-orig', orig);
6727 var replaced = replaceText(replacer, orig);
6728
6729 k.changeButtonText(ele, replaced);
6730 } else {
6731 var orig = '';
6732 var replaced = '';
6733 loopChildText(ele, function(child) {
6734 if (child.nodeType == 3) {
6735 orig += child.textContent;
6736 replaced += replaceText(replacer, child.textContent);
6737 if (child.textContent != replaced) {
6738 child.textContent = replaced;
6739 }
6740 }
6741 });
6742 button.setAttribute('data-ponyhoof-button-orig', orig);
6743 }
6744
6745 if (orig != replaced) {
6746 if (button.getAttribute('data-hover') != 'tooltip') {
6747 if (button.title == '') {
6748 button.title = orig;
6749 }
6750 }
6751 }
6752 button.setAttribute('data-ponyhoof-button-text', replaced);
6753 }
6754
6755 });
6756
6757 k.ufiPagerLink(dom);
6758
6759 if (k.reactRoot(dom)) {
6760 INTERNALUPDATE = iu;
6761 return;
6762 }
6763
6764 k.postLike(dom);
6765
6766 if (k.ticker(dom)) {
6767 INTERNALUPDATE = iu;
6768 return;
6769 }
6770
6771 domReplaceFunc(dom.target, '', '.inCommonSectionList, #fbTimelineHeadline .name h2 > div, ._8yb, .-cx-PRIVATE-fbEntstreamAttachmentAvatar__secondarydetaillist, ._508a, .-cx-PRIVATE-pageLikeStory__fancountfooter, .permalinkHeaderInfo > .subscribeOrLikeSentence > .fwn', k.textBrohoof);
6772
6773 domReplaceFunc(dom.target, '', '.uiUfiViewAll, .uiUfiViewPrevious, .uiUfiViewMore', function(ele) {
6774 var button = ele.querySelector('input[type="submit"]');
6775 var t = button.value;
6776 t = t.replace(/comments/g, "friendship letters");
6777 t = t.replace(/comment/g, "friendship letter");
6778 if (button.value != t) {
6779 button.value = t;
6780 }
6781 });
6782
6783 domReplaceFunc(dom.target, '', '.tooltipContent', function(ele) {
6784 // <div class="tooltipContent"><div class="tooltipText"><span>xy</span></div></div>
6785 // <div class="tooltipContent">xy</div>
6786
6787 // <div class="tooltipContent"><div>Edit or Delete</div></div>
6788 var io = ele.getElementsByClassName('tooltipText');
6789 if (io.length) {
6790 var target = io[0];
6791 } else {
6792 var target = ele;
6793 }
6794 var potentialLabel = target.querySelector('._5bqd, .-cx-PRIVATE-HubbleInfoTip__content');
6795 if (potentialLabel) {
6796 target = potentialLabel;
6797 }
6798 io = target.getElementsByTagName('div');
6799 if (io.length) {
6800 target = io[0];
6801 }
6802 io = target.getElementsByTagName('span');
6803 if (io.length) {
6804 target = io[0];
6805 }
6806
6807 var t = target.innerHTML;
6808 t = replaceText(tooltipTitles, t);
6809 if (target.innerHTML != t) {
6810 var oldWidth = target.offsetWidth;
6811 target.innerHTML = t;
6812
6813 // <div class="uiContextualLayerPositioner uiLayer" id="js_4" style="width: 862px; left: 309px; top: 1914px;" data-ownerid=""><div class="uiContextualLayer uiContextualLayerAboveCenter" style="bottom: 0px;"><div class="uiTooltipX"><div class="tooltipContent"><div>Loading...</div></div><i class="arrow"></i></div></div></div>
6814 if (!ele.parentNode || !ele.parentNode.parentNode || !ele.parentNode.parentNode.parentNode) {
6815 return;
6816 }
6817 var layer = ele.parentNode.parentNode.parentNode;
6818 if (!ele.parentNode.parentNode.className.match(/Center/) || !hasClass(layer, 'uiContextualLayerPositioner')) {
6819 return;
6820 }
6821 layer.style.width = 'auto'; // fix horizontal scrollbar
6822 var left = parseInt(layer.style.left);
6823 var newWidth = target.offsetWidth;
6824 layer.style.left = (left - Math.round((newWidth - oldWidth) / 2))+'px';
6825 }
6826 });
6827
6828 domReplaceFunc(dom.target, 'egoProfileTemplate', '.egoProfileTemplate', function(ele) {
6829 if (ele.getAttribute('data-ponyhoof-ponified')) {
6830 return;
6831 }
6832 var div = ele.getElementsByTagName('div');
6833 if (div.length) {
6834 for (var i = 0, len = div.length; i < len; i += 1) {
6835 var t = div[i].innerHTML;
6836 t = k.textStandard(t);
6837 if (div[i].innerHTML != t) {
6838 div[i].innerHTML = t;
6839 }
6840 }
6841 }
6842
6843 var action = ele.getElementsByClassName('uiIconText');
6844 if (action.length) {
6845 action = action[0];
6846 ele.setAttribute('data-ponyhoof-iconText', action.textContent);
6847
6848 var t = action.innerHTML;
6849 t = t.replace(/Like/g, capitaliseFirstLetter(CURRENTSTACK.like));
6850 t = t.replace(/Join Group/g, "Join the Herd");
6851 t = t.replace(/Add Friend/g, "Add "+capitaliseFirstLetter(CURRENTSTACK.friend));
6852 t = t.replace(/\bConfirm Friend\b/g, "Confirm Friendship");
6853 action.innerHTML = t;
6854 }
6855
6856 ele.setAttribute('data-ponyhoof-ponified', 1);
6857 });
6858
6859 domReplaceFunc(dom.target, 'uiInterstitial', '.uiInterstitial', function(ele) {
6860 if (ele.getAttribute('data-ponyhoof-ponified')) {
6861 return;
6862 }
6863 ele.setAttribute('data-ponyhoof-ponified', 1);
6864
6865 var title = ele.getElementsByClassName('uiHeaderTitle');
6866 if (title.length) {
6867 title = title[0];
6868 } else {
6869 title = ele.querySelector('.fsxl.fwb');
6870 if (!title) {
6871 return;
6872 }
6873 }
6874 ele.setAttribute('data-ponyhoof-inters-title', title.textContent);
6875 });
6876
6877 domReplaceFunc(dom.target, 'uiLayer', '.uiLayer', function(ele) {
6878 if (ele.getAttribute('data-ponyhoof-dialog-title')) {
6879 return;
6880 }
6881
6882 var titlebar = ele.querySelector('.-cx-PUBLIC-uiDialog__title, ._t ._1yw, ._4-i0, .-cx-PRIVATE-xuiDialog__title, .overlayTitle, .fbCalendarOverlayHeader');
6883 if (titlebar) {
6884 var titletext = ele.querySelector('._52c9, .-cx-PRIVATE-xuiDialog__titletext');
6885 if (!titletext) {
6886 titletext = titlebar;
6887 }
6888
6889 var orig = '';
6890 var replaced = '';
6891 loopChildText(titletext, function(child) {
6892 if (child.nodeType == 3) {
6893 orig += child.textContent;
6894 replaced += replaceText(dialogTitles, child.textContent);
6895 if (child.textContent != replaced) {
6896 child.textContent = replaced;
6897 }
6898 }
6899 });
6900 addClass(titlebar, 'ponyhoof_fbdialog_title');
6901 if (orig != replaced) {
6902 titlebar.title = orig;
6903 }
6904
6905 addClass(ele, 'ponyhoof_fbdialog');
6906 ele.setAttribute('data-ponyhoof-dialog-title', replaced);
6907 ele.setAttribute('data-ponyhoof-dialog-orig', orig);
6908
6909 var body = ele.querySelector('._t ._13, .-cx-PRIVATE-uiDialog__body, ._4-i2, .-cx-PRIVATE-xuiDialog__body, .uiLayerPageContent > .pvm');
6910 if (body) {
6911 addClass(body, 'ponyhoof_fbdialog_body');
6912
6913 var stop = false;
6914 loopChildText(body, function(child) {
6915 if (stop) {
6916 return;
6917 }
6918 if (child.nodeType == TEXT_NODE) {
6919 var replaced = replaceText(dialogDescriptionTitles, child.textContent);
6920 if (child.textContent != replaced) {
6921 child.textContent = replaced;
6922 stop = true;
6923 }
6924 }
6925 });
6926 }
6927
6928 if (hasClass(dom.target, 'uiLayer')) {
6929 // dom.target is intentional
6930 // Detect rare cases when HTML detection just got turned on, and there is a dialog at the back
6931 k._dialog_playSound(replaced, ele);
6932 }
6933 }
6934
6935 domChangeTextbox(ele, '.groupsMemberFlyoutWelcomeTextarea', function(textbox) {
6936 var orig = textbox.getAttribute('placeholder');
6937 var t = orig.replace(/\bgroup\b/, 'herd');
6938 if (t != orig) {
6939 return t;
6940 }
6941 return "Welcome him/her to the herd...";
6942 });
6943 domChangeTextbox(ele, '.fbEventMemberComment', function(textbox) {
6944 var orig = textbox.getAttribute('placeholder');
6945 var t = orig.replace(/\bevent\b/, 'adventure');
6946 if (t != orig) {
6947 return t;
6948 }
6949 return orig; // for pages "Write something to let her know you're going too."
6950 });
6951
6952 // Hovercard
6953 $$(ele, '._7lo > .fcg, .-cx-PRIVATE-hovercard__footer > .fcg', function(footer) {
6954 loopChildText(footer, k.textBrohoof);
6955 });
6956 });
6957
6958 domReplaceFunc(dom.target, '', 'a[href^="/ajax/sharer/"][rel="dialog"], a[ajaxify^="/ajax/sharer/"], a[href^="/ajax/sharer?"][rel="dialog"], a[href^="/ajax/photos/album/share_dialog.php"], a[ajaxify^="/ajax/video/actions/share/dialog/"]', function(ele) {
6959 if (CURRENTSTACK.stack == 'pony') {
6960 ele.setAttribute('data-hover', 'tooltip');
6961 ele.setAttribute('aria-label', CURRENTLANG.fb_share_tooltip);
6962 ele.setAttribute('title', '');
6963 }
6964 });
6965
6966 domReplaceFunc(dom.target, '', '.uiHeaderTitle, .legacyContextualDialogTitle, ._6dp, .-cx-PRIVATE-litestandRHC__titlename', function(ele) {
6967 var imgwrap = ele.querySelector('._8m, .-cx-PRIVATE-uiImageBlock__content, .adsCategoryTitleLink');
6968 if (imgwrap) {
6969 ele = imgwrap;
6970 };
6971
6972 loopChildText(ele, function(child) {
6973 if (!child.children || !child.children.length) {
6974 var t = replaceText(headerTitles, child.textContent);
6975 if (child.textContent != t) {
6976 child.textContent = t;
6977 }
6978 }
6979 });
6980 });
6981
6982 domReplaceFunc(dom.target, '', '.insights-header .header-title > .ufb-text-content', function(ele) {
6983 var t = replaceText(headerInsightsTitles, ele.textContent);
6984 if (ele.textContent != t) {
6985 ele.textContent = t;
6986 }
6987 });
6988
6989 if (k.fbDockChatBuddylistNub(dom.target)) {
6990 INTERNALUPDATE = iu;
6991 return;
6992 }
6993
6994 if (k.pokesDashboard(dom.target)) {
6995 INTERNALUPDATE = iu;
6996 return;
6997 }
6998
6999 k.commentBrohoofed(dom);
7000
7001 k.changeCommentBox(dom);
7002 k.changeComposer(dom);
7003
7004 k.notification(dom);
7005 k.menuItems(dom);
7006 k.fbRemindersStory(dom.target);
7007 if (k.flyoutLikeForm(dom.target)) {
7008 INTERNALUPDATE = iu;
7009 return;
7010 }
7011 k.pluginButton(dom.target);
7012 k.insightsCountry(dom);
7013 k.timelineMutualLikes(dom.target);
7014 k.videoStageContainer(dom.target);
7015
7016 domChangeTextbox(dom.target, '.MessagingComposerForm textarea, ._1rt ._1rv, .-cx-PRIVATE-webMessengerComposer__composertextarea, ._20y textarea, .-cx-PRIVATE-mercuryComposerDialog__root textarea, ._2oj, .-cx-PRIVATE-mercuryComposerDialog__textarea', "Dear Princess Celestia...");
7017 domChangeTextbox(dom.target, '.groupAddMemberTypeaheadBox .inputtext', "Add "+capitaliseFirstLetter(CURRENTSTACK.friends)+" to the Herd");
7018 //domChangeTextbox(dom.target, '.friendListAddTypeahead .inputtext', "Add "+CURRENTSTACK.friends+" to this directory");
7019 domChangeTextbox(dom.target, '.friendListAddTypeahead .inputtext', "Add "+CURRENTSTACK.friends+" to this list");
7020 domChangeTextbox(dom.target, '.groupsJumpHeaderSearch .inputtext', "Search this herd");
7021 domChangeTextbox(dom.target, '.MessagingSearchFilter .inputtext', "Search Friendship Reports");
7022 domChangeTextbox(dom.target, '#chatFriendsOnline .fbChatTypeahead .inputtext', "Pals on Whinny Chat");
7023
7024 //domChangeTextbox(dom.target, '.uiComposer textarea', "What lessons in friendship have you learned today?");
7025 //domChangeTextbox(dom.target, '.uiComposerMessageBox textarea', "Share your friendship stories...");
7026 //domChangeTextbox(dom.target, '.uiMetaComposerMessageBox textarea', "What lessons in friendship have you learned today?");
7027 domChangeTextbox(dom.target, '#q, .fbFacebar .facebarInput .structuredText, ._585- ._586f, .-cx-PUBLIC-fbFacebar__root .-cx-PUBLIC-uiStructuredInput__text', function(searchbox) {
7028 if (CURRENTLANG.sniff_fb_search_boxAlt && searchbox.getAttribute('placeholder').indexOf(CURRENTLANG.sniff_fb_search_boxAlt) != -1) {
7029 return CURRENTLANG.fb_search_boxAlt;
7030 }
7031 return CURRENTLANG.fb_search_box;
7032 });
7033
7034 k.ponyhoofPageOptions(dom);
7035 if (userSettings.debug_betaFacebookLinks && w.location.hostname == 'beta.facebook.com') {
7036 k.debug_betaFacebookLinks(dom.target);
7037 }
7038
7039 INTERNALUPDATE = iu;
7040 };
7041
7042 k.photos_snowlift = null;
7043 k.snowliftPinkie = function(dom) {
7044 if (!k.snowliftPinkieInjected) {
7045 var id = dom.target.getAttribute('id');
7046 if ((id && id == 'photos_snowlift') || hasClass(dom.target, 'fbPhotoSnowlift')) {
7047 k.snowliftPinkieInjected = true;
7048 k.photos_snowlift = dom.target;
7049
7050 addClass(k.photos_snowlift, 'ponyhoof_snowlift_haspinkiediv');
7051 var n = d.createElement('div');
7052 n.id = 'ponyhoof_snowlift_pinkie';
7053 k.photos_snowlift.appendChild(n);
7054 }
7055 }
7056 };
7057
7058 k.notificationsFlyoutSettingsInjected = false;
7059 k.notificationsFlyoutSettings = function(dom) {
7060 if (ISUSINGPAGE) {
7061 k.notificationsFlyoutSettingsInjected = true;
7062 return;
7063 }
7064 if (!k.notificationsFlyoutSettingsInjected) {
7065 var jewel = $('fbNotificationsJewel');
7066 if (jewel) {
7067 var header = jewel.getElementsByClassName('uiHeaderTop');
7068 if (!header.length || !header[0].childNodes || !header[0].childNodes.length) {
7069 return;
7070 }
7071 header = header[0];
7072
7073 var settingsLink = d.createElement('a');
7074 settingsLink.href = '#';
7075 settingsLink.textContent = 'Ponyhoof Sounds';
7076
7077 var actions = jewel.getElementsByClassName('uiHeaderActions');
7078 if (actions.length) {
7079 actions = actions[0];
7080 var span = d.createElement('span');
7081 span.innerHTML = ' &middot; ';
7082
7083 actions.appendChild(span);
7084 actions.appendChild(settingsLink);
7085 } else {
7086 var rfloat = d.createElement('div');
7087 rfloat.className = 'rfloat';
7088 rfloat.appendChild(settingsLink);
7089 header.insertBefore(rfloat, header.childNodes[0]);
7090 }
7091
7092 settingsLink.addEventListener('click', function(e) {
7093 e.preventDefault();
7094
7095 if (!optionsGlobal) {
7096 optionsGlobal = new Options();
7097 }
7098 optionsGlobal.create();
7099 optionsGlobal.switchTab('sounds');
7100 optionsGlobal.show();
7101
7102 try {
7103 clickLink(jewel.getElementsByClassName('jewelButton')[0]);
7104 } catch (e) {}
7105 }, false);
7106
7107 k.notificationsFlyoutSettingsInjected = true;
7108 }
7109 }
7110 };
7111
7112 k.textNodes = function(dom) {
7113 try {
7114 if (!dom.target.parentNode || !dom.target.parentNode.parentNode || !hasClass(dom.target.parentNode.parentNode, 'dialog_title')) {
7115 return false;
7116 }
7117
7118 var title = dom.target.parentNode.parentNode;
7119 var orig = dom.target.textContent;
7120 var replaced = replaceText(dialogTitles, orig);
7121
7122 if (dom.target.textContent != replaced) {
7123 dom.target.textContent = replaced;
7124 }
7125 addClass(title, 'ponyhoof_fbdialog_title');
7126 if (orig != replaced) {
7127 title.title = orig;
7128 }
7129
7130 k.getParent(title, function(ele) {
7131 return hasClass(ele, 'generic_dialog');
7132 }, function(ele) {
7133 if (hasClass(ele, 'fbQuestionsPopup')) {
7134 return;
7135 }
7136
7137 addClass(ele, 'ponyhoof_fbdialog');
7138 ele.setAttribute('data-ponyhoof-dialog-title', replaced);
7139 ele.setAttribute('data-ponyhoof-dialog-orig', orig);
7140
7141 var body = ele.getElementsByClassName('dialog_body');
7142 if (body.length) {
7143 body = body[0];
7144 addClass(body, 'ponyhoof_fbdialog_body');
7145
7146 var confirmation_message = body.getElementsByClassName('confirmation_message');
7147 if (confirmation_message.length) {
7148 confirmation_message = confirmation_message[0];
7149
7150 var stop = false;
7151 loopChildText(confirmation_message, function(child) {
7152 if (stop) {
7153 return;
7154 }
7155 if (child.nodeType == TEXT_NODE) {
7156 var replaced = replaceText(dialogDescriptionTitles, child.textContent);
7157 if (child.textContent != replaced) {
7158 child.textContent = replaced;
7159 stop = true;
7160 }
7161 }
7162 });
7163 } else {
7164 var video_dialog_text = body.getElementsByClassName('video_dialog_text');
7165 if (video_dialog_text.length) {
7166 video_dialog_text = video_dialog_text[0];
7167 if (video_dialog_text.childNodes.length == 3) {
7168 var i = 0;
7169 var texts = ["Nuking a video is permanent.", "Once you nuke a video, you will not be able to get it back.", "Are you sure you want to nuke this video?"];
7170 loopChildText(video_dialog_text, function(child) {
7171 if (!texts[i]) {
7172 return;
7173 }
7174 child.textContent = texts[i];
7175 i++;
7176 });
7177 }
7178 }
7179 }
7180 }
7181
7182 k._dialog_playSound(replaced, ele);
7183 });
7184
7185 return true;
7186 } catch (e) {}
7187
7188 return false;
7189 };
7190
7191 k.ufiPagerLink = function(dom) {
7192 domReplaceFunc(dom.target, '', '.UFIPagerLink', function(ele) {
7193 var t = ele.innerHTML;
7194 t = t.replace(/ comments/, " friendship letters");
7195 t = t.replace(/ comment/, " friendship letter");
7196 if (ele.innerHTML != t) {
7197 ele.innerHTML = t;
7198 }
7199 });
7200 };
7201
7202 k.postLike = function(dom) {
7203 if (hasClass(dom.target, 'uiUfiLike') || hasClass(dom.target, 'UFILikeSentence')) {
7204 k._likePostBox(dom.target);
7205 } else {
7206 /*if (dom.target.parentNode) {
7207 if (hasClass(dom.target.parentNode, 'UFILikeSentence')) {
7208 k._likePostBox(dom.target);
7209 return;
7210 }
7211 }*/
7212 domReplaceFunc(dom.target, '', '.uiUfiLike, .UFILikeSentence', k._likePostBox);
7213 }
7214 };
7215
7216 k._likePostBox = function(ele) {
7217 //var inner = ele.querySelector('._42ef, .-cx-PRIVATE-uiFlexibleBlock__flexiblecontent, .lfloat > span, .-cx-PRIVATE-uiImageBlockDeprecated__content, .-cx-PRIVATE-uiImageBlock__content, ._8m, .-cx-PRIVATE-uiFlexibleBlock__flexibleContent');
7218 //if (inner) {
7219
7220 var inner = ele.getElementsByClassName('UFILikeSentenceText');
7221 if (inner.length) {
7222 inner = inner[0];
7223 var t = k.likeSentence(inner.innerHTML);
7224 if (inner.innerHTML != t) {
7225 inner.innerHTML = t;
7226 }
7227 }
7228
7229 var reorder = ele.getElementsByClassName('UFIOrderingModeSelectorDownCaret');
7230 if (reorder.length) {
7231 reorder = reorder[0];
7232 if (reorder.previousSibling) {
7233 k.UFIOrderingMode(reorder.previousSibling);
7234 }
7235 }
7236 };
7237
7238 k.likeSentence = function(t) {
7239 //t = t.replace(/likes? this\./g, "brohoof'd this.");
7240 t = t.replace(/like this\./g, CURRENTSTACK['like_past']+" this.");
7241 t = t.replace(/likes this\./g, CURRENTSTACK['likes_past']+" this.");
7242 t = t.replace(/\bpeople\b/g, CURRENTSTACK['people']);
7243 t = t.replace(/\bperson\b/g, CURRENTSTACK['person']); // http://fb.com/647294431950845
7244 //t = t.replace(/(^|\\W|_)people(^|\\W|_)/g, "ponies");
7245 /*if (CURRENTSTACK == 'pony') {
7246 t = t.replace(/\<3 7h\!5/g, '/) 7h!5');
7247 t = t.replace(/\<3 7h15/g, '/) 7h!5');
7248 }*/
7249
7250 return t;
7251 };
7252
7253 k._likeCount = function(ufiitem) {
7254 var likecount = ufiitem.getElementsByClassName('comment_like_button');
7255 if (likecount.length) {
7256 likecount = likecount[0];
7257 var t = likecount.innerHTML;
7258 //t = t.replace(/likes? this\./g, "brohoof'd this.");
7259 t = t.replace(/like this/g, CURRENTSTACK['like_past']+" this");
7260 t = t.replace(/likes this/g, CURRENTSTACK['likes_past']+" this");
7261 if (likecount.innerHTML != t) {
7262 likecount.innerHTML = t;
7263 }
7264 }
7265 };
7266
7267 k.UFIOrderingMode = function(ele) {
7268 var t = ele.textContent;
7269 t = t.replace(/Top Comments/, "Top Friendship Letters");
7270 if (ele.textContent != t) {
7271 ele.textContent = t;
7272 }
7273 };
7274
7275 k._likeDesc = '';
7276 k._unlikeDesc = '';
7277 k._likeConditions = '';
7278 k._likeIsLikeConditions = '';
7279 k.FB_TN_LIKELINK = '>';
7280 k.FB_TN_UNLIKELINK = '?';
7281 k.commentBrohoofed = function(dom) {
7282 var targets = '.UFICommentActions a, .UFILikeLink';
7283 if (!USINGMUTATION) {
7284 targets += ', .UFILikeThumb';
7285 }
7286 domReplaceFunc(dom.target, '', targets, k._commentLikeLink);
7287 };
7288
7289 k.commentLikeDescInit = function() {
7290 if (k._likeDesc == '') {
7291 var locale = getDefaultUiLang();
7292 if (LANG[locale] && LANG[locale].sniff_comment_tooltip_like) {
7293 k._likeDesc = LANG[locale].sniff_comment_tooltip_like;
7294 } else {
7295 k._likeDesc = LANG['en_US'].sniff_comment_tooltip_like;
7296 }
7297 if (LANG[locale] && LANG[locale].sniff_comment_tooltip_unlike) {
7298 k._unlikeDesc = LANG[locale].sniff_comment_tooltip_unlike;
7299 } else {
7300 k._unlikeDesc = LANG['en_US'].sniff_comment_tooltip_unlike;
7301 }
7302
7303 k._likeConditions = [
7304 k._likeDesc, k._unlikeDesc,
7305 capitaliseFirstLetter(CURRENTSTACK.like)+" this friendship letter", capitaliseFirstLetter(CURRENTSTACK.unlike)+" this friendship letter"
7306 ];
7307 k._likeIsLikeConditions = [
7308 k._likeDesc,
7309 capitaliseFirstLetter(CURRENTSTACK.like)+" this friendship letter"
7310 ];
7311 }
7312 };
7313
7314 k._commentLikeLink = function(ele) {
7315 k.commentLikeDescInit();
7316
7317 var pass = false;
7318 var likeThumb = false;
7319 if (k._likeConditions.indexOf(ele.title) == -1) {
7320 // extreme sniffing
7321 var trackingNode = k.getTrackingNode(ele);
7322 if (trackingNode == k.FB_TN_LIKELINK || trackingNode == k.FB_TN_UNLIKELINK) {
7323 pass = true;
7324 } else if (!USINGMUTATION && hasClass(ele, 'UFILikeThumb')) {
7325 likeThumb = true;
7326 pass = true;
7327 }
7328 } else {
7329 pass = true;
7330 }
7331 if (!pass) {
7332 return;
7333 }
7334
7335 if (!hasClass(ele, 'ponyhoof_brohoof_button')) {
7336 if (!USINGMUTATION) {
7337 ele.addEventListener('click', function() {
7338 var ele = this;
7339 k.delayIU(function() {
7340 if (likeThumb) {
7341 // UFILikeThumb disappears after a post is brohoof'd
7342 k._likeBrohoofMagic(ele, false);
7343 } else {
7344 k._commentLikeLink(ele);
7345 }
7346 });
7347 }, false);
7348 }
7349 addClass(ele, 'ponyhoof_brohoof_button');
7350 }
7351
7352 var isLike = false;
7353 if (k.getTrackingNode(ele) == k.FB_TN_LIKELINK || likeThumb || k._likeIsLikeConditions.indexOf(ele.title) != -1) {
7354 isLike = true;
7355 }
7356
7357 k._likeBrohoofMagic(ele, isLike);
7358 };
7359
7360 k._likeBrohoofMagic = function(ele, isLike) {
7361 var comment = k.getReactComment(ele);
7362 var title = '';
7363 if (isLike) {
7364 removeClass(ele, 'ponyhoof_brohoof_button_unbrohoof');
7365 title = capitaliseFirstLetter(CURRENTSTACK.like)+" this";
7366 } else {
7367 addClass(ele, 'ponyhoof_brohoof_button_unbrohoof');
7368 title = capitaliseFirstLetter(CURRENTSTACK.unlike)+" this";
7369 }
7370 if (comment) {
7371 title += " friendship letter";
7372 }
7373 ele.setAttribute('data-ponyhoof-title', ele.title);
7374 ele.title = title;
7375 ele.setAttribute('data-ponyhoof-title-modified', title);
7376
7377 if (comment) {
7378 k._markCommentLiked(comment, isLike);
7379
7380 // Fix an edge case with jump to comment
7381 if (hasClass(comment, 'highlightComment')) {
7382 w.setTimeout(function() {
7383 k._markCommentLiked(comment, isLike);
7384 }, 1);
7385 }
7386 } else {
7387 k.delayIU(function() {
7388 if (!ele.parentNode) {
7389 var ufi = k.getReactUfi(ele);
7390 if (!ufi) {
7391 return;
7392 }
7393 ele = ufi;
7394 }
7395
7396 k.getParent(ele, function(form) {
7397 return (form.tagName.toUpperCase() == 'FORM' && hasClass(form, 'commentable_item'));
7398 }, function(form) {
7399 if (!form) {
7400 return;
7401 }
7402 var ufi = form.getElementsByClassName('UFIList');
7403 if (!ufi.length) {
7404 return;
7405 }
7406 ufi = ufi[0];
7407 if (!ufi.parentNode) {
7408 return;
7409 }
7410
7411 /*var id = k.getReactId(ufi);
7412 if (!id) {
7413 return;
7414 }
7415 if (!k.ufiData[id]) {
7416 k.ufiData[id] = {};
7417 }*/
7418
7419 if (isLike) {
7420 //k.ufiData[id].brohoofed = false;
7421 removeClass(ufi.parentNode, 'ponyhoof_brohoofed');
7422 } else {
7423 //k.ufiData[id].brohoofed = true;
7424 addClass(ufi.parentNode, 'ponyhoof_brohoofed');
7425 }
7426 });
7427 });
7428 }
7429 };
7430
7431 k._markCommentLiked = function(ufiitem, isLike) {
7432 var child = null;
7433 if (ufiitem.childNodes && ufiitem.childNodes[0]) {
7434 child = ufiitem.childNodes[0];
7435 }
7436 if (isLike) {
7437 removeClass(ufiitem, 'ponyhoof_comment_liked');
7438 if (child) {
7439 removeClass(child, 'ponyhoof_comment_liked');
7440 }
7441 } else {
7442 addClass(ufiitem, 'ponyhoof_comment_liked');
7443 if (child) {
7444 addClass(child, 'ponyhoof_comment_liked');
7445 }
7446 }
7447 };
7448
7449 k.REACTROOTID = '.r['; // https://github.com/facebook/react/commit/8bc2abd367232eca66e4d38ff63b335c8cf23c45
7450 k.REACTATTRNAME = 'data-reactid'; // https://github.com/facebook/react/commit/67cf44e7c18e068e3f39462b7ac7149eee58d3e5
7451 k.getReactId = function(ufiitem) {
7452 var id = ufiitem.getAttribute(k.REACTATTRNAME);
7453 if (!id) {
7454 return false;
7455 }
7456 return id.substring(k.REACTROOTID.length, id.indexOf(']'));
7457 };
7458
7459 k.reactRoot = function(dom) {
7460 var id = dom.target.getAttribute(k.REACTATTRNAME);
7461 if (id || hasClass(dom.target, 'UFILikeIcon')) {
7462 // beeperNotificaton
7463 if (hasClass(dom.target, '_3sod') || hasClass(dom.target, '-cx-PRIVATE-notificationBeeperItem__beeperitem')) {
7464 var info = dom.target.querySelector('._3sol > span, .-cx-PRIVATE-notificationBeeperItem__imageblockcontent > span');
7465 if (!info) {
7466 return false;
7467 }
7468 k._beepNotification_change(dom.target, info, k._beepNotification_condition_react);
7469
7470 return true;
7471 }
7472
7473 // Notifications
7474 if (k._notification_react(dom.target)) {
7475 return true;
7476 }
7477 var notificationReact = false;
7478 domReplaceFunc(dom.target, '', '.'+k.notification_itemClass[0]+', .'+k.notification_itemClass[1], function(ele) {
7479 k._notification_react(ele);
7480 notificationReact = true;
7481 });
7482 if (notificationReact) {
7483 return true;
7484 }
7485
7486 // Comments
7487 if (hasClass(dom.target, 'UFIComment')) {
7488 k.commentBrohoofed({target: dom.target});
7489 } else if (hasClass(dom.target, 'UFIReplyList')) {
7490 k.changeCommentBox({target: dom.target});
7491 k.commentBrohoofed({target: dom.target}); // only 1 reply
7492 } else if (hasClass(dom.target, 'UFIAddComment')) {
7493 domChangeTextbox(dom.target, 'textarea', k._changeCommentBox_change);
7494 } else if (hasClass(dom.target, 'UFILikeSentence')) {
7495 k._likePostBox(dom.target);
7496 } else if (hasClass(dom.target, 'UFIImageBlockContent')) {
7497 if (hasClass(dom.target, '_42ef') || hasClass(dom.target, '-cx-PRIVATE-uiFlexibleBlock__flexiblecontent')) {
7498 // on groups with seen, clicking a photo will open in the viewer, but the original post on the group messes up
7499 k._likePostBox(dom.target.parentNode);
7500 } else {
7501 // marking a comment as spam in another section, and then unmark
7502 k.commentBrohoofed({target: dom.target});
7503 }
7504 } else if (hasClass(dom.target, 'UFILikeLink') || (!USINGMUTATION && hasClass(dom.target, 'UFILikeThumb'))) {
7505 k._commentLikeLink(dom.target);
7506 } else if (dom.target.parentNode) {
7507
7508 if (hasClass(dom.target.parentNode, 'UFIComment')) {
7509 // marking a comment as spam, and then immediately undo
7510 k.commentBrohoofed({target: dom.target.parentNode});
7511 } else if (hasClass(dom.target.parentNode, 'UFILikeSentence')) {
7512 // groups with seen, from no likes to liked
7513 k._likePostBox(dom.target.parentNode);
7514 } else if (dom.target.parentNode.parentNode) {
7515
7516 //if (hasClass(dom.target.parentNode.parentNode, 'UFIImageBlockContent') || hasClass(dom.target.parentNode.parentNode, 'lfloat')) {
7517 if (hasClass(dom.target.parentNode.parentNode, 'UFILikeSentenceText')) {
7518 // John Amebijeigeba Laverdetberg brohoof this.
7519 // You and John Amebijeigeba Laverdetberg like this.
7520 var ufi = k.getReactUfi(dom.target);
7521 if (ufi) {
7522 k.postLike({target: ufi});
7523 }
7524 } else if (dom.target.parentNode.parentNode.parentNode) {
7525
7526 //if (hasClass(dom.target.parentNode.parentNode.parentNode, 'UFIImageBlockContent')) {
7527 if (hasClass(dom.target.parentNode.parentNode.parentNode, 'UFILikeSentenceText')) {
7528 var ufi = k.getReactUfi(dom.target);
7529 if (ufi) {
7530 k.postLike({target: ufi});
7531 }
7532 }
7533 }
7534 }
7535 }
7536 return true;
7537 }
7538
7539 return false;
7540 };
7541
7542 k.changeCommentBox = function(dom) {
7543 domChangeTextbox(dom.target, '.commentArea textarea, .UFIAddComment textarea', k._changeCommentBox_change);
7544 };
7545 k._changeCommentBox_change = function(textbox) {
7546 try {
7547 var form = textbox;
7548 while (form) {
7549 if (form.tagName.toUpperCase() == 'FORM' && form.getAttribute('action') == '/ajax/ufi/modify.php') {
7550 break;
7551 }
7552 form = form.parentNode;
7553 }
7554 if (form) {
7555 var feedback_params = JSON.parse(form.querySelector('input[name="feedback_params"]').value);
7556 switch (feedback_params.assoc_obj_id) {
7557 case '140792002656140':
7558 case '346855322017980':
7559 return LANG['ms_MY'].fb_comment_box;
7560
7561 case '146225765511748':
7562 return CURRENTLANG.fb_composer_coolstory;
7563
7564 default:
7565 break;
7566 }
7567 switch (feedback_params.target_profile_id) {
7568 case '496282487062916':
7569 return CURRENTLANG.fb_composer_coolstory;
7570
7571 default:
7572 break;
7573 }
7574 }
7575 } catch (e) {}
7576
7577 return CURRENTLANG.fb_comment_box;
7578 };
7579
7580 k.composerPonies = new RegExp(['pony', 'ponies', 'mlp', 'brony', 'bronies', 'pegasister', 'pega sister', 'pega-sister', 'twilight sparkle', 'rainbow dash', 'pinkie', 'applejack', 'fluttershy', 'rarity', 'celestia', 'derpy', 'equestria', 'canterlot', 'dashie', 'apple jack', 'flutter shy', 'princess luna', 'friendship is magic', 'kuda'].join('|'), 'i');
7581 k.composerExclude = new RegExp(['suck', 'shit', 'fuck', 'assho', 'crap', 'ponyfag', 'faggo', 'retard', 'dick'].join('|'), 'i');
7582 k.composerSpecialPages = {
7583 '140792002656140': {composer: LANG['ms_MY'].fb_composer_lessons, malay:true}
7584 ,'346855322017980': {composer: LANG['ms_MY'].fb_composer_lessons, malay:true}
7585 ,'366748370110998': {composer: LANG['ms_MY'].fb_composer_lessons, malay:true}
7586 ,'146225765511748': {composer: CURRENTLANG.fb_composer_coolstory}
7587 ,'496282487062916': {composer: CURRENTLANG.fb_composer_coolstory}
7588 };
7589 k.composerSelectors = '.uiComposer textarea.mentionsTextarea, .composerTypeahead textarea';
7590 k.composerButtonSelectors = '.uiComposerMessageBoxControls .submitBtn input, .uiComposerMessageBoxControls .submitBtn .uiButtonText, ._11b input, .-cx-PRIVATE-fbComposerMessageBox__button input, button._11b, button.-cx-PRIVATE-fbComposerMessageBox__button';
7591 k.changeComposer = function(dom) {
7592 var pageid = '';
7593
7594 // tagging people with "Who are you with?" and new feelings feature
7595 if (hasClass(dom.target, 'uiMentionsInput')) {
7596 // fix group composers, ugh
7597 if (dom.target.parentNode && dom.target.parentNode.parentNode && dom.target.parentNode.parentNode.parentNode) {
7598 // .uiMentionsInput -> #id -> .-cx-PUBLIC-fbComposerMessageBox__root -> form -> .-cx-PUBLIC-fbComposer__content
7599 k._changeComposer_fixGroup(dom.target.parentNode.parentNode.parentNode);
7600 }
7601
7602 contentEval(function(arg) {
7603 try {
7604 if (typeof window.requireLazy == 'function') {
7605 window.requireLazy(['MentionsInput'], function(MentionsInput) {
7606 var mentions = MentionsInput.getInstance(document.getElementById(arg.uiMentionsInput));
7607 mentions.setPlaceholder(mentions._input.title);
7608 });
7609 }
7610 } catch (e) {
7611 if (arg.CANLOG && typeof console != 'undefined' && console.log && console.dir) {
7612 console.log("Unable to hook to MentionsInput");
7613 console.dir(e);
7614 }
7615 }
7616 }, {"CANLOG":CANLOG, "uiMentionsInput":dom.target.id});
7617 return;
7618 }
7619
7620 domChangeTextbox(dom.target, k.composerSelectors, function(composer) {
7621 var placeholderText = CURRENTLANG.fb_composer_lessons;
7622
7623 try {
7624 var form = composer;
7625 var inputContainer = null;
7626 while (form) {
7627 if (hasClass(form, 'uiComposer') || hasClass(form, '_119' /*'_118'*/) || hasClass(form, '-cx-PRIVATE-fbComposer__root')) {
7628 break;
7629 }
7630 if (hasClass(form, 'inputContainer')) {
7631 inputContainer = form;
7632 }
7633 form = form.parentNode;
7634 }
7635
7636 if (!form) {
7637 return placeholderText;
7638 }
7639
7640 pageid = form.querySelector('input[name="xhpc_targetid"]');
7641 if (!pageid) {
7642 pageid = '';
7643 return placeholderText;
7644 }
7645 pageid = pageid.value;
7646 form.setAttribute('data-ponyhoof-xhpc_targetid', pageid);
7647 if (k.composerSpecialPages[pageid] && k.composerSpecialPages[pageid].composer) {
7648 placeholderText = k.composerSpecialPages[pageid].composer;
7649 }
7650
7651 k._changeComposerAttachment(dom, pageid);
7652
7653 if (k.composerSpecialPages[pageid] && k.composerSpecialPages[pageid].malay) {
7654 $$(form, k.composerButtonSelectors, function(submit) {
7655 k.changeButtonText(submit, "Kirim");
7656 });
7657 }
7658
7659 composer.addEventListener('input', function() {
7660 var malay = false;
7661 var lang = CURRENTLANG;
7662 if (k.composerSpecialPages[pageid] && k.composerSpecialPages[pageid].malay) {
7663 malay = true;
7664 lang = LANG['ms_MY'];
7665 }
7666
7667 // we can't guarantee the button anymore, so we have to do this expensive JS :(
7668 // group composers are funky and teleport the textbox to a new <div> onclick
7669 $$(form, k.composerButtonSelectors, function(submit) {
7670 if (!k.composerExclude.test(composer.value) && k.composerPonies.test(composer.value)) {
7671 if (composer.value.toUpperCase() == composer.value) {
7672 k.changeButtonText(submit, lang.fb_composer_ponies_caps);
7673 } else {
7674 k.changeButtonText(submit, lang.fb_composer_ponies);
7675 }
7676 } else if (malay) {
7677 k.changeButtonText(submit, "Kirim");
7678 } else {
7679 var submitParent = submit;
7680 if (submit.tagName.toUpperCase() != 'BUTTON') {
7681 submitParent = submit.parentNode;
7682 }
7683 if (submitParent.getAttribute('data-ponyhoof-button-text')) {
7684 k.changeButtonText(submit, submitParent.getAttribute('data-ponyhoof-button-text'));
7685 }
7686 }
7687 });
7688 });
7689
7690 if (isPonyhoofPage(pageid)) {
7691 composer.addEventListener('focus', function() {
7692 if (inputContainer) {
7693 k._changeComposer_insertReadme(inputContainer.nextSibling);
7694 return;
7695 }
7696
7697 // pages have ComposerX and teleports the textbox here and there
7698 $$(form, '._2yg, .-cx-PUBLIC-fbComposerMessageBox__root', function(composer) {
7699 // exclude inactives
7700 if (!composer.parentNode || hasClass(composer.parentNode, 'hidden_elem')) {
7701 return;
7702 }
7703
7704 var temp = composer.getElementsByClassName('ponyhoof_page_readme');
7705 if (temp.length) {
7706 return;
7707 }
7708
7709 // status: before taggersPlaceholder
7710 // photos: after uploader
7711 // fallback: before bottom bar
7712 var insertBefore = composer.querySelector('._3-6, .-cx-PRIVATE-fbComposerBootloadStatus__taggersplaceholder');
7713 if (!insertBefore) {
7714 insertBefore = composer.querySelector('._93, .-cx-PRIVATE-fbComposerUploadMedia__root');
7715 if (insertBefore) {
7716 insertBefore = insertBefore.nextSibling;
7717 }
7718 }
7719 if (!insertBefore) {
7720 insertBefore = composer.querySelector('._1dsp, .-cx-PUBLIC-fbComposerMessageBox__bar');
7721 }
7722 // abort if no good insertion
7723 if (!insertBefore) {
7724 return;
7725 }
7726
7727 k._changeComposer_insertReadme(insertBefore);
7728 });
7729 }, true);
7730 return "Suggest something for Ponyhoof...";
7731 }
7732 if (k.composerSpecialPages[pageid] && k.composerSpecialPages[pageid].composer) {
7733 return k.composerSpecialPages[pageid].composer;
7734 }
7735 } catch (e) {}
7736
7737 return placeholderText;
7738 });
7739
7740 // moved outside for timelineStickyHeader
7741 if (!pageid) {
7742 k._changeComposerAttachment(dom, null);
7743 }
7744
7745 // fix group composers, ugh
7746 //k._changeComposer_fixGroup(dom.target);
7747 };
7748
7749 k._changeComposerAttachment = function(dom, pageid) {
7750 $$(dom.target, '._4_ li a, ._9lb, .-cx-PUBLIC-fbComposerAttachment__link, .uiComposerAttachment', function(attachment) {
7751 if (attachment.getAttribute('data-ponyhoof-ponified')) {
7752 return;
7753 }
7754
7755 var switchit = false;
7756 switch (attachment.getAttribute('data-endpoint')) {
7757 case '/ajax/composerx/attachment/status/':
7758 case '/ajax/composerx/attachment/group/post/':
7759 case '/ajax/composerx/attachment/wallpost/':
7760 case '/ajax/metacomposer/attachment/timeline/status.php':
7761 case '/ajax/metacomposer/attachment/timeline/backdated_status.php':
7762 case '/ajax/metacomposer/attachment/timeline/wallpost.php':
7763 switchit = "Take a Note";
7764 if (k.composerSpecialPages[pageid] && k.composerSpecialPages[pageid].malay) {
7765 switchit = "Tulis Kiriman";
7766 }
7767 break;
7768
7769 case '/ajax/composerx/attachment/media/chooser/':
7770 case '/ajax/composerx/attachment/media/chooser':
7771 case '/ajax/composerx/attachment/media/upload/':
7772 case '/ajax/metacomposer/attachment/timeline/photo/photo.php':
7773 case '/ajax/metacomposer/attachment/timeline/photo/backdated_upload.php':
7774 case '/ajax/metacomposer/attachment/timeline/backdated_vault.php?max_select=1':
7775 switchit = "Add a Pic";
7776 if (k.composerSpecialPages[pageid] && k.composerSpecialPages[pageid].malay) {
7777 switchit = "Tambah Gambar / Video";
7778 }
7779 break;
7780
7781 case '/ajax/composerx/attachment/question/':
7782 switchit = "Query";
7783 if (k.composerSpecialPages[pageid] && k.composerSpecialPages[pageid].malay) {
7784 switchit = "Tanya Soalan";
7785 }
7786 break;
7787
7788 case '/ajax/composerx/attachment/group/file/':
7789 case '/ajax/composerx/attachment/group/filedropbox/':
7790 if (k.composerSpecialPages[pageid] && k.composerSpecialPages[pageid].malay) {
7791 switchit = "Muat Naik Fail";
7792 }
7793 break;
7794
7795 default:
7796 break;
7797 }
7798 if (!switchit) {
7799 if (attachment.getAttribute('data-endpoint').indexOf('/ajax/composerx/attachment/pages/other') != -1 || attachment.getAttribute('data-endpoint').indexOf('/ajax/metacomposer/attachment/timeline/pages_other.php') != -1) {
7800 switchit = "Adventure, Milestone +";
7801 //if (attachment.id == 'offerEventAndOthersButton') {
7802 if (attachment.textContent.toLowerCase().indexOf('offer') != -1) {
7803 switchit = "Offer, Adventure +";
7804 }
7805 }
7806 }
7807
7808 if (switchit) {
7809 var done = false;
7810 var inner = attachment.querySelector('._2-s, .-cx-PUBLIC-fbTimelineComposerAttachment__label');
7811 if (!inner) {
7812 inner = attachment.querySelector('._51z7, .-cx-PUBLIC-fbComposerAttachment__linktext');
7813 if (!inner) {
7814 // page timelines use ".attachmentName" and are wacky, there are actually two copies of the <div> that show/hide
7815 $$(attachment, '.attachmentName', function(inner) {
7816 k._changeComposerAttachment_inner(inner, switchit);
7817 done = true;
7818 });
7819
7820 if (!done) {
7821 inner = attachment;
7822 }
7823 }
7824 }
7825
7826 if (!done) {
7827 k._changeComposerAttachment_inner(inner, switchit);
7828 }
7829 }
7830
7831 attachment.setAttribute('data-ponyhoof-ponified', 1);
7832 });
7833 };
7834
7835 k._changeComposerAttachment_inner = function(inner, switchit) {
7836 var stopit = false;
7837 loopChildText(inner, function(child) {
7838 if (stopit) {
7839 return;
7840 }
7841 if (child.nodeType == 3) {
7842 child.textContent = switchit;
7843 stopit = true;
7844 }
7845 });
7846 };
7847
7848 k._changeComposer_insertReadme = function(insertBefore) {
7849 var n = d.createElement('iframe');
7850 n.className = 'showOnceInteracted ponyhoof_page_readme _4- -cx-PRIVATE-fbComposer__showonceinteracted';
7851 n.scrolling = 'auto';
7852 n.frameborder = '0';
7853 n.allowtransparency = 'true';
7854 n.src = PONYHOOF_README;
7855 insertBefore.parentNode.insertBefore(n, insertBefore);
7856 };
7857
7858 k._changeComposer_fixGroup = function(target) {
7859 if (hasClass(target.parentNode, '_55d0') || hasClass(target.parentNode, '.-cx-PUBLIC-fbComposer__content')) {
7860 var pageid = target.querySelector('input[name="xhpc_targetid"]');
7861 if (!pageid) {
7862 return;
7863 }
7864 pageid = pageid.value;
7865
7866 // domChangeTextbox will not work as these <textarea>s already has "data-ponyhoof-ponified"
7867 var composer = target.querySelector(k.composerSelectors);
7868 if (!composer) {
7869 return;
7870 }
7871
7872 $$(target, k.composerButtonSelectors, function(submit) {
7873 var malay = false;
7874 var lang = CURRENTLANG;
7875 if (k.composerSpecialPages[pageid] && k.composerSpecialPages[pageid].malay) {
7876 malay = true;
7877 lang = LANG['ms_MY'];
7878 }
7879
7880 if (!k.composerExclude.test(composer.value) && k.composerPonies.test(composer.value)) {
7881 if (composer.value.toUpperCase() == composer.value) {
7882 k.changeButtonText(submit, lang.fb_composer_ponies_caps);
7883 } else {
7884 k.changeButtonText(submit, lang.fb_composer_ponies);
7885 }
7886 } else if (malay) {
7887 k.changeButtonText(submit, "Kirim");
7888 }
7889 });
7890 }
7891 };
7892
7893 k.fbDockChatBuddylistNub = function(target) {
7894 if (target.parentNode && target.parentNode.parentNode && target.parentNode.parentNode.getAttribute && target.parentNode.parentNode.getAttribute('id') == 'fbDockChatBuddylistNub' && hasClass(target, 'label')) {
7895 k._fbDockChatBuddylistNub_change(target);
7896 return true;
7897 }
7898 // first loading
7899 var nub = target.querySelector('#fbDockChatBuddylistNub .label');
7900 if (nub) {
7901 k._fbDockChatBuddylistNub_change(nub);
7902 }
7903 return false;
7904 };
7905
7906 k._fbDockChatBuddylistNub_change = function(target) {
7907 if (target.childNodes && target.childNodes.length && target.childNodes[0] && target.childNodes[0].nodeType == TEXT_NODE) {
7908 var replaced = target.childNodes[0].textContent.replace(/Chat/, "Whinny");
7909 if (target.childNodes[0].textContent != replaced) {
7910 addClass(target, 'ponyhoof_chatLabel_ponified');
7911 target.childNodes[0].textContent = replaced;
7912 }
7913 }
7914 };
7915
7916 k.pokesDashboard = function(target) {
7917 if (target.getAttribute && target.getAttribute('id') && target.getAttribute('id').indexOf('poke_') == 0) {
7918 k._pokesDashboard_item(target);
7919 return true;
7920 }
7921
7922 $$(target, '.pokesDashboard > .objectListItem', k._pokesDashboard_item);
7923
7924 if (hasClass(target, 'highlight')) {
7925 var t = target.textContent;
7926 t = t.replace(/You poked /, 'You nuzzled ');
7927 if (target.textContent != t) {
7928 target.textContent = t;
7929 }
7930 return true;
7931 }
7932
7933 k._pokesDashboard_pokeLink(target);
7934
7935 return false;
7936 };
7937
7938 k._pokesDashboard_item = function(item) {
7939 var header = item.getElementsByClassName('pokeHeader');
7940 if (!header || !header.length) {
7941 return;
7942 }
7943 header = header[0];
7944
7945 var t = header.innerHTML;
7946 t = t.replace(/ has poked you\./, ' has nuzzled you.');
7947 if (header.innerHTML != t) {
7948 header.innerHTML = t;
7949 }
7950
7951 k._pokesDashboard_pokeLink(item);
7952 };
7953
7954 k._pokesDashboard_pokeLink = function(target) {
7955 $$(target, 'a[ajaxify^="/ajax/pokes/poke_inline.php"]', function(poke) {
7956 var text = "Nuzzle";
7957 if (poke.getAttribute('ajaxify').indexOf('pokeback=1') != -1) { // http://fb.com/406911932763192
7958 text = "Nuzzle Back";
7959 }
7960
7961 if (poke.childNodes && poke.childNodes.length && poke.childNodes[1]) {
7962 poke.childNodes[1].textContent = text;
7963 return;
7964 }
7965
7966 var stop = false;
7967 loopChildText(poke, function(child) {
7968 if (stop) {
7969 return;
7970 }
7971 if (child.nodeType == TEXT_NODE) {
7972 child.textContent = text;
7973 stop = true;
7974 }
7975 });
7976 });
7977 };
7978
7979 k.notification = function(dom) {
7980 domReplaceFunc(dom.target, 'notification', '.notification', function(ele) {
7981 k._notification_change(ele, '.info', 'metadata', 'blueName');
7982 });
7983 };
7984
7985 k.notification_itemClass = ['_33c', '-cx-PRIVATE-fbNotificationJewelItem__item'];
7986 k.notification_textClass = ['_4l_v', '-cx-PRIVATE-fbNotificationJewelItem__text'];
7987 k.notification_metadataClass = ['_33f', '-cx-PRIVATE-fbNotificationJewelItem__metadata'];
7988 k._notification_react = function(ele) {
7989 for (var i = 0; i <= 1; i += 1) {
7990 if (hasClass(ele, k.notification_itemClass[i])) {
7991 k._notification_change(ele, '.'+k.notification_textClass[i]+' > span', k.notification_metadataClass[i], 'fwb');
7992 return true;
7993 }
7994 }
7995 return false;
7996 };
7997
7998 k._notification_change = function(ele, info, metadata, bold) {
7999 var info = ele.querySelector(info);
8000 if (!info) {
8001 return;
8002 }
8003 if (!info.childNodes || !info.childNodes.length) {
8004 return;
8005 }
8006
8007 for (var i = 0, len = info.childNodes.length; i < len; i += 1) {
8008 var node = info.childNodes[i];
8009 if (hasClass(node, metadata) || hasClass(node, bold)) {
8010 continue;
8011 }
8012
8013 var text = node.textContent;
8014 if (text.indexOf('"') != -1) {
8015 var finalText = k.textNotification(text.substring(0, text.indexOf('"')));
8016 finalText += text.substring(text.indexOf('"'), text.length);
8017 } else {
8018 var finalText = k.textNotification(text);
8019 }
8020
8021 if (node.textContent != finalText) {
8022 node.textContent = finalText;
8023 }
8024
8025 if (text.indexOf('"') != -1) {
8026 break;
8027 }
8028 }
8029 };
8030
8031 k.menuPrivacyOnlyAjaxify = [
8032 // when posting
8033 '%22value%22%3A%2280%22' // Everyone
8034 ,'%22value%22%3A%2250%22' // Friends of Friends
8035 ,'%22value%22%3A%2240%22' // Friends
8036 ,'%22value%22%3A%22127%22' // Friends except Acquaintances
8037 ,'%22value%22%3A%2210%22' // Only Me
8038
8039 // https://www.facebook.com/settings?tab=timeline&section=posting&view
8040 ,'%22value%22%3A40'
8041 ,'%22value%22%3A10'
8042 ];
8043 k._processMenuXOldWidthDiff = 0;
8044 k.menuItems = function(dom) {
8045 var processMenuX = false;
8046 var hasScrollableArea = false;
8047 k._processMenuXOldWidthDiff = 0;
8048 domReplaceFunc(dom.target, 'uiMenuItem', '.uiMenuItem, ._54ni, .-cx-PUBLIC-abstractMenuItem__root, .ufb-menu-item', function(ele) {
8049 if (hasClass(ele, 'ponyhoof_fbmenuitem')) {
8050 return;
8051 }
8052 addClass(ele, 'ponyhoof_fbmenuitem');
8053
8054 // pages on share dialog
8055 if (hasClass(ele, '_90z') || hasClass(ele, '-cx-PRIVATE-fbShareModePage__smalliconcontainer')) {
8056 return;
8057 }
8058
8059 // lists/groups on Invite Friends dialogs
8060 var listendpoint = ele.getAttribute('data-listendpoint');
8061 if (listendpoint && listendpoint != '/ajax/chooser/list/friends/all/' && listendpoint.indexOf('/ajax/chooser/list/friends/') == 0 && listendpoint.indexOf('/ajax/chooser/list/friends/suggest/?filter=all') == -1) {
8062 return;
8063 }
8064
8065 var replacer = menuTitles;
8066 if (hasClass(ele, 'fbPrivacyAudienceSelectorOption')) {
8067 replacer = menuPrivacyOnlyTitles;
8068
8069 // ensure that only FB-provided options get changed
8070 var itemAnchor = ele.getElementsByClassName('itemAnchor');
8071 if (itemAnchor.length) {
8072 var ajaxify = itemAnchor[0].getAttribute('ajaxify');
8073 // Sometimes ajaxify is missing (legacy edit video)
8074 if (ajaxify) {
8075 var _menuPrivacyOnlyOk = false;
8076 for (var i = 0, len = k.menuPrivacyOnlyAjaxify.length; i < len; i += 1) {
8077 if (ajaxify.indexOf(k.menuPrivacyOnlyAjaxify[i]) != -1) {
8078 _menuPrivacyOnlyOk = true;
8079 break;
8080 }
8081 }
8082 if (!_menuPrivacyOnlyOk) {
8083 return;
8084 }
8085 }
8086 }
8087 }
8088
8089 var label = ele.querySelector('.itemLabel, ._54nh, .-cx-PUBLIC-abstractMenuItem__label, .ufb-menu-item-label');
8090 if (label) {
8091 //if (label.childNodes.length == 1) {
8092 // timeline post has 2
8093 var io = label.getElementsByTagName('span');
8094 if (io.length) {
8095 if (!hasClass(io[0], 'hidden_elem')) {
8096 label = io[0];
8097 }
8098 }
8099
8100 var orig = '';
8101 var replaced = '';
8102 //var oldWidthBody = '';
8103 var oldLabelWidth = 0;
8104 ele.setAttribute('data-ponyhoof-menuitem-orig', ele.textContent);
8105 loopChildText(label, function(child) {
8106 if (child.nodeType == 3) {
8107 var t = child.textContent;
8108 orig += t+' ';
8109 t = replaceText(replacer, t);
8110 if (child.textContent != t) {
8111 if (!hasScrollableArea && (ele.parentNode && ele.parentNode.parentNode && hasClass(ele.parentNode.parentNode, 'uiScrollableAreaContent'))) {
8112 hasScrollableArea = true;
8113 }
8114 if (hasScrollableArea) {
8115 //oldWidthBody = ele.parentNode.parentNode.parentNode.style.width;
8116 //ele.parentNode.parentNode.parentNode.style.width = 'auto';
8117 label.style.display = 'inline-block';
8118 //var oldWidth = label.offsetWidth;
8119 if (!oldLabelWidth) {
8120 //oldLabelWidth = oldWidth;
8121 oldLabelWidth = label.offsetWidth;
8122 }
8123 }
8124 child.textContent = t;
8125 }
8126 replaced += t+' ';
8127 }
8128 });
8129 //if (hasScrollableArea) {
8130 //ele.parentNode.parentNode.parentNode.style.width = oldWidthBody;
8131 //}
8132
8133 orig = orig.substr(0, orig.length-1);
8134 replaced = replaced.substr(0, replaced.length-1);
8135 ele.setAttribute('data-ponyhoof-menuitem-text', replaced);
8136 ele.setAttribute('data-label', replaced); // technically, this is only used for .uiMenuItem
8137
8138 if (orig != replaced) {
8139 if (hasClass(ele, '_54ni') || hasClass(ele, '-cx-PUBLIC-abstractMenuItem__root')) {
8140 if (hasScrollableArea && oldLabelWidth) {
8141 var newWidth = label.offsetWidth;
8142 if (newWidth > oldLabelWidth) {
8143 k._processMenuXOldWidthDiff = Math.max(newWidth - oldLabelWidth, 0);
8144 processMenuX = true;
8145 }
8146 } else {
8147 processMenuX = true;
8148 }
8149 }
8150 }
8151 if (hasScrollableArea) {
8152 label.style.display = '';
8153 }
8154 }
8155 });
8156
8157 if (processMenuX) {
8158 if (hasClass(dom.target, 'uiContextualLayerPositioner')) {
8159 k._menuItems_processMenuX(dom.target);
8160 return;
8161 }
8162
8163 k.getParent(dom.target, function(parent) {
8164 return hasClass(parent, 'uiContextualLayerPositioner');
8165 }, k._menuItems_processMenuX);
8166 }
8167 };
8168 k._menuItems_processMenuX = function(layer) {
8169 if (!layer) {
8170 return;
8171 }
8172
8173 var ownerid = layer.getAttribute('data-ownerid');
8174 if (!ownerid) {
8175 return;
8176 }
8177 ownerid = $(ownerid);
8178 if (!ownerid) {
8179 return;
8180 }
8181
8182 var menu = layer.querySelector('._54nq, .-cx-PUBLIC-abstractMenu__wrapper');
8183 if (!menu) {
8184 return;
8185 }
8186
8187 if (k._processMenuXOldWidthDiff) {
8188 var uiScrollableArea = layer.getElementsByClassName('uiScrollableArea');
8189 var uiScrollableAreaBody = layer.getElementsByClassName('uiScrollableAreaBody');
8190 if (uiScrollableArea && uiScrollableAreaBody) {
8191 uiScrollableArea = uiScrollableArea[0];
8192 uiScrollableAreaBody = uiScrollableAreaBody[0];
8193
8194 uiScrollableArea.style.width = (parseInt(uiScrollableArea.style.width)+k._processMenuXOldWidthDiff)+'px';
8195 uiScrollableAreaBody.style.width = (parseInt(uiScrollableAreaBody.style.width)+k._processMenuXOldWidthDiff)+'px';
8196 }
8197 }
8198
8199 var border = layer.querySelector('._54hx, .-cx-PUBLIC-abstractMenu__shortborder');
8200 if (!border) {
8201 return;
8202 }
8203 border.style.width = (Math.max((menu.offsetWidth - ownerid.offsetWidth), 0))+'px';
8204 };
8205
8206 k.fbRemindersStory = function(target) {
8207 $$(target, '.fbRemindersStory', function(item) {
8208 var inner = item.querySelector('._42ef > .fcg, .-cx-PRIVATE-uiFlexibleBlock__flexiblecontent > .fcg');
8209 if (!inner) {
8210 return;
8211 }
8212
8213 loopChildText(inner, function(child) {
8214 if (child.nodeType == TEXT_NODE) {
8215 var t = child.textContent;
8216 t = t.replace(/\bpoked you\b/, "nuzzled you");
8217 if (child.textContent != t) {
8218 child.textContent = t;
8219 }
8220 } else {
8221 if (hasClass(child, 'fbRemindersTitle')) {
8222 var t = child.innerHTML;
8223 t = t.replace(/([0-9]+?) events/, "$1 adventures")
8224 if (child.innerHTML != t) {
8225 child.innerHTML = t;
8226 }
8227 }
8228 }
8229 });
8230 });
8231 };
8232
8233 k.flyoutLikeForm = function(target) {
8234 var result = k._flyoutLikeForm(target, 'groupsMemberFlyoutLikeForm', 'unlike');
8235 if (!result) {
8236 result = k._flyoutLikeForm(target, 'fbEventMemberLike', 'liked');
8237 }
8238 return result;
8239 };
8240
8241 k._flyoutLikeForm = function(target, className, forminput) {
8242 domReplaceFunc(target, className, '.'+className, function(ele) {
8243 if (!ele.elements[forminput]) {
8244 return;
8245 }
8246
8247 var isLike = true;
8248 if (ele.elements[forminput].value == 1) {
8249 isLike = false;
8250 }
8251
8252 var submit = ele.querySelector('input[type="submit"]');
8253 if (!submit) {
8254 return;
8255 }
8256 if (isLike) {
8257 submit.value = capitaliseFirstLetter(CURRENTSTACK['like']);
8258 } else {
8259 submit.value = capitaliseFirstLetter(CURRENTSTACK['unlike']);
8260 }
8261 });
8262
8263 if (hasClass(target, className)) {
8264 return true;
8265 }
8266 return false;
8267 };
8268
8269 k.pluginButton = function(target) {
8270 if (!hasClass(d.body, 'plugin')) {
8271 return;
8272 }
8273
8274 //var root = target.getElementsByClassName('pluginConnectButtonLayoutRoot');
8275 var root = target.getElementsByClassName('pluginSkinLight');
8276 if (!root.length) {
8277 return;
8278 }
8279 root = root[0];
8280
8281 domReplaceFunc(root, '', '.pluginButton', function(ele) {
8282 var div = ele.getElementsByTagName('div');
8283 if (div.length) {
8284 ele = div[0];
8285 }
8286
8287 // <div class="pluginButton pluginButtonInline pluginConnectButtonDisconnected hidden_elem" title="Like"><div><button type="submit"><i class="pluginButtonIcon img sp_like sx_like_thumb"></i><span class="accessible_elem">Like</span></button><span aria-hidden="true">Like</span></div></div>
8288 var stop = false;
8289 loopChildText(ele, function(child) {
8290 if (stop) {
8291 return;
8292 }
8293 if (child.tagName.toUpperCase() == 'SPAN') {
8294 if (child.innerHTML == "Like") {
8295 child.innerHTML = capitaliseFirstLetter(CURRENTSTACK.like);
8296 stop = true;
8297 }
8298 }
8299 });
8300 });
8301
8302 domReplaceFunc(root, '', '.uiIconText', function(ele) {
8303 // <div style="padding-left: 19px;" class="uiIconText"><i class="img sp_like sx_like_fav" style="top: 0px;"></i><span id="u_0_1">You, <a href="https://www.facebook.com/XXX" target="_blank">XXX</a> and 102,502 others like this.</span><span class="hidden_elem" id="u_0_2"><a href="https://www.facebook.com/XXX" target="_blank">XXX</a> and 102,502 others like this.</span></div>
8304 loopChildText(ele, function(child) {
8305 loopChildText(child, function(inner) {
8306 if (inner.nodeType === TEXT_NODE) {
8307 var t = k.likeSentence(inner.textContent);
8308 t = t.replace(/\bfriends\b/g, CURRENTSTACK['friends_logic']); // Be the first of your friends.
8309 if (inner.textContent != t) {
8310 inner.textContent = t;
8311 }
8312 }
8313 });
8314 });
8315 });
8316
8317 // likebox
8318 $$(root, '.uiGrid .pts > .uiGrid .pls > div > span', function(ele) {
8319 var t = k.likeSentence(ele.textContent);
8320 if (ele.textContent != t) {
8321 ele.textContent = t;
8322 }
8323 });
8324 };
8325
8326 k.ticker = function(dom) {
8327 domReplaceFunc(dom.target, 'fbFeedTickerStory', '.fbFeedTickerStory', function(ele) {
8328 var div = ele.getElementsByClassName('uiStreamMessage');
8329 if (div.length) {
8330 div = div[0];
8331
8332 // Ticker messages are really inconsistent
8333 // <span class="passiveName">Friend</span> brohoofs <span class="token">Page</span>'s <span class="token">photo</span>.
8334 // <span class="passiveName">Friend</span> added a new pony pic.
8335 // <span class="passiveName">Friend</span> brohoofs <span class="token">Page</span>'s <span class="token">video</span> Title. // http://fb.com/10200537039965966
8336 var continueTextNodes = true;
8337 for (var i = 0, len = div.childNodes.length; i < len; i += 1) {
8338 var node = div.childNodes[i];
8339 if (node.nodeType == TEXT_NODE) {
8340 if (!continueTextNodes) {
8341 continue;
8342 }
8343
8344 var t = node.textContent;
8345
8346 var boundary = '';
8347 var haltOnBoundary = false;
8348 if (t.indexOf('"') != -1) {
8349 boundary = '"';
8350 haltOnBoundary = true;
8351 } else if (t.indexOf('\'s') != -1) {
8352 boundary = '\'s';
8353 continueTextNodes = false;
8354 }
8355
8356 if (boundary) {
8357 var finalText = k.textNotification(t.substring(0, t.indexOf(boundary)));
8358 finalText += t.substring(t.indexOf(boundary), t.length);
8359 } else {
8360 var finalText = k.textNotification(t);
8361 }
8362 //t = t.replace(/\blikes\b/, " "+CURRENTSTACK['likes_past']);
8363 //t = t.replace(/\blike\b/, " "+CURRENTSTACK['like_past']);
8364 if (node.textContent != finalText) {
8365 node.textContent = finalText;
8366 }
8367
8368 if (boundary && haltOnBoundary) {
8369 break;
8370 }
8371 } else {
8372 // It's too risky changing legit page names, so we are doing this in isolated cases
8373 if (hasClass(node, 'token')) {
8374 var list = [
8375 ['photo', 'pony pic']
8376 ,['a photo', 'a pony pic']
8377 ,['wall', 'journal']
8378 ];
8379 var t = replaceText(list, node.textContent);
8380 if (node.textContent != t) {
8381 node.textContent = t;
8382 }
8383 }
8384 }
8385 }
8386 }
8387 });
8388 if (hasClass(dom.target, 'fbFeedTickerStory')) {
8389 return true;
8390 }
8391 return false;
8392 };
8393
8394 k.beepNotification = function(dom) {
8395 warn("domNodeHandler.beepNotification() is deprecated");
8396 return false;
8397 };
8398
8399 // XYZ commented on your Wall post: "I like it"
8400 k._beepNotification_condition_classic = function(node, gt) {
8401 // <div class="UIBeep_Title"><span class="blueName">XYZ</span> likes your comment: "12"</div>
8402 // <div class="UIBeep_Title"><span class="blueName">XYZ</span> brohoofs your friendship letter: "12"</div>
8403 if (node.nodeType == 3) {
8404 return true;
8405 }
8406 return false;
8407 };
8408 k._beepNotification_condition_react = function(node, gt) {
8409 // <span id=".reactRoot[37].[0]{NUMBER}.0.[1].0.[1].0.0.[0]"><span class="fwb" id=".reactRoot[37].[0]{NUMBER}.0.[1].0.[1].0.0.[0].[0]"><span id=".reactRoot[37].[0]{NUMBER}.0.[1].0.[1].0.0.[0].[0].0">XYZ</span></span><span id=".reactRoot[37].[0]{NUMBER}.0.[1].0.[1].0.0.[0].[1]"> also commented on a </span><span class="fwb" id=".reactRoot[37].[0]{NUMBER}.0.[1].0.[1].0.0.[0].[2]"><span id=".reactRoot[37].[0]{NUMBER}.0.[1].0.[1].0.0.[0].[2].0">photo</span></span><span id=".reactRoot[37].[0]{NUMBER}.0.[1].0.[1].0.0.[0].[3]"> in </span><span class="fwb" id=".reactRoot[37].[0]{NUMBER}.0.[1].0.[1].0.0.[0].[4]"><span id=".reactRoot[37].[0]{NUMBER}.0.[1].0.[1].0.0.[0].[4].0">GROUP NAME</span></span><span id=".reactRoot[37].[0]{NUMBER}.0.[1].0.[1].0.0.[0].[5]">: "What?"</span></span>
8410
8411 // **XYZ** posted on **Ponyhoof**'s **timeline**: "XYZ"
8412 //if (hasClass(node, 'fwb')) {
8413 // return false;
8414 //}
8415 return true;
8416 };
8417
8418 k._beepNotification_change = function(ele, info, condition) {
8419 if (!info) {
8420 return;
8421 }
8422
8423 var gt = JSON.parse(ele.getAttribute('data-gt'));
8424 ele.setAttribute('data-ponyhoof-beeper-orig', info.textContent);
8425 for (var i = 0, len = info.childNodes.length; i < len; i += 1) {
8426 var node = info.childNodes[i];
8427 if (condition(node, gt)) {
8428 if (node.nodeType == 3) {
8429 var text = node.textContent;
8430 } else {
8431 var inner = node.getElementsByTagName('span');
8432 if (inner.length) {
8433 // reactRoot .fwb
8434 node = inner[0];
8435 }
8436 var text = node.innerHTML;
8437 }
8438
8439 if (text.indexOf('"') != -1) {
8440 var finalText = k.textNotification(text.substring(0, text.indexOf('"')));
8441 finalText += text.substring(text.indexOf('"'), text.length);
8442 } else {
8443 var finalText = k.textNotification(text);
8444 }
8445
8446 if (node.nodeType == 3) {
8447 if (node.textContent != finalText) {
8448 node.textContent = finalText;
8449 }
8450 } else {
8451 if (node.innerHTML != finalText) {
8452 node.innerHTML = finalText;
8453 }
8454 }
8455
8456 if (text.indexOf('"') != -1) {
8457 break;
8458 }
8459 }
8460 }
8461 ele.setAttribute('data-ponyhoof-beeper-message', info.textContent);
8462
8463 if (userSettings.sounds) {
8464 var file = '';
8465 if (SOUNDS[userSettings.soundsFile]) {
8466 file = userSettings.soundsFile;
8467 }
8468
8469 if (!file || file == 'AUTO') {
8470 file = '_sound/defaultNotification';
8471
8472 var data = convertCodeToData(REALPONY);
8473 if (data.soundNotif) {
8474 file = data.soundNotif;
8475 }
8476 }
8477
8478 if (userSettings.soundsNotifTypeBlacklist) {
8479 var current = userSettings.soundsNotifTypeBlacklist.split('|');
8480
8481 if (current.indexOf(gt.notif_type) != -1) {
8482 return;
8483 }
8484 }
8485
8486 try {
8487 var finalfile = THEMEURL+file+'.EXT';
8488 if (gt.notif_type == 'poke' && CURRENTSTACK.stack == 'pony') {
8489 finalfile = THEMEURL+'_sound/pokeSound.EXT';
8490 }
8491
8492 var ps = initPonySound('notif', finalfile);
8493 ps.wait = 15;
8494 ps.play();
8495 } catch (e) {}
8496 }
8497 };
8498
8499 k.insightsCountryData = [
8500 ["United States of America", "United States of Amareica"]
8501 ,["Malaysia", "Marelaysia"]
8502 ,["Mexico", "Mexicolt"]
8503 ,["New Zealand", "Neigh Zealand"]
8504 ,["Philippines", "Fillypines"]
8505 ,["Singapore", "Singapony"]
8506 ,["Singapore, Singapore", "Singapony"]
8507 ];
8508 k.insightsCountry = function(dom) {
8509 domReplaceFunc(dom.target, 'breakdown-list-table', '.breakdown-list-table', function(ele) {
8510 if (ele.getAttribute('data-ponyhoof-ponified')) {
8511 return;
8512 }
8513 ele.setAttribute('data-ponyhoof-ponified', 1);
8514 $$(ele, '.breakdown-key .ufb-text-content', function(country) {
8515 country.textContent = replaceText(k.insightsCountryData, country.textContent);
8516 });
8517 });
8518 };
8519
8520 k.timelineMutualLikes = function(target) {
8521 $$(target, '.fbStreamTimelineFavStory', function(root) {
8522 $$(root, '.fbStreamTimelineFavInfoContainer', function(ele) {
8523 var done = false;
8524 loopChildText(ele, function(child) {
8525 if (done) {
8526 return;
8527 }
8528 if (child.nodeType == TEXT_NODE) {
8529 var t = k.textStandard(child.textContent);
8530 if (child.textContent != t) {
8531 child.textContent = t;
8532 done = true;
8533 }
8534 }
8535 });
8536 });
8537
8538 $$(root, '.fbStreamTimelineFavFriendContainer > .friendText > .fwn', function(ele) {
8539 loopChildText(ele, function(child) {
8540 if (child.nodeType == ELEMENT_NODE) {
8541 if (!child.href || child.href.indexOf('/browse/users/') == -1) {
8542 return;
8543 }
8544 }
8545 var t = k.textStandard(child.textContent);
8546 if (child.textContent != t) {
8547 child.textContent = t;
8548 }
8549 });
8550 });
8551 });
8552 };
8553
8554 // http://fb.com/406714556116263
8555 // http://fb.com/411361928984859
8556 k.videoStageContainer = function(target) {
8557 if (hasClass(target, 'videoStageContainer')) {
8558 addClass(k.photos_snowlift, 'ponyhoof_snowlift_video');
8559 } else if (hasClass(target, 'spotlight')) {
8560 removeClass(k.photos_snowlift, 'ponyhoof_snowlift_video');
8561 }
8562 };
8563
8564 k._dialog_playSound = function(title, outer) {
8565 if (!title) {
8566 return;
8567 }
8568 var lowercase = title.toLowerCase();
8569 for (var i = 0, len = dialogDerpTitles.length; i < len; i += 1) {
8570 if (dialogDerpTitles[i].toLowerCase() == lowercase) {
8571 if (outer) {
8572 addClass(outer, 'ponyhoof_fbdialog_derp');
8573 }
8574
8575 if (CURRENTSTACK.stack == 'pony' && userSettings.sounds && !isPageHidden()) {
8576 var ps = initPonySound('ijustdontknowwhatwentwrong', THEMEURL+'_sound/ijustdontknowwhatwentwrong.EXT');
8577 ps.wait = 5;
8578 ps.play();
8579 break;
8580 }
8581 }
8582 }
8583 };
8584
8585 k.ponyhoofPageOptions = function(dom) {
8586 if (!$('pagelet_timeline_page_actions')) {
8587 return;
8588 }
8589 if ($('ponyhoof_footer_options')) {
8590 return;
8591 }
8592
8593 var selector = dom.target.querySelector('#pagelet_timeline_page_actions .fbTimelineActionSelector');
8594 if (!selector) {
8595 return;
8596 }
8597 var menu = selector.getElementsByClassName('uiMenuInner');
8598 if (!menu.length) {
8599 return;
8600 }
8601 menu = menu[0];
8602 var whatpage = menu.querySelector('#fbpage_share_action a');
8603 if (!whatpage) {
8604 return;
8605 }
8606 if (whatpage.getAttribute('href').indexOf('p[]='+PONYHOOF_PAGE) != -1) {
8607 var button = selector.getElementsByClassName('fbTimelineActionSelectorButton');
8608 if (!button.length) {
8609 return;
8610 }
8611 button = button[0];
8612
8613 var sep = d.createElement('li');
8614 sep.className = 'uiMenuSeparator';
8615
8616 var a = d.createElement('a');
8617 a.className = 'itemAnchor';
8618 a.setAttribute('role', 'menuitem');
8619 a.setAttribute('tabindex', '0');
8620 a.href = '#';
8621 a.id = "ponyhoof_footer_options";
8622 a.innerHTML = '<span class="itemLabel fsm">'+CURRENTLANG.options_title+'</span>';
8623 a.addEventListener('click', function(e) {
8624 optionsOpen();
8625
8626 try {
8627 clickLink(button);
8628 } catch (ex) {}
8629
8630 e.preventDefault();
8631 }, false);
8632
8633 var li = d.createElement('li');
8634 li.className = 'uiMenuItem ponyhoof_fbmenuitem';
8635 li.setAttribute('data-label', CURRENTLANG.options_title);
8636 li.setAttribute('data-ponyhoof-menuitem-orig', CURRENTLANG.options_title);
8637 li.setAttribute('data-ponyhoof-menuitem-text', CURRENTLANG.options_title);
8638 li.appendChild(a);
8639
8640 menu.insertBefore(sep, menu.firstChild);
8641 menu.insertBefore(li, sep);
8642 }
8643 };
8644
8645 k.debug_betaFacebookBaseRewrote = false;
8646 k.debug_betaFacebookLinks = function(target) {
8647 if (!k.debug_betaFacebookBaseRewrote) {
8648 contentEval(function(arg) {
8649 try {
8650 if (typeof window.requireLazy == 'function') {
8651 window.requireLazy(['Env'], function(Env) {
8652 Env.www_base = window.location.protocol+'//'+window.location.hostname+'/';
8653 });
8654 }
8655 } catch (e) {
8656 if (arg.CANLOG && typeof console != 'undefined' && console.log && console.dir) {
8657 console.log("Unable to hook to Env");
8658 console.dir(e);
8659 }
8660 }
8661 }, {"CANLOG":CANLOG});
8662 k.debug_betaFacebookBaseRewrote = true;
8663 }
8664 var links = target.querySelectorAll('a[href^="http://www.facebook.com"], a[href^="https://www.facebook.com"]');
8665 for (var i = 0, len = links.length; i < len; i += 1) {
8666 var link = links[i];
8667 var href = link.href;
8668 href = href.replace(/http\:\/\/www.facebook.com\//, 'http://beta.facebook.com/');
8669 href = href.replace(/https\:\/\/www.facebook.com\//, 'https://beta.facebook.com/');
8670
8671 link.href = href;
8672 }
8673 };
8674
8675 // Mutation
8676 k.mutateCharacterData = function(mutation) {
8677 var parent = null;
8678 if (mutation.target && mutation.target.parentNode) {
8679 parent = mutation.target.parentNode;
8680 if (parent.tagName.toUpperCase() == 'ABBR') {
8681 return;
8682 }
8683 }
8684
8685 if (userSettings.debug_mutationDebug) {
8686 try {
8687 console.log('characterData:');
8688 if (!ISFIREFOX) {
8689 console.dir(mutation.target);
8690 }
8691 } catch (e) {}
8692 }
8693
8694 k.textNodes({target: mutation.target});
8695
8696 if (!parent) {
8697 return;
8698 }
8699 var id = parent.getAttribute(k.REACTATTRNAME);
8700 if (id) {
8701 if (parent.rel == 'dialog') {
8702 if (parent.getAttribute('ajaxify').indexOf('/ajax/browser/dialog/likes') == 0) {
8703 k.getParent(parent, function(likesentence) {
8704 return hasClass(likesentence, 'UFILikeSentence');
8705 }, function(likesentence) {
8706 if (likesentence) {
8707 k._likePostBox(likesentence);
8708 }
8709 });
8710 }
8711 } else if (hasClass(parent.parentNode, 'UFIPagerLink')) {
8712 k.ufiPagerLink({target: parent.parentNode.parentNode});
8713 } else if (hasClass(parent, 'ponyhoof_brohoof_button')) {
8714 k._commentLikeLink(parent);
8715 } else if (parent.nextSibling && hasClass(parent.nextSibling, 'UFIOrderingModeSelectorDownCaret')) {
8716 k.UFIOrderingMode(parent);
8717 } else {
8718 if (parent.parentNode && parent.parentNode.parentNode) {
8719 //if (hasClass(parent.parentNode.parentNode, 'UFIImageBlockContent') || (parent.parentNode.parentNode.parentNode && hasClass(parent.parentNode.parentNode.parentNode, 'UFIImageBlockContent'))) {
8720 if (hasClass(parent.parentNode.parentNode, 'UFILikeSentenceText') || (parent.parentNode.parentNode.parentNode && hasClass(parent.parentNode.parentNode.parentNode, 'UFILikeSentenceText'))) {
8721 // live commenting
8722 // You and John brohoof this.
8723 // You like this.
8724 var ufi = k.getReactUfi(parent);
8725 if (ufi) {
8726 k.postLike({target: ufi});
8727 }
8728 } else {
8729 if (hasClass(parent.parentNode.parentNode, k.notification_textClass[0]) || hasClass(parent.parentNode.parentNode, k.notification_textClass[1])) {
8730 // gosh, i dislike this...
8731 k.getParent(parent, function(notificationItem) {
8732 return hasClass(notificationItem, k.notification_itemClass[0]) || hasClass(notificationItem, k.notification_itemClass[1]);
8733 }, function(notificationItem) {
8734 if (!notificationItem) {
8735 return;
8736 }
8737
8738 var i = 0;
8739 if (hasClass(notificationItem, k.notification_itemClass[1])) {
8740 i = 1;
8741 }
8742
8743 k._notification_change(notificationItem, '.'+k.notification_textClass[i]+' > span', k.notification_metadataClass[i], 'fwb');
8744 });
8745 }
8746 }
8747 }
8748 }
8749 }
8750 };
8751
8752 k.mutateAttributes = function(mutation) {
8753 //if (mutation.attributeName.indexOf('data-ponyhoof-') == 0) {
8754 // return;
8755 //}
8756 var target = mutation.target;
8757 if (mutation.attributeName == 'title') {
8758 if (target.title == target.getAttribute('data-ponyhoof-title-modified')) {
8759 return;
8760 }
8761 }
8762 switch (mutation.attributeName) {
8763 case 'title':
8764 var id = target.getAttribute(k.REACTATTRNAME);
8765 if (id) {
8766 if (hasClass(target, 'UFILikeLink')) {
8767 if (target.title == '' && mutation.oldValue != '') { // thanks a lot Hover Zoom
8768 target.setAttribute('data-ponyhoof-title', mutation.oldValue);
8769 target.setAttribute('data-ponyhoof-title-modified', mutation.oldValue);
8770 } else {
8771 var orig = target.title;
8772 var t = orig;
8773 t = t.replace(/\bcomment\b/, "friendship letter");
8774 t = t.replace(/\bLike this \b/, capitaliseFirstLetter(CURRENTSTACK.like)+' this ');
8775 t = t.replace(/\bUnlike this \b/, capitaliseFirstLetter(CURRENTSTACK.unlike)+' this ');
8776 t = t.replace(/\bunlike this \b/, CURRENTSTACK.unlike+' this ');
8777 t = t.replace(/\bliking this \b/, CURRENTSTACK.liking+' this ');
8778
8779 if (target.title != t) {
8780 target.title = t;
8781 }
8782 target.setAttribute('data-ponyhoof-title', orig);
8783 target.setAttribute('data-ponyhoof-title-modified', t);
8784 }
8785 }
8786 }
8787 break;
8788
8789 /*case 'value':
8790 if (/*(target.parentNode && hasClass(target.parentNode, 'uiButton')) || * /hasClass(target, 'ufb-button-input')) {
8791 var button = target.parentNode;
8792 if (button) {
8793 var orig = target.value;
8794 var replaced = replaceText(buttonTitles, orig);
8795 if (/*hasClass(button, 'uiButton') || * /hasClass(button, 'ufb-button')) {
8796 if (button.getAttribute('data-hover') != 'tooltip') {
8797 if (orig != replaced) {
8798 if (button.title == '') {
8799 button.title = orig;
8800 } else {
8801 if (button.title == button.getAttribute('data-ponyhoof-button-orig')) {
8802 button.title = orig;
8803 }
8804 }
8805 } else {
8806 button.title = '';
8807 }
8808 }
8809 button.setAttribute('data-ponyhoof-button-orig', orig);
8810 button.setAttribute('data-ponyhoof-button-text', replaced);
8811 }
8812 if (orig != replaced) {
8813 target.value = replaced;
8814 }
8815 }
8816 }
8817 break;*/
8818
8819 default:
8820 break;
8821 }
8822 };
8823
8824 // Utilities
8825 k.getParent = function(ele, iffunc, func) {
8826 var outer = ele.parentNode;
8827 while (outer) {
8828 if (iffunc(outer)) {
8829 break;
8830 }
8831 outer = outer.parentNode;
8832 }
8833
8834 func(outer);
8835 };
8836
8837 k.changeButtonText = function(button, t) {
8838 if (button.tagName.toUpperCase() == 'INPUT') {
8839 button.value = t;
8840 } else {
8841 button.innerHTML = t;
8842 }
8843 };
8844
8845 // Delays and let Facebook finish changing the DOM
8846 // Note that this shouldn't be a problem when MutationObserver is used full-time
8847 k.delayIU = function(func, delay) {
8848 var delay = delay || 10;
8849
8850 if (USINGMUTATION) {
8851 func();
8852 return;
8853 }
8854
8855 w.setTimeout(function() {
8856 var iu = INTERNALUPDATE;
8857 INTERNALUPDATE = true;
8858 func();
8859 INTERNALUPDATE = iu;
8860 }, delay);
8861 };
8862
8863 k.getReactUfi = function(ele) {
8864 // .reactRoot[3].[1][0].0.[1].0.0.[2]
8865 var finalid = k.getReactId(ele);
8866
8867 var ufi = d.querySelector('div['+k.REACTATTRNAME+'=".r['+finalid+']"]');
8868 if (ufi && hasClass(ufi, 'UFIList')) {
8869 return ufi;
8870 }
8871
8872 // Rollback to old method
8873 k.getParent(ele, function(ufiitem) {
8874 return hasClass(ufiitem, 'UFIList');
8875 }, function(ufiitem) {
8876 ufi = ufiitem;
8877 });
8878 return ufi;
8879 };
8880
8881 k.getReactCommentComponent = function(ele) {
8882 // .reactRoot[3].[1][2][1]{comment105273202993369_7901}.0.[1].0.[1].0.[1].[2]
8883 // .reactRoot[1].:1:1:1:comment558202387555478_1973546.:0.:1.:0.:1.:0
8884 var id = ele.getAttribute(k.REACTATTRNAME);
8885 if (!id) {
8886 return false;
8887 }
8888 var open = id.indexOf('{comment');
8889 var close = '}';
8890 var closeCount = 1;
8891 if (open == -1) {
8892 open = id.indexOf(':comment');
8893 if (open == -1) {
8894 return false;
8895 }
8896 close = '.:';
8897 closeCount = 0;
8898 }
8899 var subEnd = id.substring(open, id.length).indexOf(close);
8900 var component = id.substring(0, open+subEnd+closeCount);
8901
8902 return component;
8903 };
8904
8905 k.getReactComment = function(ele) {
8906 var component = k.getReactCommentComponent(ele);
8907
8908 var comment = d.querySelector('div['+k.REACTATTRNAME+'="'+component+'"]');
8909 if (comment && hasClass(comment, 'UFIComment')) {
8910 return comment;
8911 }
8912
8913 // Rollback to old method
8914 k.getParent(ele, function(ufiitem) {
8915 return hasClass(ufiitem, 'UFIComment');
8916 }, function(ufiitem) {
8917 comment = ufiitem;
8918 });
8919 return comment;
8920 };
8921
8922 k.getTrackingNode = function(ele) {
8923 var trackingNode = ele.getAttribute('data-ft');
8924 if (trackingNode) {
8925 try {
8926 trackingNode = JSON.parse(trackingNode);
8927 return trackingNode.tn;
8928 } catch (e) {}
8929 }
8930 return false;
8931 };
8932
8933 // Ignore irrelevant tags and some classes
8934 k.shouldIgnore = function(dom) {
8935 if (dom.target.nodeType == 8) { // comments
8936 return true;
8937 }
8938
8939 if (dom.target.nodeType != 3) {
8940 var tn = dom.target.tagName.toUpperCase();
8941 if (tn == 'SCRIPT' || tn == 'STYLE' || tn == 'LINK' || tn == 'INPUT' || tn == 'BR' || tn == 'META') {
8942 return true;
8943 }
8944 }
8945
8946 if (dom.target.parentNode && /(DOMControl_shadow|highlighterContent|textMetrics)/.test(dom.target.parentNode.className)) {
8947 return true;
8948 }
8949
8950 return false;
8951 };
8952
8953 k.dumpConsole = function(dom) {
8954 if (!userSettings.debug_dominserted_console) {
8955 return;
8956 }
8957
8958 if (dom.target.nodeType == 8) { // comments
8959 return;
8960 }
8961
8962 if (dom.target.nodeType == 3) {
8963 if (dom.target.parentNode && dom.target.parentNode.tagName.toUpperCase() != 'ABBR') {
8964 if (typeof console !== 'undefined' && console.dir) {
8965 console.dir(dom.target);
8966 }
8967 }
8968 return;
8969 }
8970
8971 var id = dom.target.getAttribute('id');
8972 if (id && (id.indexOf('bfb_') == 0 || id.indexOf('sfx_') == 0)) {
8973 return;
8974 }
8975
8976 var className = dom.target.className;
8977 if (className.indexOf('bfb_') == 0 || className.indexOf('sfx_') == 0) {
8978 return;
8979 }
8980
8981 var tagName = dom.target.tagName.toUpperCase();
8982 if (tagName != 'BODY') {
8983 if (typeof console !== 'undefined' && console.log) {
8984 console.log(dom.target.outerHTML);
8985 }
8986 }
8987 };
8988
8989 k.textBrohoof = function(ele) {
8990 var t = '';
8991 if (ele.nodeType == TEXT_NODE) {
8992 t = ele.textContent;
8993 } else {
8994 t = ele.innerHTML;
8995 }
8996 t = t.replace(/\bpeople\b/g, " "+CURRENTSTACK['people']);
8997 t = t.replace(/\bperson\b/g, " "+CURRENTSTACK['person']);
8998 t = t.replace(/likes this/g, CURRENTSTACK['likes']+" this");
8999 t = t.replace(/like this/g, CURRENTSTACK['like']+" this");
9000 t = t.replace(/Likes/g, capitaliseFirstLetter(CURRENTSTACK['likes'])); // new news feed page likes
9001 t = t.replace(/likes/g, CURRENTSTACK['likes']);
9002 t = t.replace(/like/g, CURRENTSTACK['like']);
9003 t = t.replace(/talking about this/g, "blabbering about this");
9004 t = t.replace(/\bfriends\b/g, CURRENTSTACK['friends_logic']);
9005 t = t.replace(/\bfriend\b/g, CURRENTSTACK['friend_logic']);
9006 if (ele.nodeType == TEXT_NODE) {
9007 if (ele.textContent != t) {
9008 ele.textContent = t;
9009 }
9010 } else {
9011 if (ele.innerHTML != t) {
9012 ele.innerHTML = t;
9013 }
9014 }
9015 };
9016
9017 k.textStandard = function(t) {
9018 t = t.replace(/\bpeople\b/g, " "+CURRENTSTACK['people']);
9019 t = t.replace(/\bfriends\b/g, " "+CURRENTSTACK['friends_logic']);
9020 t = t.replace(/\bfriend\b/g, " "+CURRENTSTACK['friend_logic']);
9021 t = t.replace(/\blikes\b/g, " "+CURRENTSTACK['likes_past']);
9022 t = t.replace(/\blike\b/g, " "+CURRENTSTACK['like_past']);
9023 return t;
9024 };
9025
9026 k.textNotification = function(t) {
9027 t = t.replace(/\bpeople\b/g, " "+CURRENTSTACK['people']);
9028 t = t.replace(/\(friends\b/g, "("+CURRENTSTACK['friends_logic']);
9029 t = t.replace(/\bfriends\b/g, " "+CURRENTSTACK['friends_logic']);
9030 t = t.replace(/\binvited you to like\b/g, " invited you to "+CURRENTSTACK.like);
9031 t = t.replace(/\blikes\b/g, " "+CURRENTSTACK['likes_past']);
9032 t = t.replace(/\blike\b/g, " "+CURRENTSTACK['like_past']);
9033
9034 t = t.replace(/\bcomment\b/g, "friendship letter");
9035 t = t.replace(/\bphoto\b/g, "pony pic");
9036 t = t.replace(/\bphotos\b/g, "pony pics");
9037 t = t.replace(/\bgroup\b/g, "herd");
9038 t = t.replace(/\bevent\b/g, "adventure");
9039 t = t.replace(/\btimeline\b/g, "journal");
9040 t = t.replace(/\bTimeline Review\b/g, "Journal Review");
9041 t = t.replace(/\bTimeline\b/g, "Journal"); // English UK
9042 t = t.replace(/\bnew messages\b/, "new friendship reports");
9043 t = t.replace(/\bnew message\b/, "new friendship report");
9044 t = t.replace(/\bprofile picture\b/g, "journal pony pic");
9045 t = t.replace(/\bfriend request\b/g, "friendship request");
9046 t = t.replace(/\bpoked you/g, " nuzzled you");
9047 return t;
9048 };
9049 };
9050 var _optionsLinkInjected = false;
9051 var injectOptionsLink = function() {
9052 if (_optionsLinkInjected) {
9053 return;
9054 }
9055
9056 if ($('logout_form')) {
9057 _optionsLinkInjected = true;
9058
9059 var optionsLink = d.createElement('a');
9060 optionsLink.href = '#';
9061 optionsLink.id = 'ponyhoof_account_options';
9062 optionsLink.className = 'navSubmenu submenuNav'; // submenuNav is for developers.facebook.com
9063 optionsLink.innerHTML = CURRENTLANG.options_title+" <span class='ponyhoof_hide_if_injected inline'>(Disabled)</span>";
9064 optionsLink.addEventListener('click', function(e) {
9065 optionsOpen();
9066
9067 try {
9068 clickLink($('navAccountLink'));
9069 } catch (e) {}
9070 try {
9071 clickLink($('accountNavArrow'));
9072 } catch (e) {}
9073
9074 e.preventDefault();
9075 }, false);
9076
9077 var optionsLinkLi = d.createElement('li');
9078 optionsLinkLi.setAttribute('role', 'menuitem');
9079 optionsLinkLi.appendChild(optionsLink);
9080
9081 var logout = $('logout_form');
9082 logout.parentNode.parentNode.insertBefore(optionsLinkLi, logout.parentNode);
9083 } else {
9084 var pageNav = $('pageNav');
9085 if (!pageNav) {
9086 return;
9087 }
9088
9089 var isBusiness = pageNav.querySelector('.navLink[href*="logout.php?h="]');
9090 if (!isBusiness) {
9091 return;
9092 }
9093
9094 _optionsLinkInjected = true;
9095
9096 var optionsLink = d.createElement('a');
9097 optionsLink.href = '#';
9098 optionsLink.id = 'ponyhoof_account_options';
9099 optionsLink.className = 'navLink';
9100 optionsLink.innerHTML = CURRENTLANG.options_title+" <span class='ponyhoof_hide_if_injected inline'>(Disabled)</span>";
9101 optionsLink.addEventListener('click', function(e) {
9102 optionsOpen();
9103 e.preventDefault();
9104 }, false);
9105
9106 var optionsLinkLi = d.createElement('li');
9107 optionsLinkLi.className = 'navItem middleItem';
9108 optionsLinkLi.appendChild(optionsLink);
9109
9110 pageNav.insertBefore(optionsLinkLi, pageNav.childNodes[0]);
9111 }
9112 };
9113
9114 var domNodeHandlerMain = new domNodeHandler();
9115 var mutationObserverMain = null;
9116
9117 var ranDOMNodeInserted = false;
9118 var runDOMNodeInserted = function() {
9119 if (ranDOMNodeInserted) {
9120 return false;
9121 }
9122
9123 ranDOMNodeInserted = true;
9124
9125 onPageReady(function() {
9126 if (d.body) {
9127 DOMNodeInserted({target: d.body});
9128 }
9129 });
9130
9131 if (!userSettings.debug_noMutationObserver) {
9132 try {
9133 var mutationObserver = w.WebKitMutationObserver || w.MutationObserver || false;
9134 if (mutationObserver) {
9135 var observerOptions = {attributes:true, childList:true, characterData:true, subtree:true, attributeOldValue:true, attributeFilter:['title'/*, 'class', 'value'*/]};
9136 mutationObserverMain = new mutationObserver(function(mutations) {
9137 if (INTERNALUPDATE) {
9138 return;
9139 }
9140 mutationObserverMain.disconnect();
9141
9142 for (var i = 0, len = mutations.length; i < len; i += 1) {
9143 switch (mutations[i].type) {
9144 case 'characterData':
9145 var iu = INTERNALUPDATE;
9146 INTERNALUPDATE = true;
9147
9148 domNodeHandlerMain.mutateCharacterData(mutations[i]);
9149
9150 INTERNALUPDATE = iu;
9151 break;
9152
9153 case 'childList':
9154 for (var j = 0, jlen = mutations[i].addedNodes.length; j < jlen; j += 1) {
9155 if (userSettings.debug_mutationDebug) {
9156 if (mutations[i].addedNodes[j].parentNode && mutations[i].addedNodes[j].parentNode.tagName != 'ABBR') {
9157 try {
9158 console.log('childList:');
9159 if (!ISFIREFOX) {
9160 console.dir(mutations[i].addedNodes[j]);
9161 } else {
9162 if (typeof mutations[i].addedNodes[j].className == 'undefined') {
9163 console.dir(mutations[i].addedNodes[j]);
9164 } else {
9165 //console.log(' '+mutations[i].addedNodes[j].className);
9166 //console.log(' '+mutations[i].addedNodes[j].innerHTML);
9167 }
9168 }
9169 } catch (e) {}
9170 }
9171 }
9172 DOMNodeInserted({target: mutations[i].addedNodes[j]});
9173 }
9174 break;
9175
9176 case 'attributes':
9177 var iu = INTERNALUPDATE;
9178 INTERNALUPDATE = true;
9179
9180 domNodeHandlerMain.mutateAttributes(mutations[i]);
9181
9182 INTERNALUPDATE = iu;
9183 break;
9184
9185 default:
9186 break;
9187 }
9188 }
9189 if (userSettings.debug_mutationDebug) {
9190 console.log('=========================================');
9191 }
9192 mutationObserverMain.observe(d.documentElement, observerOptions);
9193 });
9194 mutationObserverMain.observe(d.documentElement, observerOptions);
9195 USINGMUTATION = true;
9196 }
9197 } catch (e) {
9198 warn("MutationObserver threw an exception, fallback to DOMNodeInserted");
9199 dir(e);
9200 }
9201 }
9202 if (!USINGMUTATION) {
9203 d.addEventListener('DOMNodeInserted', DOMNodeInserted, true);
9204 }
9205
9206 if (d.body) {
9207 DOMNodeInserted({target: d.body});
9208 }
9209 };
9210
9211 var turnOffFbNotificationSound = function() {
9212 contentEval(function(arg) {
9213 try {
9214 if (typeof window.requireLazy == 'function') {
9215 window.requireLazy(['NotificationSound'], function(NotificationSound) {
9216 NotificationSound.prototype.play = function() {};
9217 });
9218 }
9219 } catch (e) {
9220 if (arg.CANLOG && typeof console != 'undefined' && console.log && console.dir) {
9221 console.log("Unable to hook to NotificationSound");
9222 console.dir(e);
9223 }
9224 }
9225 }, {"CANLOG":CANLOG});
9226 };
9227
9228 var changeChatSound = function(code) {
9229 onPageReady(function() {
9230 contentEval(function(arg) {
9231 try {
9232 if (typeof window.requireLazy == 'function') {
9233 window.requireLazy(['ChatConfig'], function(ChatConfig) {
9234 ChatConfig.set('sound.notif_ogg_url', arg.THEMEURL+arg.code+'.ogg');
9235 ChatConfig.set('sound.notif_mp3_url', arg.THEMEURL+arg.code+'.mp3');
9236 });
9237 }
9238 } catch (e) {
9239 if (arg.CANLOG && typeof console != 'undefined' && console.log && console.dir) {
9240 console.log("Unable to hook to ChatConfig");
9241 console.dir(e);
9242 }
9243 }
9244 }, {"CANLOG":CANLOG, "THEMEURL":THEMEURL, 'code':code});
9245 });
9246 };
9247
9248 var ranExtraInjection = false;
9249 var extraInjection = function() {
9250 if (ranExtraInjection) {
9251 return false;
9252 }
9253 ranExtraInjection = true;
9254
9255 for (var x in HTMLCLASS_SETTINGS) {
9256 if (userSettings[HTMLCLASS_SETTINGS[x]]) {
9257 addClass(d.documentElement, 'ponyhoof_settings_'+HTMLCLASS_SETTINGS[x]);
9258 }
9259 }
9260
9261 var globalcss = '';
9262 globalcss += 'html.ponyhoof_settings_show_messages_other #navItem_app_217974574879787 > ul {display:block !important;}';
9263 globalcss += '.ponyhoof_page_readme {width:100%;height:300px;border:solid #B4BBCD;border-width:1px 0;-moz-box-sizing:border-box;box-sizing:border-box;}';
9264 globalcss += '#fbIndex_swf {position:absolute;top:0;left:0;width:100%;height:100%;z-index:1;}';
9265 globalcss += '.ponyhoof_image_shadow {-moz-box-shadow:0 3px 8px rgba(0,0,0,.3);box-shadow:0 3px 8px rgba(0,0,0,.3);margin:0 auto;display:block;margin-bottom:3px;cursor:not-allowed;-webkit-user-drag:none;-moz-user-drag:none;user-drag:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;}';
9266 globalcss += '.ponyhoof_image_shadow.noshadow {-moz-box-shadow:none;box-shadow:none;}';
9267
9268 injectManualStyle(globalcss, 'global');
9269
9270 if (userSettings.customcss) {
9271 injectManualStyle(userSettings.customcss, 'customcss');
9272 }
9273
9274 INTERNALUPDATE = true;
9275 for (var i = 0; i < 10; i += 1) {
9276 var n = d.createElement('div');
9277 n.id = 'ponyhoof_extra_'+i;
9278 d.body.appendChild(n);
9279 }
9280
9281 var timeShift = function() {
9282 var now = new Date();
9283
9284 d.documentElement.setAttribute('data-ponyhoof-year', now.getFullYear());
9285 d.documentElement.setAttribute('data-ponyhoof-month', now.getMonth());
9286 d.documentElement.setAttribute('data-ponyhoof-date', now.getDate());
9287 d.documentElement.setAttribute('data-ponyhoof-hour', now.getHours());
9288 d.documentElement.setAttribute('data-ponyhoof-minute', now.getMinutes());
9289 };
9290 timeShift();
9291 w.setInterval(timeShift, 60*1000);
9292
9293 if (userSettings.chatSound) {
9294 if (!SOUNDS_CHAT[userSettings.chatSoundFile] || !SOUNDS_CHAT[userSettings.chatSoundFile].name) {
9295 userSettings.chatSoundFile = '_sound/grin2';
9296 }
9297 if (typeof w.Audio != 'undefined') {
9298 changeChatSound(userSettings.chatSoundFile);
9299 }
9300 }
9301
9302 if (userSettings.customBg) {
9303 changeCustomBg(userSettings.customBg);
9304 }
9305
9306 // Turn off Facebook's own notification sound
9307 if (userSettings.sounds) {
9308 turnOffFbNotificationSound();
9309 }
9310
9311 INTERNALUPDATE = false;
9312 };
9313
9314 var detectBrokenFbStyle = function() {
9315 var test = d.createElement('div');
9316 test.className = 'hidden_elem';
9317 d.documentElement.appendChild(test);
9318
9319 var style = w.getComputedStyle(test, null);
9320 if (style && style.display != 'none') {
9321 d.documentElement.removeChild(test);
9322
9323
9324 return true;
9325 }
9326 d.documentElement.removeChild(test);
9327 return false;
9328 };
9329
9330 // Wait for the current page to complete
9331 var scriptStarted = false;
9332 function startScript() {
9333 if (scriptStarted) {
9334 return;
9335 }
9336 scriptStarted = true;
9337
9338 // Don't run on exclusions
9339 if (w.location.hostname.indexOf('.facebook.com') == w.location.hostname.length-'.facebook.com'.length) {
9340 var excludes = ['/l.php', '/ai.php', '/ajax/'];
9341 for (var i = 0, len = excludes.length; i < len; i += 1) {
9342 if (w.location.pathname.indexOf(excludes[i]) == 0) {
9343 return;
9344 }
9345 }
9346 }
9347
9348 // Don't run on ajaxpipe
9349 if (w.location.search && w.location.search.indexOf('ajaxpipe=1') != -1) {
9350 return;
9351 }
9352
9353 // Don't run on Browser Ponies
9354 if (w.location.hostname == 'hoof.little.my') {
9355 var excludes = ['.gif', '.png'];
9356 for (var i = 0, len = excludes.length; i < len; i += 1) {
9357 if (w.location.pathname.indexOf(excludes[i]) != -1) {
9358 return;
9359 }
9360 }
9361 }
9362
9363 // Don't run on Open Graph Debugger
9364 if (w.location.hostname.indexOf('developers.') != -1 && w.location.hostname.indexOf('.facebook.com') != -1 && w.location.pathname == '/tools/debug/og/echo') {
9365 return;
9366 }
9367
9368 if (w.location.hostname == '0.facebook.com') {
9369 return;
9370 }
9371
9372 if (!d.head) {
9373 d.head = d.getElementsByTagName('head')[0];
9374 }
9375
9376 // Are we running in a special Ponyhoof page?
9377 if (d.documentElement.id == 'ponyhoof_page') {
9378 // Modify the <html> tag
9379 addClass(d.documentElement, 'ponyhoof_userscript');
9380 d.documentElement.setAttribute('data-ponyhoof-userscript-version', VERSION);
9381
9382 var changeVersion = function() {
9383 var v = d.getElementsByClassName('ponyhoof_VERSION');
9384 for (var i = 0, len = v.length; i < len; i += 1) {
9385 v[i].textContent = VERSION;
9386 }
9387 };
9388 changeVersion();
9389 onPageReady(changeVersion);
9390
9391 try {
9392 if (d.documentElement.getAttribute('data-ponyhoof-update-current') > VERSION) {
9393 addClass(d.documentElement, 'ponyhoof_update_outdated');
9394 } else {
9395 addClass(d.documentElement, 'ponyhoof_update_newest');
9396 }
9397 } catch (e) {}
9398 }
9399
9400 // Determine what storage method to use
9401 STORAGEMETHOD = 'none';
9402 try {
9403 if (typeof GM_getValue === 'function' && typeof GM_setValue === 'function') {
9404 // Chrome lies about GM_getValue support
9405 GM_setValue("ponyhoof_test", "ponies");
9406 if (GM_getValue("ponyhoof_test") === "ponies") {
9407 STORAGEMETHOD = 'greasemonkey';
9408 }
9409 }
9410 } catch (e) {}
9411
9412 if (STORAGEMETHOD == 'none') {
9413 try {
9414 if (typeof chrome != 'undefined' && chrome && chrome.extension && typeof GM_getValue == 'undefined') {
9415 STORAGEMETHOD = 'chrome';
9416 }
9417 } catch (e) {}
9418 }
9419
9420 if (STORAGEMETHOD == 'none') {
9421 try {
9422 if (typeof opera != 'undefined' && opera && opera.extension) {
9423 STORAGEMETHOD = 'opera';
9424 }
9425 } catch (e) {}
9426 }
9427
9428 if (STORAGEMETHOD == 'none') {
9429 try {
9430 if (typeof safari != 'undefined') {
9431 STORAGEMETHOD = 'safari';
9432 }
9433 } catch (e) {}
9434 }
9435
9436 if (STORAGEMETHOD == 'none') {
9437 if (DISTRIBUTION == 'xpi') {
9438 STORAGEMETHOD = 'xpi';
9439 }
9440 }
9441
9442 if (STORAGEMETHOD == 'none') {
9443 if (DISTRIBUTION == 'mxaddon') {
9444 STORAGEMETHOD = 'mxaddon';
9445 }
9446 }
9447
9448 if (STORAGEMETHOD == 'none') {
9449 STORAGEMETHOD = 'localstorage';
9450 }
9451
9452 if (d.documentElement.id == 'ponyhoof_page') {
9453 addClass(d.documentElement, 'ponyhoof_distribution_'+DISTRIBUTION);
9454 addClass(d.documentElement, 'ponyhoof_storagemethod_'+STORAGEMETHOD);
9455 return;
9456 }
9457
9458 // Inject the system style so we can do any error trapping
9459 injectSystemStyle();
9460
9461 // Grab the user
9462 USERID = cookie('c_user');
9463 if (!USERID) {
9464 USERID = 0;
9465 } else {
9466 SETTINGSPREFIX = USERID+'_';
9467 }
9468
9469 loadSettings(function(s) {
9470 userSettings = s;
9471
9472 loadSettings(function(s) {
9473 globalSettings = s;
9474
9475 if (userSettings.debug_slow_load) {
9476 onPageReady(settingsLoaded);
9477 return;
9478 }
9479 settingsLoaded();
9480 }, {prefix:'global_', defaultSettings:GLOBALDEFAULTSETTINGS});
9481 });
9482 };
9483
9484 // Check for legacy settings through message passing
9485 var migrateSettingsChromeDone = false;
9486 var migrateSettingsChrome = function(callback) {
9487 if (STORAGEMETHOD == 'chrome') {
9488 if (chrome.storage) {
9489 try {
9490 chrome_sendMessage({'command':'getValue', 'name':SETTINGSPREFIX+'settings'}, function(response) {
9491 if (response && typeof response.val != 'undefined') {
9492 var _settings = JSON.parse(response.val);
9493 if (_settings) {
9494 userSettings = _settings;
9495 saveSettings();
9496
9497 chrome_sendMessage({'command':'clearStorage'}, function() {});
9498 }
9499
9500 migrateSettingsChromeDone = true;
9501 callback();
9502 }
9503 });
9504 } catch (e) {
9505 error("Failed to read previous settings through message passing");
9506 dir(e);
9507 migrateSettingsChromeDone = true;
9508 callback();
9509 }
9510 return;
9511 }
9512 }
9513 migrateSettingsChromeDone = true;
9514 callback();
9515 };
9516
9517 // Check for previous settings from unprefixed settings
9518 var migrateSettingsUnprefixedDone = false;
9519 var migrateSettingsUnprefixed = function(callback) {
9520 loadSettings(function(s) {
9521 if (s.lastVersion) { // only existed in previous versions
9522 userSettings = s;
9523 saveSettings();
9524 saveValue('settings', JSON.stringify(null));
9525 }
9526
9527 migrateSettingsUnprefixedDone = true;
9528 callback();
9529 }, {prefix:''});
9530 };
9531
9532 var globalSettingsTryLastUserDone = false;
9533 var globalSettingsTryLastUser = function(callback) {
9534 if (!globalSettings.lastUserId) {
9535 globalSettingsTryLastUserDone = true;
9536 callback();
9537 return;
9538 }
9539
9540 SETTINGSPREFIX = globalSettings.lastUserId+'_';
9541 loadSettings(function(s) {
9542 if (s) {
9543 userSettings = s;
9544 }
9545
9546 globalSettingsTryLastUserDone = true;
9547 callback();
9548 });
9549 };
9550
9551 function settingsLoaded() {
9552 if (!userSettings.theme && !migrateSettingsChromeDone) {
9553 migrateSettingsChrome(settingsLoaded);
9554 return;
9555 }
9556
9557 // Migrate for multi-user
9558 if (!userSettings.theme && !migrateSettingsUnprefixedDone) {
9559 migrateSettingsUnprefixed(settingsLoaded);
9560 return;
9561 }
9562
9563 if (!globalSettings.globalSettingsMigrated) {
9564 if (!userSettings.lastVersion) {
9565 // New user
9566 statTrack('install');
9567 }
9568
9569 for (var i in GLOBALDEFAULTSETTINGS) {
9570 if (userSettings.hasOwnProperty(i)) {
9571 globalSettings[i] = userSettings[i];
9572 }
9573 }
9574 globalSettings.globalSettingsMigrated = true;
9575 saveGlobalSettings();
9576 }
9577
9578 if (!USERID && !globalSettingsTryLastUserDone) {
9579 // Try loading the last user
9580 globalSettingsTryLastUser(settingsLoaded);
9581 return;
9582 }
9583
9584 // If we haven't set up Ponyhoof, don't log
9585 if (!userSettings.theme || userSettings.debug_disablelog) {
9586 CANLOG = false;
9587 }
9588
9589 // Run ONLY on #facebook
9590 if (!(d.documentElement.id == 'facebook' && w.location.hostname.indexOf('.facebook.com') == w.location.hostname.length-'.facebook.com'.length) && d.documentElement.id != 'ponyhoof_page') {
9591 info("Ponyhoof does not run on "+w.location.href+" (html id is not #facebook)");
9592 return;
9593 }
9594
9595 // Did we already run our script?
9596 if (hasClass(d.documentElement, 'ponyhoof_userscript')) {
9597 info("Style already injected at "+w.location.href);
9598 return;
9599 }
9600
9601 // Don't run in frames
9602 var forceWhiteBackground = false;
9603 try {
9604 var href = w.location.href.toLowerCase();
9605
9606 if ((href.indexOf('/plugins/like.php') != -1 || href.indexOf('/plugins/likebox.php') != -1 || href.indexOf('/plugins/subscribe.php') || href.indexOf('/plugins/facepile.php') != -1) && (href.indexOf('login/plugin_roadblock.php') == -1 && (href.indexOf('#ponyhoof_runme') != -1 || href.indexOf('&ponyhoof_runme') != -1))) {
9607 // Allow like boxes for the Ponyhoof page (yeah, a bit cheating)
9608 } else if (hasClass(d.body, 'chrmxt')) {
9609 // Allow for Facebook Notifications for Chrome
9610 } else {
9611 // Allow for some frames
9612 var allowedFrames = ['/ads/manage/powereditor/funding', '/ads/manage/powereditor/convtrack', '/mobile/iframe_emails.php'];
9613 var allowedFramesOk = false;
9614 for (var i = 0, len = allowedFrames.length; i < len; i += 1) {
9615 if (w.location.pathname.indexOf(allowedFrames[i]) == 0) {
9616 allowedFramesOk = true;
9617 forceWhiteBackground = true;
9618 }
9619 }
9620
9621 if (!allowedFramesOk) {
9622 if (USW.self != USW.top) {
9623 throw 1;
9624 }
9625 }
9626 }
9627 } catch (e) {
9628 info("Framed");
9629 return;
9630 }
9631
9632 // Special instructions for browsers that needs localStorage
9633 runMe = true;
9634 if (STORAGEMETHOD == 'localstorage') {
9635 // Don't run on non-www :(
9636 if (userSettings.force_run) {
9637 log("Force running on "+w.location.href);
9638 } else {
9639 if (w.location.hostname != 'www.facebook.com') {
9640 info("w.location.hostname = "+w.location.hostname);
9641 runMe = false;
9642 }
9643 }
9644 }
9645
9646 if (!runMe) {
9647 info("Ponyhoof style is not injected on "+w.location.href);
9648 //return;
9649 }
9650
9651 CURRENTPONY = userSettings.theme;
9652
9653 if (!USERID && !globalSettings.allowLoginScreen) {
9654 info("Ponyhoof will not run when logged out because of a setting.");
9655 return;
9656 }
9657
9658 // Ban parasprites
9659 // If you would like to end up here, just simply show us that you have no clue about what Ponyhoof is really about and keep hitting "Send page source", don't be a moron please
9660 if (USERID && ['0147135a7dc2d1b65ca0032c97f89c5b', '6c5b9bf8a304f1a3e0b085f974c53592', '4ab4094e54225dccadf42bee9ac212a9', '2887516d877df760641ed9247cc84b65', '06308ee7060101f04a18e41158408730', 'a95ef44112c18876a808b2d7781e63ba', '57b540dc72835f30d402f6abc566677c', '1f75490e12b25ee5839687e0ffe65502', '24363cd421635e8268983f6187def3c8', '3a420678fb395a9e71ad6b523e880a27', 'd7a9db4027cd407b281c84cc626a9f70', '23d69d7ecfeeb940deef6bc69c3aee00', 'ad3553f919b97dbbb19a69966666641e', '46077eeb2467c70ec9332b672d1d7bd1', 'bc8ef81105cfdc4c6b5ff349622dae8a', 'a21ad36f4c3fc35494626d1399cc4be1', '3a2135f78503521e570608c07c3e6386', '8dc11f39765f8fe83603502afcb630a9', 'ac966d33840736554984577a78d37d95', '11abc5dd16709ff201ec00781c39ac3c', '00e957ff53a5b34518087621165498f9', '025e1b15134402df1803de9421dc7819', '125c419ddbad08ee8c53b88801415887', 'ca94af2350690962e97e1ac1fb98fa06', '62e6c5f16e8ccc79c94aa452aa36f5d8', 'cf7e6ddb2fc7c7984d323a81dfca8dfb', 'df6495bacaeb347a931f7e676fc8ee0b', 'e5ffc53255c20275e2c7d8f0c2ca5201', '31161cecf1fd9804bb66fa4e373733c6', 'cb5f2107815d30a538b30d82df93a1ac', '3a420678fb395a9e71ad6b523e880a27', 'b002c047d235437b8b255173ce73744a'].indexOf(md5(USERID)) != -1) {
9661 if (globalSettings.allowLoginScreen) {
9662 globalSettings.allowLoginScreen = false;
9663 saveGlobalSettings();
9664 }
9665 return;
9666 }
9667
9668 // If we don't have an old setting...
9669 if (userSettings.theme == null) {
9670 // ... and not logged in, DON'T show the welcome screen
9671 if (!USERID) {
9672 // Special exception at home page, we want that cool login background
9673 if (!hasClass(d.body, 'fbIndex')) {
9674 info("Ponyhoof does not run for logged out users.");
9675 return;
9676 }
9677 }
9678
9679 // Don't run on dialogs
9680 if (w.location.pathname.indexOf('/dialog/') == 0) {
9681 info("Ponyhoof does not run when there is no theme selected and running on dialogs.");
9682 return;
9683 }
9684 }
9685
9686 // v1.581: Detect broken Facebook styles and abort if derped
9687 if (userSettings.theme && detectBrokenFbStyle()) {
9688 error("Broken Facebook style: hidden_elem is not expected");
9689 return;
9690 }
9691
9692 // Modify the <html> tag
9693 addClass(d.documentElement, 'ponyhoof_userscript');
9694 addClass(d.documentElement, 'ponyhoof_storagemethod_'+STORAGEMETHOD);
9695 addClass(d.documentElement, 'ponyhoof_distribution_'+DISTRIBUTION);
9696 d.documentElement.setAttribute('data-ponyhoof-userscript-version', VERSION);
9697
9698 // CANLOG previously could be disabled before
9699 if (!userSettings.debug_disablelog) {
9700 CANLOG = true;
9701 }
9702
9703 // Load the language for the options link
9704 CURRENTLANG = LANG['en_US'];
9705 if (!userSettings.forceEnglish) {
9706 UILANG = getDefaultUiLang();
9707 if (!UILANG) {
9708 UILANG = 'en_US';
9709 } else {
9710 for (var i in LANG[UILANG]) {
9711 CURRENTLANG[i] = LANG[UILANG][i];
9712 }
9713 }
9714 }
9715
9716 // Inject Ponyhoof Options in the Account dropdown even when DOMNodeInserted is disabled
9717 onPageReady(function() {
9718 injectOptionsLink();
9719 domNodeHandlerMain.ponyhoofPageOptions({target: d.body});
9720 });
9721
9722 if (!runMe) {
9723 return;
9724 }
9725
9726 var luckyGuess = -1;
9727 if (!CURRENTPONY) {
9728 // If we have a "special" name, load the peferred theme for that character if we're in one
9729 try {
9730 getBronyName();
9731 for (var i = 0, len = PONIES.length; i < len; i += 1) {
9732 if (PONIES[i].users) {
9733 var lowercase = BRONYNAME.toLowerCase();
9734 for (var j = 0, jlen = PONIES[i].users.length; j < jlen; j += 1) {
9735 if (lowercase.indexOf(PONIES[i].users[j]) != -1) {
9736 // We got a match!
9737 CURRENTPONY = PONIES[i].code;
9738 luckyGuess = i;
9739 }
9740 }
9741 }
9742 }
9743 } catch (e) {
9744 error("Failed to get brony name");
9745 }
9746 }
9747
9748 // If we still don't have one, then assume none
9749 if (!CURRENTPONY) {
9750 CURRENTPONY = 'NONE';
9751 }
9752
9753 if ($('jewelFansTitle')) {
9754 ISUSINGPAGE = true;
9755 addClass(d.documentElement, 'ponyhoof_isusingpage');
9756 }
9757
9758 var logo = d.querySelector('#pageLogo > a[href*="/business/dashboard/"]');
9759 if (logo) {
9760 ISUSINGBUSINESS = true;
9761 addClass(d.documentElement, 'ponyhoof_isusingbusiness');
9762 }
9763
9764 // v1.401: Turn on new chat sound by default
9765 if (!userSettings.chatSound1401 && !userSettings.chatSound) {
9766 userSettings.chatSound = true;
9767 userSettings.chatSound1401 = true;
9768 saveSettings();
9769 }
9770
9771 // v1.501: Migrate previous randomSetting
9772 if (userSettings.randomSetting && !userSettings.randomSettingMigrated) {
9773 if (userSettings.randomSetting == 'mane6') {
9774 userSettings.randomPonies = 'twilight|dash|pinkie|applej|flutter|rarity';
9775 }
9776 userSettings.randomSettingMigrated = true;
9777 saveSettings();
9778 }
9779
9780 // v1.571
9781 userSettings.soundsVolume = Math.max(0, Math.min(parseFloat(userSettings.soundsVolume), 1));
9782
9783 // v1.601
9784 if (globalSettings.lastVersion < 1.6) {
9785 if (userSettings.customcss || userSettings.debug_dominserted_console || userSettings.debug_slow_load || userSettings.debug_disablelog || userSettings.debug_noMutationObserver || userSettings.debug_mutationDebug) {
9786 userSettings.debug_exposed = true;
9787 saveSettings();
9788 }
9789 }
9790
9791 // v1.511: Track updates
9792 if (userSettings.theme && globalSettings.lastVersion < VERSION) {
9793 statTrack('updated');
9794 globalSettings.lastVersion = VERSION;
9795 saveGlobalSettings();
9796 }
9797
9798 if (forceWhiteBackground || hasClass(d.body, 'plugin') || hasClass(d.body, 'transparent_widget')) {
9799 addClass(d.documentElement, 'ponyhoof_fbplugin');
9800 changeThemeSmart(CURRENTPONY);
9801 } else {
9802 // Are we on homepage?
9803 if (hasClass(d.body, 'fbIndex') && globalSettings.allowLoginScreen) {
9804 // Activate screen saver
9805 screenSaverActivate();
9806
9807 $$(d.body, '#blueBar .loggedout_menubar > .rfloat, ._50dz > .ptl[style*="#3B5998"] .rfloat > #login_form, ._50dz > div[style*="#3B5998"] td > div[style*="float"] #login_form, .-cx-PRIVATE-regCmsContainer__root > .ptl[style*="#3B5998"] .rfloat > #login_form, .-cx-PRIVATE-regCmsContainer__root > div[style*="#3B5998"] td > div[style*="float"] #login_form', function() {
9808 addClass(d.documentElement, 'ponyhoof_fbIndex_topRightLogin');
9809 });
9810 }
9811
9812 // No theme?
9813 if (userSettings.theme == null) {
9814 // No theme AND logged out
9815 if (!USERID) {
9816 changeTheme('login');
9817 log("Homepage is default to login.");
9818 extraInjection();
9819 if (!userSettings.disableDomNodeInserted) {
9820 runDOMNodeInserted();
9821 }
9822 return;
9823 }
9824
9825 if (globalSettings.runForNewUsers) {
9826 if (luckyGuess == -1) {
9827 CURRENTPONY = getRandomMane6();
9828 }
9829
9830 var welcome = new WelcomeUI({feature: luckyGuess});
9831 welcome.start();
9832 }
9833 } else {
9834 if (hasClass(d.body, 'fbIndex')) {
9835 if (CURRENTPONY == 'RANDOM' && !userSettings.randomPonies) {
9836 log("On login page and theme is RANDOM, choosing 'login'");
9837 changeThemeSmart('login');
9838 } else {
9839 changeThemeSmart(CURRENTPONY);
9840 }
9841
9842 var dat = convertCodeToData(REALPONY);
9843 if (dat.fbIndex_swf && !userSettings.disable_animation) {
9844 addClass(d.documentElement, 'ponyhoof_fbIndex_hasswf');
9845
9846 var swf = d.createElement('div');
9847 swf.innerHTML = '<object type="application/x-shockwave-flash" id="fbIndex_swf" width="100%" height="100%" data="'+THEMEURL+dat.fbIndex_swf+'"><param name="movie" value="'+THEMEURL+dat.fbIndex_swf+'"><param name="wmode" value="opaque"><param name="menu" value="false"><param name="allowscriptaccess" value="never"></object>';
9848 d.body.appendChild(swf);
9849 }
9850 } else {
9851 changeThemeSmart(CURRENTPONY);
9852 }
9853 }
9854 }
9855
9856 if (CURRENTPONY != 'NONE' && !userSettings.disableDomNodeInserted) {
9857 runDOMNodeInserted();
9858 }
9859
9860 if (CURRENTPONY != 'NONE') {
9861 extraInjection();
9862 }
9863
9864 // Record the last user to figure out what theme to load at login screen
9865 // This is low priority, if all else fails, we would just load the default Equestria 'login' anyway
9866 if (CURRENTPONY != 'NONE' && USERID && globalSettings.lastUserId != USERID) {
9867 globalSettings.lastUserId = USERID;
9868 saveGlobalSettings();
9869 }
9870 }
9871
9872 onPageReady(startScript);
9873 d.addEventListener('DOMContentLoaded', startScript, true);
9874
9875 var _loop = function() {
9876 if (d.body) {
9877 startScript();
9878 return;
9879 } else {
9880 w.setTimeout(_loop, 100);
9881 }
9882 };
9883 _loop();
9884 })();
9885
9886 /* ALL YOUR PONIES ARE BELONG TO US */
9887 /*eof*/