Jz Warlight

Adds extra filters for tournaments and dashboard games, including a fun filter that brings up a strange mix of games. Allows note-taking in games. A couple of easter eggs are also included.

当前为 2017-11-14 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Jz Warlight
  3. // @namespace https://greasyfork.org/en/users/44200-jz
  4. // @version 1.3.1
  5. // @grant none
  6. // @match https://www.warlight.net/*
  7. // @match https://www.warzone.com/*
  8. // @description Adds extra filters for tournaments and dashboard games, including a fun filter that brings up a strange mix of games. Allows note-taking in games. A couple of easter eggs are also included.
  9. // ==/UserScript==
  10.  
  11. main();
  12. function main() {
  13. try{
  14. setupSettings();
  15. var filter_setting = localStorage.getItem('setting_extra_filters');
  16. if(pageIsDashboard()) {
  17. if(filter_setting == 'true') {
  18. //$("#MyGamesFilter").append('<option value="0">Games that are active</option>');
  19. $("#MyGamesFilter").append('<option value="7">Games that are active or have unread chat messages</option>');
  20. $("#MyGamesFilter").append('<option value="3">Weird Filter (Non-Archived Games)</option>');
  21. }
  22. }
  23. if(pageIsTournaments()) {
  24. var muli_setting = localStorage.getItem('setting_enhance_muli');
  25. if(muli_setting == 'true') {
  26. // Add filters for tournaments, to expand the functionality Muli provided
  27. var filter = $('<select id="tournamentFilter" title="After updating the tournament data using Muli\'s script, pick a filter." style="float: right;margin: 0 10px;"/>');
  28. filter.append($('<option value="showAll">Show all</option>'));
  29. filter.append($('<option value="showGamesLeft">Tournaments with games left</option>'));
  30. filter.append($('<option value="showInProgress">Tournaments with games in progress</option>'));
  31. filter.append($('<option value="showNotEliminated">Tournaments that I am not eliminated from</option>'));
  32. filter.append($('<option value="showAlmostDone">Tournaments that are almost done</option>'));
  33. filter.append($('<option value="showCoin">Coin Tournaments</option>'));
  34. filter.on("change", function () {
  35. var selected = $( this ).val();
  36. var tds = $("td .tournamentData");
  37. for(var i = 0; i < tds.length; i++) {
  38. var td = tds[i];
  39. var parentTr = $(td).parent('tr');
  40. if(selected == "showAll") {
  41. parentTr.show();
  42. } else if(selected == "showGamesLeft") {
  43. if(td.innerHTML.indexOf('<font color="#858585">Games left:</font> None <br>') > 0) {
  44. parentTr.hide();
  45. } else {
  46. parentTr.show();
  47. }
  48. } else if(selected == "showInProgress") {
  49. if(td.innerHTML.indexOf('<font color="#858585">Playing:</font> 0 <br>') > 0) {
  50. parentTr.hide();
  51. } else if(td.innerHTML.indexOf('<font color="#858585">Playing:</font>') > 0) {
  52. parentTr.show();
  53. } else {
  54. parentTr.hide();
  55. }
  56. } else if(selected == "showNotEliminated") {
  57. // Show round robins, tournaments with games in progress, and tournaments with games left
  58. if(parentTr.html().indexOf('Round robin tournament') >= 0) {
  59. parentTr.show();
  60. } else if(td.innerHTML.indexOf('<font color="#858585">Playing:</font>') > 0
  61. && td.innerHTML.indexOf('<font color="#858585">Playing:</font> 0 <br>') == -1) {
  62. parentTr.show();
  63. } else if(td.innerHTML.indexOf('<font color="#858585">Games left:</font> None <br>') == -1) {
  64. parentTr.show();
  65. } else {
  66. parentTr.hide();
  67. }
  68. } else if(selected == "showAlmostDone") {
  69. if(td.innerHTML.indexOf('Almost done') > 0) {
  70. parentTr.show();
  71. } else {
  72. parentTr.hide();
  73. }
  74. } else if(selected == "showCoin") {
  75. if(parentTr.html().indexOf('https://d2wcw7vp66n8b3.cloudfront.net/Images/Coins/SmallCoins.png') != -1) {
  76. parentTr.show();
  77. } else {
  78. parentTr.hide();
  79. }
  80. }
  81. }
  82. });
  83. $("#MyTournamentsTable h2").after(filter);
  84. }
  85. }
  86. if(pageIsPastTournaments()) {
  87. if(filter_setting == 'true') {
  88. //$("#Filter").append('<option value="4">Actionable</option>');
  89. $("#Filter").append('<option value="5">Tournaments with unread chat</option>');
  90. //$("#Filter").append('<option value="6">Actionable or unread chat</option>');
  91. //$("#Filter").append('<option value="8">Not Complete that I joined</option>');
  92. }
  93. }
  94. if(pageIsGame()) {
  95. var note_setting = localStorage.getItem('setting_enable_notes');
  96. if(note_setting == 'true') {
  97. setupNotes();
  98. }
  99. }
  100. // Reimplement Alt tagging
  101. /*// Tag alts (alts retrieved from the library)
  102. for(var main_count = 0; main_count < mains.length; main_count++) {
  103. var main = mains[main_count];
  104. for(var alt_count = 0; alt_count < main.alts.length; alt_count++) {
  105. var alt = main.alts[alt_count];
  106. if(poster_id == alt) {
  107. var username = poster_cell.html();
  108. poster_cell.html(username + " (" + main.name + ")");
  109. }
  110. }
  111. }*/
  112. var today = new Date();
  113. var april_fools = today.getDate() == 1 && today.getMonth() == 3;
  114. if(april_fools) {
  115. aprilFools();
  116. }
  117. var troll_setting = localStorage.getItem('setting_troll_players');
  118. if(april_fools || troll_setting == 'true') {
  119. playerTrolls();
  120. }
  121. var extra_features = localStorage.getItem('setting_extra_features');
  122. if((april_fools || extra_features == 'true')) {
  123. extraFeatures();
  124. }
  125. } catch(err) {
  126. console.log(err);
  127. }
  128. }
  129.  
  130. function getPosterAnchor(tdCell) {
  131. var posterCell = tdCell.find('a[href*="/Profile?p="]').first();
  132. return posterCell;
  133. }
  134.  
  135. function getPosterId(posterCell) {
  136. if(posterCell !== undefined && posterCell != null){
  137. var postAuthor = posterCell.attr("href");
  138. if(postAuthor != null && postAuthor.length > 11) {
  139. return postAuthor.substring(11);
  140. }
  141. }
  142. return null;
  143. }
  144.  
  145. function flipLevel(level) {
  146. if(level.length == 1) {
  147. return level + "0";
  148. } else {
  149. return level.substring(1) + level.substring(0,1);
  150. }
  151. }
  152.  
  153. function setupSettings() {
  154. $("#AccountDropDown").parent().find("div .dropdown-divider").before('<div class="dropdown-item" id="jz-userscript-menu" style="cursor:pointer" data-toggle="modal" data-target="#settingsdialog">Jz\'s Userscript</div>');
  155. var modalhtml = ''
  156. modalhtml += '<div class="modal" tabindex="-1" role="dialog" id="settingsdialog">'
  157. modalhtml += ' <div class="modal-dialog" role="document">'
  158. modalhtml += ' <div class="modal-content">'
  159. modalhtml += ' <div class="modal-header" style="color:#b3b081;background-color:#330000;height:40px">'
  160. modalhtml += ' <h5 class="modal-title">Settings (Automatically Saved)</h5>'
  161. modalhtml += ' <button type="button" class="close" data-dismiss="modal" aria-label="Close">'
  162. modalhtml += ' <span aria-hidden="true" style="color:#b3b081">&times;</span>'
  163. modalhtml += ' </button>'
  164. modalhtml += ' </div>'
  165. modalhtml += ' <div class="modal-body" id="settingsbody" style="color:#b3b081;background-color:#171717">'
  166. modalhtml += ' </div>'
  167. modalhtml += ' </div>'
  168. modalhtml += ' </div>'
  169. modalhtml += '</div>'
  170. var settings_modal=$(modalhtml)
  171. $('body').append(settings_modal)
  172.  
  173. var settings_body = $("#settingsbody")
  174. addSetting(settings_body, "Enable Note Taking", "setting_enable_notes", "true", "Allow note taking in games");
  175. addSetting(settings_body, "Add extra filters", "setting_extra_filters", "true", "Add extra filters to the dashboard and past tournaments pages");
  176. addSetting(settings_body, "Add features to enhance Muli's userscript", "setting_enhance_muli", "true", "If muli's script is installed, add features to enhance it.");
  177. addSetting(settings_body, "Enable Special Features (fun feature)", "setting_extra_features", "false", "Enable the secret easter egg features");
  178. addSetting(settings_body, "Allow Audio Features (fun feature)", "setting_audio_features", "false", "Enable the secret easter egg features that use audio");
  179. addSetting(settings_body, "Player Trolls (fun feature)", "setting_troll_players", "false", "Enable features that troll certain players (including yourself, if relevant).");
  180. }
  181.  
  182. function addSetting(settings_dialog, label, id, default_val, title) {
  183. var setting_header = $('<label for="setting_' + id + '" title="' + title + '">' + label + '</label>');
  184. var setting = $('<input type="checkbox" id="setting_' + id + '"/>');
  185. settings_dialog.append(setting);
  186. settings_dialog.append(setting_header);
  187. settings_dialog.append($('<br/>'));
  188. var stored_value = localStorage.getItem(id);
  189. if(stored_value == null) {
  190. stored_value = default_val;
  191. localStorage.setItem(id, default_val);
  192. }
  193. if(stored_value == 'true') {
  194. setting.prop('checked', true);
  195. }
  196. setting.on('change', function() {
  197. if(setting.prop('checked')) {
  198. localStorage.setItem(id, 'true');
  199. } else {
  200. localStorage.setItem(id, 'false');
  201. }
  202. });
  203. }
  204.  
  205. /**
  206. * Create a CSS selector
  207. * Taken from Muli's Userscript and renamed from createSelector (to avoid conflict): https://greasyfork.org/en/scripts/8936-tidy-up-your-dashboard
  208. * @param name The name of the object, which the rules are applied to
  209. * @param rules The CSS rules
  210. */
  211. function addStyle(name, rules) {
  212. var style = document.createElement('style');
  213. style.type = 'text/css';
  214. document.getElementsByTagName('head')[0].appendChild(style);
  215. if (!(style.sheet || {}).insertRule) {
  216. (style.styleSheet || style.sheet).addRule(name, rules);
  217. } else {
  218. style.sheet.insertRule(name + "{" + rules + "}", 0);
  219. }
  220. }
  221.  
  222. function setupNotes() {
  223. // Create the minimized notes
  224. var modalhtml = ''
  225. modalhtml += '<div class="panel" tabindex="-1" id="notesdialogmini">'
  226. modalhtml += ' <div class="modal-dialog" role="document" style="border: 2px solid;border-radius: 5px;max-width:100px;position:fixed;bottom:0px;right:0px;margin:0px;padding:0px">'
  227. modalhtml += ' <div class="modal-content" style="color:#b3b081">'
  228. modalhtml += ' <div class="modal-header" id="notesheadermini" style="border:0px;color:#b3b081;background-color:#330000;padding:5px;height:15px">'
  229. modalhtml += ' <span aria-hidden="true" id="notesopen" style="cursor:pointer;font-size:x-small">Notes</span>'
  230. modalhtml += ' </div>'
  231. modalhtml += ' </div>'
  232. modalhtml += ' </div>'
  233. modalhtml += '</div>'
  234. var notes_modal2=$(modalhtml)
  235. $('body').append(notes_modal2)
  236. // Create the popup for the notes
  237. var modalhtml = ''
  238. modalhtml += '<div class="panel" tabindex="-1" id="notesdialog">'
  239. modalhtml += ' <div class="modal-dialog" role="document" style="max-width:340px;position:fixed;bottom:0px;right:0px;margin:0px">'
  240. modalhtml += ' <div class="modal-content">'
  241. modalhtml += ' <div class="modal-header" id="notesheader" style="color:#b3b081;background-color:#330000;height:35px">'
  242. modalhtml += ' <h5 class="modal-title">Notes</h5>'
  243. modalhtml += ' <button type="button" class="close" id="notesminimize" aria-label="Minimize">'
  244. modalhtml += ' <span aria-hidden="true" style="color:#b3b081">-</span>'
  245. modalhtml += ' </button>'
  246. modalhtml += ' </div>'
  247. modalhtml += ' <div class="modal-body" id="notesbody" style="color:#b3b081;background-color:#171717">'
  248. modalhtml += ' <textarea id="GameNotes" rows="4" cols="30"/>'
  249. modalhtml += ' </div>'
  250. modalhtml += ' </div>'
  251. modalhtml += ' </div>'
  252. modalhtml += '</div>'
  253. var notes_modal=$(modalhtml)
  254. notes_modal.hide();
  255. $('body').append(notes_modal)
  256. // Add the notes header to the Multi-Player Menu
  257. var notesHeader = $('<div class="dropdown-item" id="NotesHeader" style="cursor:pointer">Notes</div>');
  258. $("#CreateGameLink").after(notesHeader);
  259. // Setup note display events
  260. notesHeader.on('click', function() {
  261. notes_modal.show();
  262. notes_modal2.hide();
  263. });
  264. var notes_minimize=$("#notesminimize")
  265. notes_minimize.on('click', function() {
  266. notes_modal.hide();
  267. notes_modal2.show();
  268. });
  269. var notes_open=$("#notesopen")
  270. notes_open.on('click', function() {
  271. notes_modal.show();
  272. notes_modal2.hide();
  273. });
  274. // Parse the gameid
  275. var gameid = getGameID();
  276.  
  277. // Create the events
  278. // Save the note automatically
  279. var gameNotes = $("#GameNotes")
  280. gameNotes.on('change', function() {
  281. saveNote(gameNotes, gameid);
  282. });
  283.  
  284. // Populate the notes field and set the background color for the notes
  285. var notes = getNotesFromStorage();
  286. var note = notes[gameid];
  287. if(note != null && note.value != null && note.value.length > 0) {
  288. gameNotes.val(note.value);
  289. notes_modal.show();
  290.  
  291. // Resaving it updates the timestamp
  292. saveNote(gameNotes, gameid);
  293. }
  294. colorNotesHeader(gameNotes);
  295. }
  296.  
  297. function getGameID() {
  298. var gameid = location.href.substring(location.href.indexOf('GameID=') + 7)
  299. if(gameid.indexOf('&') > 0) {
  300. gameid = gameid.substring(0, gameid.indexOf('&'));
  301. }
  302. return gameid;
  303. }
  304.  
  305. function getNotesFromStorage() {
  306. var notesString = localStorage.getItem("notes");
  307. if(notesString != null) {
  308. return JSON.parse(notesString);
  309. } else {
  310. return {};
  311. }
  312. }
  313.  
  314. function saveNotesToStorage(notes) {
  315. localStorage.setItem("notes", JSON.stringify(notes));
  316. }
  317.  
  318. function saveNote(gameNotes, gameid) {
  319. var notes = getNotesFromStorage();
  320. var note = notes[gameid];
  321. if(note == null) {
  322. note = {};
  323. }
  324. note.date = new Date();
  325. note.value = gameNotes.val();
  326. notes[gameid] = note;
  327. if(note.value == null || note.value.length == 0) {
  328. delete notes[gameid];
  329. }
  330. //alert(JSON.stringify(notes));
  331. saveNotesToStorage(notes);
  332. colorNotesHeader(gameNotes);
  333. }
  334.  
  335. function colorNotesHeader(gameNotes) {
  336. var notesHeader = $("#NotesHeader")
  337. var miniNotesHeader = $("#notesheadermini")
  338. miniNotesHeader.css('font-style','normal');
  339. var color = "";
  340. if(gameNotes.val() != null && gameNotes.val().length > 0) {
  341. color = '#FFAA00';
  342. miniNotesHeader.css('font-style','italic');
  343. }
  344. notesHeader.css('color',color);
  345. }
  346.  
  347. function pageIsDashboard() {
  348. return location.href.match(/.*warzone[.]com\/MultiPlayer\/#?$/i);
  349. }
  350.  
  351. function pageIsTournaments() {
  352. return location.href.match(/.*warzone[.]com\/MultiPlayer\/Tournaments\/$/i);
  353. }
  354.  
  355. function pageIsPastTournaments() {
  356. return location.href.match(/.*warzone[.]com\/MultiPlayer\/Tournaments\/Past/i);
  357. }
  358.  
  359. function pageIsGame() {
  360. return location.href.match(/.*warzone[.]com\/MultiPlayer\?GameID=/i);
  361. }
  362.  
  363. function pageIsForum() {
  364. return location.href.match(/.*warzone[.]com\/Forum/i);
  365. }
  366.  
  367. // "Troll" content below
  368. function aprilFools() {
  369. var level = $('#LevelLink i').html().substring(1);
  370. var newlevel = flipLevel(level)
  371. if(level != null) {
  372. $('#LevelLink i').html("L" + newlevel);
  373. }
  374. var headers = $("#navbarSupportedContent ul li");
  375. if(headers) {
  376. headers.each(function(i, header) {
  377. var anchor = $(header).find("a").first();
  378. anchor.text(anslatetray(anchor.text()));
  379. });
  380. }
  381. if(pageIsForum()) {
  382. var firstpost = $($("#PostTbl_0").find("td")[1]).find("div");
  383. var postcontent = firstpost.html();
  384. firstpost.html(anslatetray(postcontent))
  385. var forumPosts = $("[id^=PostTbl]");
  386. for(var i = 0; i < forumPosts.length; i++) {
  387. var post = forumPosts[i];
  388. var tds = $(post).find("td");
  389. var tdCell = $(post).find("td:first");
  390. var poster_cell = getPosterAnchor(tdCell);
  391. var poster_id = getPosterId(poster_cell);
  392. if(poster_id != null) {
  393. if(tdCell.html() != null && poster_id != null) {
  394. var levelstart = tdCell.html().indexOf('Level');
  395. if(levelstart > 0) {
  396. var level = tdCell.html().substring(levelstart+6, levelstart + 8).trim();
  397. var newlevel = flipLevel(level);
  398. tdCell.html(tdCell.html().replace('Level ' + level, 'Level ' + newlevel));
  399. }
  400. }
  401. }
  402. };
  403. //MOTD
  404. changeAvatar('2428496679', "http://icons.iconarchive.com/icons/giannis-zographos/english-football-club/256/Liverpool-FC-icon.png");
  405. // Styx
  406. changeAvatar('1552135718', "https://lh3.googleusercontent.com/-iDzlv7IG4rY/AAAAAAAAAAI/AAAAAAACsik/FnDXDKxLt5I/s0-c-k-no-ns/photo.jpg");
  407. }
  408. var date = new Date();
  409. if(date.getMilliseconds() <= 50) {
  410. $("#MailImgNormal").hide();
  411. $("#MailImgFlashing").show();
  412. $("#MailLink").attr("href", "https://www.warlight.net/Forum/154263-troll-awards-war-begins");
  413. return true;
  414. }
  415. }
  416.  
  417. // Change avatars and give profile theme songs
  418. function playerTrolls() {
  419. var today = new Date();
  420. if(pageIsForum()) {
  421. if(today.getMonth() == 6 && today.getFullYear() == 2017) {
  422. // MOTD
  423. changeAvatar('2428496679', "https://hdlogo.files.wordpress.com/2011/11/real-salt-lake-city-hd-logo.png");
  424. // Styx
  425. changeAvatar('1552135718', "https://hdlogo.files.wordpress.com/2011/11/real-salt-lake-city-hd-logo.png");
  426. }
  427. // Nero
  428. changeAvatar('397429597', "https://lh3.googleusercontent.com/-iDzlv7IG4rY/AAAAAAAAAAI/AAAAAAACsik/FnDXDKxLt5I/s0-c-k-no-ns/photo.jpg");
  429. }
  430. var audio_features = localStorage.getItem('setting_audio_features');
  431. // Platinum
  432. if(location.href.match(/.*warzone[.]com\/Profile\?p=6559504553/i)
  433. || location.href.match(/.*warzone[.]com\/Profile\?p=5550827655/i)) {
  434. addThemeSongToProfile(audio_features, "8Gv0H-vPoDc");
  435. }
  436. //After Dark
  437. replaceClanIcon("155", "http://static.skaip.org/img/emoticons/180x180/f6fcff/poop.gif", 18, 18);
  438. }
  439.  
  440. // Other extra features, such as changed titles.
  441. function extraFeatures() {
  442. var audio_features = localStorage.getItem('setting_audio_features');
  443. try{
  444. var hiddenThreads = $('tr#HiddenThreadsRow').first().find("font:first");
  445. if(hiddenThreads!= null && hiddenThreads.text().match(/[54]\d hidden threads/i) != null) {
  446. lotsOfHiddenThreads(hiddenThreads);
  447. }
  448. } catch (e) {
  449. alert(e);
  450. }
  451. var profilelink = $('a[href*="/Profile?p="]').first();
  452. var linkhref = profilelink.attr("href");
  453. var profid = linkhref.substring(linkhref.indexOf("=")+1);
  454. var date = new Date();
  455. var day = date.getDay();
  456. if(date.getHours() >= 0 && date.getHours() <=2) {
  457. changeProfile("Sleep is for the weak", null, null);
  458. return true;
  459. } else if(date.getHours() > 2 && date.getHours() <= 5) {
  460. changeProfile("Seriously, why are you awake at this hour?", null, null);
  461. return true;
  462. }
  463.  
  464. if(profid == '2214950915') {
  465. if(day = 2) {
  466. changeProfile('Master of Disaster', null, '0');
  467. } else if(day == 3) {
  468. changeProfile('Elitist', 'L99', '999999');
  469. }
  470. } else if(profid == '6319040229') {
  471. if(day == 2) {
  472. changeProfile('Jefferspoon', null, '-35');
  473. }
  474. if((day == 6)) {
  475. if(date.getMilliseconds() < 50) {
  476. var player2 = document.createElement("iframe");
  477. player2.setAttribute("src", "https://www.youtube.com/embed/jsduOOI_EGE?autoplay=1&autohide=1&border=0&wmode=opaque&enablejsapi=1");
  478. player2.width = 5;
  479. player2.height = 5;
  480. document.body.appendChild(player2);
  481. }
  482. }
  483. } else if(profid == '2428496679') {
  484. if(day == 2) {
  485. changeProfile('Miles Edgeworth', 'L59', null);
  486. } else if(day == 3) {
  487. changeProfile('Mercer', 'L31', null);
  488. } else if(day == 1) {
  489. changeProfile(null, 'L61', null);
  490. }
  491. } else if(profid == '9911415828') {
  492. if(day == 2) {
  493. changeProfile('Master Sephiroth', 'L1', '180479');
  494. }
  495. }
  496. return false;
  497.  
  498. }
  499.  
  500. function changeProfile(username, level, coins) {
  501. if(username != null) {
  502. $('#AccountDropDown').first().html(username);
  503. }
  504. if(level != null) {
  505. $('#LevelLink i').html(level);
  506. }
  507. if(coins != null) {
  508. var coinsobj = $('#CoinsText');
  509. //coins.html(coins.html() * 100);
  510. coinsobj.html(coins);
  511. }
  512. }
  513.  
  514. function changeAvatar(player, src) {
  515. var selector = 'a[href*="/Profile?p=' + player + '"]';
  516. var player_as = $(selector);
  517. for(var i = 0; i < player_as.length; i++) {
  518. var link = $(player_as[i]);
  519. var tdCell = link.parent();
  520. if(tdCell.is('TD')) {
  521. var image1 = $(tdCell).find("img:first");
  522. if(image1 != null && image1.attr('src').indexOf('https://s3.amazonaws.com/data.warlight.net/Data/Players') == 0) {
  523. image1.attr('src', src);
  524. } else {
  525. tdCell.prepend('<br/><img src="' + src + '" border="0" width="50" height="50" />');
  526. }
  527. }
  528. }
  529. }
  530.  
  531. function replaceClanIcon(clanId, url, width, height) {
  532. var selector = 'a[href*="/Clans/?ID=' + clanId + '"]';
  533. var icon_as = $(selector);
  534. for(var i = 0; i < icon_as.length; i++) {
  535. var icon_a = $(icon_as[i]);
  536. var img = icon_a.find("img")[0];
  537. img.src = url;
  538. img.width = width;
  539. img.height = height;
  540. }
  541. }
  542.  
  543. function lotsOfHiddenThreads(hiddenThreads) {
  544. var hiddenrow = $('tr#HiddenThreadsRow').first();
  545. var audio_features = localStorage.getItem('setting_audio_features');
  546. if(audio_features == 'true') {
  547. var player2 = document.createElement("iframe");
  548. player2.setAttribute("src", "https://www.youtube.com/embed/zq7Eki5EZ8o?autoplay=1&autohide=1&border=0&wmode=opaque&enablejsapi=1");
  549. player2.width = 60;
  550. player2.height = 40;
  551. hiddenThreads.append(player2);
  552. } else {
  553. var player2 = document.createElement("div");
  554. $(player2).html("<a href=\"https://www.youtube.com/watch?v=zq7Eki5EZ8o\">Can't nothin bring me shame</a>");
  555. hiddenThreads.append(player2);
  556. }
  557. }
  558.  
  559. function addThemeSongToProfile(audio_features, youtube_link) {
  560. if(audio_features == 'true') {
  561. var player2 = document.createElement("iframe");
  562. player2.setAttribute("src", "https://www.youtube.com/embed/" + youtube_link + "?autoplay=1&autohide=1&border=0&wmode=opaque&enablejsapi=1");
  563. player2.width = 5;
  564. player2.height = 5;
  565. document.body.append(player2);
  566. }
  567. var theme = document.createElement("small");
  568. $(theme).html("<br/><span>Theme Song: </span><a href=\"https://www.youtube.com/watch?v=" + youtube_link + "\">https://www.youtube.com/watch?v=" + youtube_link + "</a><span></span>");
  569. $("big").append(theme);
  570. }
  571.  
  572. function anslatetray(post) {
  573. var new_post = "";
  574. var suffix = "";
  575. var suffix_end = false;
  576. var chars = post.split('');
  577. var open_br = false;
  578. var capital = false;
  579. for(var i = 0; i < chars.length; i++) {
  580. var character = chars[i];
  581. if(character == ">") {
  582. open_br = false;
  583. new_post += character;
  584. } else if(character == "<") {
  585. open_br = true;
  586. if(suffix != "") {
  587. new_post += suffix + "ay";
  588. suffix = "";
  589. suffix_end = false;
  590. }
  591. new_post += character;
  592. } else if(open_br) {
  593. new_post += character;
  594. } else if(character.match(/[a-zA-Z]/g) == null) {
  595. if(suffix != "") {
  596. new_post += suffix + "ay";
  597. suffix = "";
  598. }
  599. suffix_end = false;
  600. new_post += character;
  601. } else if(suffix_end) {
  602. new_post += character;
  603. } else if(character.match(/[aeiouAEIOU]/g) != null) {
  604. suffix_end = true;
  605. if(capital) {
  606. new_post += character.toUpperCase();
  607. } else {
  608. new_post += character;
  609. }
  610. if(suffix == '') {
  611. suffix += 'w'
  612. }
  613. } else {
  614. if(suffix == "") {
  615. if(character.match(/[A-Z]/g) != null) {
  616. capital = true;
  617. suffix += character.toLowerCase();
  618. } else {
  619. capital = false;
  620. suffix += character;
  621. }
  622. } else {
  623. suffix += character;
  624. }
  625. }
  626. }
  627. if(suffix != "") {
  628. new_post += suffix + "ay";
  629. suffix = "";
  630. }
  631. return new_post;
  632. }