STS Helper

In Steam Translation Server, add many features to make translate easier.

目前为 2016-05-17 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name STS Helper
  3. // @namespace iFantz7E.StsHelper
  4. // @version 1.76
  5. // @description In Steam Translation Server, add many features to make translate easier.
  6. // @match *://translation.steampowered.com/*
  7. // @icon http://translation.steampowered.com/public/favicon.ico
  8. // @run-at document-start
  9. // @grant GM_getValue
  10. // @grant GM_setValue
  11. // @grant GM_addStyle
  12. // @copyright 2014, 7-elephant
  13. // ==/UserScript==
  14.  
  15. // http://userscripts.org/scripts/show/325610
  16. // https://greasyfork.org/scripts/2250-sts-helper/
  17.  
  18. GM_addStyle(
  19. " #logout { position: fixed; z-index: 1001; right: 12px; top: 10px; line-height: 24px; text-align: right; } "
  20. + "input[type='button'], input[type='submit'] { cursor: pointer; } "
  21. + "input[type='button']:disabled { cursor: default; color: #777; } "
  22. + "#suggestionmain { overflow-x: hidden; } "
  23. + "#suggestionmain > div:nth-child(4) > form:nth-child(2) > div:nth-child(1) "
  24. + " { text-align: left; } "
  25. + ".lbAction > div > input[value^='SUBMIT'] "
  26. + " { width: 97%; height: 30px; } "
  27. + "form.lbAction:nth-child(1) > div:nth-child(2) > input:nth-child(1) "
  28. + " { width: 90%; margin-top: 5px; } "
  29. + "div.suggestion form.lbAction textarea"
  30. + " { width: 700px !important; min-height: 50px; } "
  31. + ".progress td { vertical-align: top; } "
  32. + "div#suggestions_nav { z-index: 3; position: absolute; width: 525px; left: 463px; top: 4px; text-align: right; line-height: 24px; } "
  33. + "#suggestionmain .smallcopy { width: 855px; min-height: 70px; max-height: 70px; overflow: hidden; } "
  34. + "#suggestionmain .progress { margin-top: -12px; } "
  35. + "#leftAreaContainer > table > tbody:nth-child(1) > tr > td:nth-child(1) { vertical-align: top; } "
  36. + "#leftAreaContainer > table, #leftAreaContainer > table th, #leftAreaContainer > table td "
  37. + " { border: 1px solid #333; border-collapse: collapse; padding: 4px; } "
  38. + "#suggestions_box { margin-top: 1px !important; } "
  39. + "#suggestions_iframe { min-height: 100px !important; } "
  40. + "#keylist td:nth-child(1) > div { background-image: none !important; min-height: 43px; } "
  41. + "#keylist tr:nth-child(2n) > td:nth-child(1) > div { background-color: #060606 !important; } "
  42. + "#keylist tr:nth-child(2n) > td:nth-child(1) > div:hover { background-color: #0D0D0D !important; } "
  43. + "#keylist td:nth-child(1) > div:hover "
  44. + " { background-repeat: no-repeat; background-position: center; background-color: #0D0D0D !important; "
  45. + " background-image: url('./public/images/row_over.gif') !important; "
  46. + " } "
  47. + ".progress h1 { display: inline-block; width: 484px; } "
  48. + "div#suggestions_box iframe { background-color: #111 !important; } "
  49. + ".suggestions_list { border-right: 0px none !important; } "
  50. + ".suggestion { resize: both; overflow: hidden; border-right: 1px solid #505050; } "
  51. + ".suggestion_signature { font-family: Verdana; } "
  52. + ".suggestion_signature input[value~='APPROVE'], .suggestion_signature input[value~='Next'] { color: #A4B23C } "
  53. + ".suggestion_signature input[value~='DECLINE'], .suggestion_signature input[value~='Next']:nth-child(5) { color: #F22 } "
  54. + ".suggestion_signature input[disabled='disabled'] { color: #777 !important; } "
  55. + ".lbAction input[value~='COMMENT'] { vertical-align: top; margin-top: 1px; height: 52px; } "
  56. + ".lbAction input[value~='DISCUSS'] { vertical-align: top; margin-top: 1px; height: 36px; } "
  57. + "#votes_container a[title='not translated'] { background-color: #333; } "
  58. + ".stsh_btn { width: 90px; } "
  59. + ".stsh_btn_med { min-width: 112px; } "
  60. + ".stsh_btn_long { min-width: 136px; } "
  61. + ".stsh_btn_short { min-width: 66px; } "
  62. + ".stsh_btn_right { position: relative; float: right; } "
  63. + ".stsh_suggestion_header { color: #A4B23C; } "
  64. + ".stsh_suggestion_comment:before { background-color: #CF8B37 !important; } "
  65. + ".stsh_suggestion_pending:before { background-color: #FFF !important; } "
  66. + ".stsh_suggestion_approved:before { background-color: #A4B23C !important; } "
  67. + ".stsh_suggestion_declined:before { background-color: red !important; } "
  68. + ".stsh_suggestion_applied:before { background-color: #2EBCEB !important; } "
  69. + ".stsh_suggestion_removed:before { background-color: #555 !important; } "
  70. + ".stsh_suggestion { list-style: none; } "
  71. + ".stsh_suggestion:before "
  72. + " { content: ''; display: inline-block; position: relative; height: 6px; width: 6px; "
  73. + " border-radius: 3px; background-clip: padding-box; margin-right: -6px; top: -1px; left: -12px; background-color: green; }"
  74. + "#stsh_frame { text-align: center; } "
  75. + ".stsh_blue { color: #2ebceb; } "
  76. + ".stsh_green { color: #a4b23c; } "
  77. + ".stsh_red { color: #F00; } "
  78. + ".stsh_white { color: #fff; } "
  79. + ".stsh_orange { color: #CF8B37; } "
  80. + ".stsh_pink { color: pink; } "
  81. + "#stsh_showing { color: #CCDAD6; position: fixed; z-index: 1001; right: 12px; bottom: 12px; text-align: right; line-height: 14px;} "
  82. + "#stsh_showing_current { color: #CCDAD6; position: fixed; z-index: 1001; right: 12px; bottom: 28px; text-align: right; line-height: 14px;} "
  83. + ".stsh_showing_counter { display: inline-block; min-width: 60px; text-align: center; } "
  84. + ".stsh_showing_header { color: #CCDAD6; display: inline-block; width: 135px; text-align: center; padding-top: 10px; } "
  85. + ".stsh_showing_group { position: fixed; z-index: 3; right: 10px; top: 74px; line-height: 24px; text-align: right; } "
  86. + ".stsh_home_header { color: #CCDAD6; display: inline-block; padding-top: 10px; } "
  87. + ".stsh_home_group { position: fixed; z-index: 3; right: 0px; top: 74px; line-height: 24px; text-align: center; width: 164px; } "
  88. + ".stsh_scroll_header { color: #CCDAD6; display: inline-block; width: 130px; text-align: center; padding-top: 10px; } "
  89. + "#stsh_specialEvent { position: absolute; z-index: 2; right: 164px; top: 11px; } "
  90. + ".stsh_snapshot { position: absolute; top: 320px; left: 790px; width: 140px; text-align: center; color: #FFF; } "
  91. + ".stsh_submit_comment_header { vertical-align: top; } "
  92. + ".stsh_submit_comment { vertical-align: top; display: inline-block } "
  93. + ".stsh_insert_space { margin: 10px; } "
  94. + "#stsh_autoApprove { vertical-align: -2px; margin-left: 15px; margin-right: 1px; } "
  95. + ".stsh_unselectable { -webkit-user-select: none; -moz-user-select: none; user-select: none; } "
  96. + ".stsh_a_button "
  97. + " { background-color: #1D1D1D; font-family: tahoma,arial,helvetica,trebuchet ms,sans-serif; "
  98. + " color: #E1E1E1; font-size: 13px; border: 1px solid #777; padding: 1px 9px; } "
  99. + ".stsh_a_button:link, .stsh_a_button:hover, .stsh_a_button:active, .stsh_a_button:visited { color: #E1E1E1; text-decoration: none; } "
  100. + ".stsh_a_button.stsh_btn { display: inline-block; padding: 0px; height: 19px; line-height: 19px; width: 88px; } "
  101. + ".stsh_a_button.stsh_btn_med { display: inline-block; padding: 0px; height: 19px; line-height: 19px; min-width: 110px; } "
  102. + ".stsh_a_button.stsh_btn_long { display: inline-block; padding: 0px; height: 19px; line-height: 19px; min-width: 134px; } "
  103. + ".stsh_lineCounter_outer { position: relative; } "
  104. + ".stsh_lineCounter "
  105. + " { position: absolute; width: 30px; left: -35px; top: -28px; line-height: 28px; text-align: right; "
  106. + " color: #ACACAC; font-size: 9px; } "
  107. + ".stsh_glossary_term { min-width: 50px; display: inline-block; } "
  108. + ".stsh_glossary_header, .stsh_glossary_header td { color: #DDD; } "
  109. + ".stsh_glossary_header *, .stsh_glossary_header td * { color: #858585; } "
  110. + ".stsh_time_convert { cursor: pointer; } "
  111. + ".stsh_comment_img "
  112. + " { display: block; cursor: zoom-in; cursor: -webkit-zoom-in; cursor: -moz-zoom-in; "
  113. + " max-width: 400px; margin-top: 5px; margin-bottom: 20px; } "
  114. );
  115.  
  116. function attachOnLoad(callback)
  117. {
  118. window.addEventListener("load", function (e)
  119. {
  120. callback();
  121. });
  122. }
  123.  
  124. function attachOnReady(callback)
  125. {
  126. document.addEventListener("DOMContentLoaded", function (e)
  127. {
  128. callback();
  129. });
  130. }
  131.  
  132. function insertBeforeElement(newNode, referenceNode)
  133. {
  134. referenceNode.parentNode.insertBefore(newNode, referenceNode);
  135. }
  136.  
  137. function insertAfterElement(newNode, referenceNode)
  138. {
  139. referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
  140. }
  141.  
  142. function addKeyCtrl(ele, input, keyCode, keyName)
  143. {
  144. if (ele != null && input != null)
  145. {
  146. //if (input.getAttribute("disabled") == null)
  147. // return;
  148. if (keyName != null && keyName != "")
  149. {
  150. input.value += " (Ctrl+" + keyName + ")";
  151. }
  152. ele.addEventListener("keydown", function (e)
  153. {
  154. if (e.ctrlKey)
  155. {
  156. var isSameKey = false;
  157. if (Number.isInteger(keyCode))
  158. {
  159. isSameKey = (e.keyCode == keyCode);
  160. }
  161. else
  162. {
  163. isSameKey = (e.code != undefined && e.code == keyCode)
  164. }
  165. if (isSameKey)
  166. {
  167. input.focus();
  168. input.click();
  169. return false;
  170. }
  171. }
  172. }, true);
  173. }
  174. }
  175.  
  176. function addKeyAlt(ele, input, keyCode, keyName)
  177. {
  178. if (ele != null && input != null)
  179. {
  180. if (keyName != null && keyName != "")
  181. {
  182. input.value += " (Alt+" + keyName + ")";
  183. }
  184. ele.addEventListener("keydown", function (e)
  185. {
  186. if (e.altKey)
  187. {
  188. var isSameKey = false;
  189. if (Number.isInteger(keyCode))
  190. {
  191. isSameKey = (e.keyCode == keyCode);
  192. }
  193. else
  194. {
  195. isSameKey = (e.code != undefined && e.code == keyCode)
  196. }
  197. if (isSameKey)
  198. {
  199. input.focus();
  200. input.click();
  201. return false;
  202. }
  203. }
  204. }, true);
  205. }
  206. }
  207.  
  208. function addKeyCtrlEnter(form, input)
  209. {
  210. addKeyCtrl(form, input, 13, "Enter")
  211. }
  212.  
  213. function disableAfterClick(ele)
  214. {
  215. ele.addEventListener("click", function (e)
  216. {
  217. var ele = e.target;
  218. var tagName = ele.tagName.toLowerCase();
  219. if (tagName == "input")
  220. {
  221. // don't change color after disable
  222. ele.style.setProperty("color"
  223. , window.getComputedStyle(ele).color, "important");
  224. ele.disabled = true;
  225. }
  226. else if (tagName == "img")
  227. {
  228. ele.removeAttribute("onclick");
  229. }
  230. }, true);
  231. }
  232.  
  233. function resizeSuggestionBox()
  234. {
  235. var script = document.createElement('script');
  236. script.innerHTML = " \
  237. var stsh_showSuggestionsBox_start = new Date(); \
  238. var stsh_showSuggestionsBox_itv = setIntervalCustom(function() \
  239. { \
  240. var stsh_showSuggestionsBox_isEnd = false; \
  241. var stsh_showSuggestionsBox_cur = new Date(); \
  242. if (typeof showSuggestionsBox != 'undefined') \
  243. { \
  244. showSuggestionsBox = function(url) \
  245. { \
  246. g_suggestionsBoxIsOpen = true; \
  247. $('suggestions_box_outer').appear( \
  248. { \
  249. duration : 0.1 \
  250. } \
  251. ); \
  252. $('suggestions_iframe').setAttribute('src', url); \
  253. if (!Prototype.Browser.IE) \
  254. { \
  255. $('suggestions_iframe').focus(); \
  256. } \
  257. $('suggestions_iframe').style.height = (document.viewport.getHeight() * 0.99) + 'px'; \
  258. return false; \
  259. }; \
  260. stsh_showSuggestionsBox_isEnd = true; \
  261. } \
  262. if (stsh_showSuggestionsBox_isEnd || stsh_showSuggestionsBox_cur - stsh_showSuggestionsBox_start > 10000) \
  263. { \
  264. clearInterval(stsh_showSuggestionsBox_itv); \
  265. } \
  266. }, 300); \
  267. ";
  268. document.head.appendChild(script);
  269.  
  270. window.addEventListener("resize", function()
  271. {
  272. var iframe = document.querySelector("#suggestions_iframe");
  273. iframe.style.height = (window.innerHeight * 0.99) + "px";
  274. });
  275. }
  276.  
  277. function getQueryByName(name, url)
  278. {
  279. if (url == null)
  280. url = location.search;
  281. name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
  282. var regex = new RegExp("[\\?&]" + name + "=([^&#]*)");
  283. var results = regex.exec(url);
  284. var retVal = "";
  285. if (results != null)
  286. {
  287. retVal = results[1].replace(/\+/g, " ");
  288. try
  289. {
  290. retVal = decodeURIComponent(retVal);
  291. }
  292. catch (ex)
  293. {
  294. }
  295. }
  296. return retVal;
  297. }
  298.  
  299. function padZero(num, size)
  300. {
  301. return (1e15+num+"").slice(-size);
  302. }
  303.  
  304. function checkSpecialCharMatched(str1, str2)
  305. {
  306. // return (status, numSp1, numSp2)
  307. // status: 0:Match, 1:NotMatch, 2:NotEqual
  308. var sp1 = "";
  309. var sp2 = "";
  310. var sp3 = "";
  311. var sp4 = "";
  312. var sp5 = "";
  313. var sp6 = "";
  314. var sp7 = "";
  315. var sp8 = "";
  316. var strOut1 = "";
  317. var strOut2 = "";
  318. if (str1 != null && str2 != null)
  319. {
  320. for (var i = 0; i < str1.length; i++)
  321. {
  322. if (str1[i] == sp1 || str1[i] == sp2 || str1[i] == sp3 || str1[i] == sp4
  323. || str1[i] == sp5 || str1[i] == sp6 || str1[i] == sp7 || str1[i] == sp8)
  324. {
  325. strOut1 += str1[i];
  326. }
  327. }
  328. for (var i = 0; i < str2.length; i++)
  329. {
  330. if (str2[i] == sp1 || str2[i] == sp2 || str2[i] == sp3 || str2[i] == sp4
  331. || str2[i] == sp5 || str2[i] == sp6 || str2[i] == sp7 || str2[i] == sp8)
  332. {
  333. strOut2 += str2[i];
  334. }
  335. }
  336. }
  337. var retVal = 0;
  338. if (strOut1 == strOut2)
  339. retVal = 0;
  340. else if (strOut1.length == strOut2.length)
  341. retVal = 1;
  342. else
  343. retVal = 2;
  344. return new Array(retVal, strOut1.length, strOut2.length);
  345. }
  346.  
  347. if (!String.prototype.endsWith)
  348. {
  349. String.prototype.endsWith = function(searchString, position)
  350. {
  351. var subjectString = this.toString();
  352. if (typeof position !== 'number' || !isFinite(position)
  353. || Math.floor(position) !== position || position > subjectString.length)
  354. {
  355. position = subjectString.length;
  356. }
  357. position -= searchString.length;
  358. var lastIndex = subjectString.indexOf(searchString, position);
  359. return lastIndex !== -1 && lastIndex === position;
  360. };
  361. }
  362.  
  363. function reload()
  364. {
  365. window.location = window.location.href;
  366. }
  367.  
  368. function getCookie(c_name) {
  369. var c_value = document.cookie;
  370. var c_start = c_value.indexOf(" " + c_name + "=");
  371. if (c_start == -1) {
  372. c_start = c_value.indexOf(c_name + "=");
  373. }
  374. if (c_start == -1) {
  375. c_value = null;
  376. }
  377. else {
  378. c_start = c_value.indexOf("=", c_start) + 1;
  379. var c_end = c_value.indexOf(";", c_start);
  380. if (c_end == -1) {
  381. c_end = c_value.length;
  382. }
  383. c_value = unescape(c_value.substring(c_start, c_end));
  384. }
  385. return c_value;
  386. }
  387.  
  388. var isVisible = (function()
  389. {
  390. var stateKey;
  391. var eventKey;
  392. var keys =
  393. {
  394. hidden: "visibilitychange",
  395. webkitHidden: "webkitvisibilitychange",
  396. mozHidden: "mozvisibilitychange",
  397. msHidden: "msvisibilitychange"
  398. };
  399. for (stateKey in keys)
  400. {
  401. if (stateKey in document)
  402. {
  403. eventKey = keys[stateKey];
  404. break;
  405. }
  406. }
  407. return function(c)
  408. {
  409. if (c)
  410. {
  411. document.addEventListener(eventKey, c);
  412. }
  413. return !document[stateKey];
  414. }
  415. })();
  416.  
  417. function isDstUsa(year, month, day, hour)
  418. {
  419. // 2016, 3, 1, 15 == 1 Mar 2016 15:00
  420. var isDst = false;
  421. try
  422. {
  423. var y = parseInt(year);
  424. var m = parseInt(month);
  425. var d = parseInt(day);
  426. var h = parseInt(hour);
  427. function checkDstUsa(dayMar, dayNov, m, d, h)
  428. {
  429. var isDst = false;
  430. if ((m == 3 && d >= dayMar) || (m > 3 && m < 11) || (m == 11 && d <= dayNov))
  431. isDst = true;
  432. if ((m == 3 && d == dayMar && h < 2) || (m == 11 && d == dayNov && h >= 2))
  433. isDst = false;
  434. return isDst;
  435. }
  436. if (y == 2007 || y == 2012 || y == 2018 || y == 2029)
  437. {
  438. isDst = checkDstUsa(11, 4, m, d, h);
  439. }
  440. else if (y == 2013 || y == 2019 || y == 2024)
  441. {
  442. isDst = checkDstUsa(10, 3, m, d, h);
  443. }
  444. else if (y == 2008 || y == 2014 || y == 2025)
  445. {
  446. isDst = checkDstUsa(9, 2, m, d, h);
  447. }
  448. else if (y == 2009 || y == 2015 || y == 2020 || y == 2026)
  449. {
  450. isDst = checkDstUsa(8, 1, m, d, h);
  451. }
  452. else if (y == 2010 || y == 2021 || y == 2027)
  453. {
  454. isDst = checkDstUsa(14, 7, m, d, h);
  455. }
  456. else if (y == 2011 || y == 2016 || y == 2022)
  457. {
  458. isDst = checkDstUsa(13, 6, m, d, h);
  459. }
  460. else if (y == 2017 || y == 2023 || y == 2028)
  461. {
  462. isDst = checkDstUsa(12, 5, m, d, h);
  463. }
  464. }
  465. catch (ex)
  466. {
  467. }
  468. return isDst;
  469. }
  470.  
  471. function getUnixTimestamp()
  472. {
  473. return parseInt((new Date()) / 1000);
  474. }
  475.  
  476. var timeoutList = new Array();
  477. var intervalList = new Array();
  478.  
  479. function setTimeoutCustom(func, tm, params)
  480. {
  481. var id = setTimeout(func, tm, params);
  482. timeoutList.push(id);
  483. return id;
  484. }
  485.  
  486. function clearTimeoutAll()
  487. {
  488. for (var i = 0; i < timeoutList.length; i++)
  489. {
  490. clearTimeout(timeoutList[i]);
  491. }
  492. }
  493.  
  494. function setIntervalCustom(func, tm, params)
  495. {
  496. var id = setInterval(func, tm, params);
  497. intervalList.push(id);
  498. return id;
  499. }
  500.  
  501. function clearIntervalAll()
  502. {
  503. for (var i = 0; i < intervalList.length; i++)
  504. {
  505. clearInterval(intervalList[i]);
  506. }
  507. }
  508.  
  509. function main()
  510. {
  511. var url = document.documentURI;
  512. var lang = getCookie("Language");
  513. // Auto refresh when error
  514. {
  515. var h1 = document.querySelector("#leftAreaContainer > h1, body > h1");
  516. if (h1 != null)
  517. {
  518. var text = h1.textContent.trim();
  519. if (text == "Steam Translation Server - Maintenance Warning"
  520. || text == "Forbidden")
  521. {
  522. console.log("stsh: refresh");
  523. setTimeoutCustom(reload, 60000);
  524. return;
  525. }
  526. }
  527. }
  528.  
  529. // Clean links
  530. {
  531. var pattT1 = /\?t=[0-9]{6,}\&/g;
  532. var pattT2 = /\&t=[0-9]{6,}/g;
  533. var pattT3 = /\?t=[0-9]{6,}/g;
  534. var as = document.querySelectorAll("a");
  535. for (var i = 0; i < as.length; i++)
  536. {
  537. var href = as[i].href;
  538. if (pattT1.test(href))
  539. {
  540. as[i].href = href.replace(pattT1,"?");
  541. }
  542. else if (pattT2.test(href))
  543. {
  544. as[i].href = href.replace(pattT2,"");
  545. }
  546. else if (pattT3.test(href))
  547. {
  548. as[i].href = href.replace(pattT3,"");
  549. }
  550. }
  551. }
  552.  
  553. var eleLogout = document.querySelector("#logout");
  554. if (eleLogout != null)
  555. {
  556. var logoutHtml = ' <a class="stsh_a_button" target="_blank" '
  557. + ' href="/user_activity.php">My Profile</a> '
  558. + ' <input name="login_button" value="Logout?" type="submit" onmouseup="return confirm(\'Logout?\');" /> ';
  559. eleLogout.innerHTML = logoutHtml;
  560. }
  561.  
  562. // Special event button
  563. {
  564. var eleLogoff = document.querySelector("#logoff");
  565. if (eleLogoff != null)
  566. {
  567. var d = new Date();
  568. if ((d.getUTCMonth() > 8) || (d.getUTCMonth() == 8 && d.getUTCDate() >= 25) || (d.getUTCMonth() == 0 && d.getUTCDate() <= 1))
  569. {
  570. var divSpecial = document.createElement("div");
  571. divSpecial.id = "stsh_specialEvent";
  572. divSpecial.innerHTML = ' <a class="stsh_a_button" target="_blank" '
  573. + ' href="/rally.php">Year-End Rally</a> ';
  574. eleLogoff.appendChild(divSpecial);
  575. }
  576. }
  577. }
  578.  
  579. if (url.indexOf("Us_And_Them.php") > -1)
  580. {
  581. var container = "\"";
  582. var tdEng = document.querySelector("#leftAreaContainer > table > tbody:nth-child(1) > tr:nth-child(1) > td:nth-child(2)");
  583. if (tdEng != null)
  584. {
  585. tdEng.innerHTML = container + tdEng.innerHTML + container;
  586. }
  587. var h1 = document.querySelector("#leftAreaContainer > h1:nth-child(2)");
  588. if (h1 != null)
  589. {
  590. var header = h1.textContent.trim();
  591. var key = header.split(" ")[0];
  592. h1.innerHTML = header.replace(key, "<a href='http://translation.steampowered.com/translate.php?keyonly=1&search_input="
  593. + encodeURIComponent(key) + "' >" + key + "</a>");
  594. document.title = key + " - " + document.title;
  595. }
  596. } // End Us_And_Them.php
  597.  
  598. if (url.indexOf("suggestions.php") > -1)
  599. {
  600. var ele = document.querySelector("#suggestion_value_new");
  601. if (ele != null)
  602. {
  603. ele.style.width = "960px";
  604. ele.style.height = "64px";
  605. ele.style.marginLeft = "3px";
  606. }
  607. var inputClose = document.querySelector("#suggestions_nav > input[value^='Close']");
  608. if (inputClose != null)
  609. {
  610. inputClose.value = "Close (Esc)";
  611. }
  612. // Move region
  613. {
  614. var td = document.querySelector(".progress tr:last-child > td:nth-child(3)");
  615. if (td != null && td.textContent.trim() == "")
  616. {
  617. function moveSuggestionBox()
  618. {
  619. var td = document.querySelector(".progress tr:last-child > td:nth-child(3)");
  620. if (td != null && td.textContent.trim() == "")
  621. {
  622. td.innerHTML = "";
  623. var eleTarget = document.querySelector("#suggestionmain > div:nth-child(4) > .lbAction");
  624. if (eleTarget != null)
  625. {
  626. td.appendChild(eleTarget);
  627. td.style.padding = "0px";
  628. var textarea = document.querySelector("#suggestion_value_new");
  629. if (textarea != null)
  630. {
  631. textarea.style.width = "98%";
  632. textarea.style.marginLeft = "0px";
  633. textarea.style.height = (textarea.scrollHeight + 20) + "px";
  634. textarea.focus();
  635. }
  636. }
  637. }
  638. }
  639. function moveSuggestionList()
  640. {
  641. var td = document.querySelector(".progress tr:last-child > td:nth-child(3)");
  642. if (td != null && td.textContent.trim() == "")
  643. {
  644. td.innerHTML = "";
  645. var eleTarget = document.querySelector(".suggestion");
  646. if (eleTarget != null)
  647. {
  648. td.appendChild(eleTarget);
  649. td.style.padding = "0px";
  650. eleTarget.style.marginTop = "-2px";
  651. eleTarget.style.paddingTop = "0px";
  652. eleTarget.style.borderBottomWidth = "0px";
  653. eleTarget.style.borderRightWidth = "0px";
  654. eleTarget.style.resize = "none";
  655. var eleAutoApprove = document.querySelector("#stsh_autoApprove");
  656. if (eleAutoApprove != null)
  657. {
  658. eleAutoApprove.style.display = "none";
  659. }
  660. var eleAutoApproveLabel = document.querySelector(".stsh_autoApprove_label");
  661. if (eleAutoApproveLabel != null)
  662. {
  663. eleAutoApproveLabel.style.display = "none";
  664. }
  665. }
  666. }
  667. }
  668. var eleMoveBox = document.createElement("input");
  669. eleMoveBox.id = "stsh_moveSuggestionBox";
  670. eleMoveBox.setAttribute("value", "Move Box Here");
  671. eleMoveBox.setAttribute("type", "button");
  672. eleMoveBox.style.marginRight = "5px";
  673. eleMoveBox.addEventListener("click", function(e)
  674. {
  675. moveSuggestionBox();
  676. });
  677. td.appendChild(eleMoveBox);
  678. var eleMoveList = document.createElement("input");
  679. eleMoveList.id = "stsh_moveSuggestionList";
  680. eleMoveList.setAttribute("value", "Move Suggestion Here");
  681. eleMoveList.setAttribute("type", "button");
  682. eleMoveList.style.marginRight = "5px";
  683. eleMoveList.addEventListener("click", function(e)
  684. {
  685. moveSuggestionList();
  686. });
  687. td.appendChild(eleMoveList);
  688. }
  689. }
  690. var textarea = document.querySelector("#suggestion_value_new");
  691. if (textarea != null)
  692. {
  693. textarea.focus();
  694. textarea.style.height = (textarea.scrollHeight + 20) + "px";
  695. if (textarea.scrollHeight > 200 && document.querySelector(".suggestion") != null)
  696. {
  697. textarea.scrollIntoView();
  698. }
  699. }
  700. var br = document.querySelector("form.lbAction:nth-child(2) > div:nth-child(2) > br:nth-child(1)");
  701. if (br != null)
  702. {
  703. br.parentElement.removeChild(br);
  704. }
  705. var key = "";
  706. var divNav = document.querySelector("div#suggestions_nav");
  707. if (divNav != null)
  708. {
  709. var insert = "";
  710. var spliter = "_";
  711. var regApp = /[0-9]{2,}/;
  712. var aKey = document.querySelector(".smallcopy > font:nth-child(2) > a:nth-child(1)");
  713. if (aKey != null)
  714. {
  715. insert += ' <br/> &nbsp; ';
  716. key = encodeURIComponent(aKey.textContent.trim());
  717. if (key == "token-key")
  718. {
  719. aKey = document.querySelector(".smallcopy > a:nth-child(3)");
  720. if (aKey != null)
  721. {
  722. key = encodeURIComponent(aKey.textContent.trim());
  723. }
  724. }
  725. if (key != "")
  726. {
  727. document.title = key + " - " + document.title;
  728. if (key.split(spliter).length > 1)
  729. {
  730. if (key.indexOf("%23") == 0)
  731. {
  732. var firstSpliter = key.indexOf(spliter);
  733. var keySharp = key.substring(0, firstSpliter);
  734. insert += ' <a class="stsh_a_button" target="_blank" '
  735. + ' href="/translate.php?keyonly=1&paginationrows=1000&search_input='
  736. + keySharp + '">Search by Hashtag</a> ';
  737. }
  738. var lastSpliter = key.lastIndexOf(spliter);
  739. var keyGroup = key.substring(0, lastSpliter);
  740. insert += ' <a class="stsh_a_button" target="_blank" '
  741. + ' href="/translate.php?keyonly=1&paginationrows=1000&search_input='
  742. + keyGroup + '">Search by Group</a> ';
  743. }
  744. insert += ' <a class="stsh_a_button" target="_blank" '
  745. + ' href="/translate.php?keyonly=1&search_input='
  746. + key + '">Search by Key</a> ';
  747. }
  748. }
  749. var tdText = document.querySelector(".progress tr:last-child > td:nth-child(1)");
  750. if (tdText != null)
  751. {
  752. var text = encodeURIComponent(tdText.textContent.trim()).replace(/(%20|%09)/g,"+")
  753. .replace(/'/g,"\\'").replace("%0A","+").replace(/\++/g,"+").substr(0, 80);
  754. if (text.length >= 80)
  755. {
  756. text = text.substr(0,text.lastIndexOf("+"));
  757. }
  758. if (text != "")
  759. {
  760. insert += ' <br/> &nbsp; <a class="stsh_a_button" target="_blank" '
  761. + ' href="/translate.php?keyonly=2&paginationrows=1000&search_input='
  762. + text + '">Search by String</a> ';
  763. }
  764. else
  765. {
  766. if (textarea != null)
  767. {
  768. var eleSubmit = document.querySelector(".lbAction input[type='submit'][accesskey='s']");
  769. if (eleSubmit != null)
  770. {
  771. var eleNew = document.createElement("input");
  772. eleNew.classList.add("stsh_insert_space");
  773. eleNew.setAttribute("type", "button");
  774. eleNew.setAttribute("value", "Insert Space (Alt+0160)");
  775. insertBeforeElement(eleNew, eleSubmit.parentElement.firstChild);
  776. eleNew.addEventListener("click", function(e)
  777. {
  778. var textarea = document.querySelector("#suggestion_value_new");
  779. if (textarea != null)
  780. {
  781. textarea.value = String.fromCharCode(160);
  782. textarea.focus();
  783. }
  784. });
  785. }
  786. }
  787. }
  788. }
  789. var app = regApp.exec(key.replace("%23",""));
  790. if (key.indexOf("faq") < 0 && app != null)
  791. {
  792. insert += ' <br/> &nbsp; ';
  793. if (key.indexOf("SharedFiles_App_") == 0)
  794. {
  795. insert += ' <a class="stsh_a_button" target="_blank" '
  796. + ' href="http://steamcommunity.com/workshop/browse?appid='
  797. + app + '">View Workshop</a> ';
  798. }
  799. insert += ' <a class="stsh_a_button" target="_blank" '
  800. + ' href="http://steamcommunity.com/app/'
  801. + app + '">View Community</a> '
  802. insert += ' <a class="stsh_a_button" target="_blank" '
  803. + ' href="http://store.steampowered.com/app/'
  804. + app + '">View App</a> ';
  805. }
  806. var src = document.documentURI;
  807. var insertBefore = ' <input value="Refresh" '
  808. + ' onclick="window.location = window.location.href; return false;" type="button"> '
  809. + ' <a class="stsh_a_button" target="_blank" '
  810. + ' href="' + src + '">Frame</a> ';
  811. var innerNew = divNav.innerHTML
  812. .replace('<input value="Previous','&nbsp;&nbsp;<input value="Prev')
  813. .replace('<input value="Close','&nbsp;&nbsp;<input value="Close');
  814. divNav.innerHTML = insertBefore + innerNew + insert;
  815. }
  816. // Regroup glossary and auto replace matched string
  817. if (false)
  818. {
  819. // old feature
  820. setTimeoutCustom(function()
  821. {
  822. var br = "<br>";
  823. var brSpace = " <br> ";
  824. var tag = "<a";
  825. var colon = ">: ";
  826. var comma = ",";
  827. var bracket = " (";
  828. var isEdit = false;
  829. var p = null;
  830. var aGls = document.querySelectorAll("a[href='glossary.php']");
  831. for (var i = 0; i < aGls.length; i++)
  832. {
  833. if (aGls[i].textContent.trim() == "GLOSSARY FEATURE")
  834. {
  835. p = aGls[i].parentElement;
  836. break;
  837. }
  838. }
  839. if (p != null)
  840. {
  841. var glosOuters = [];
  842. var glosInnerStart = 0;
  843. var countGl = 0;
  844. var glossaries = p.innerHTML.split(br);
  845. if (glossaries.length > 2)
  846. {
  847. glosOuters = [p];
  848. glosInnerStart = 2;
  849. }
  850. else
  851. {
  852. glosOuters = p.nextSibling.querySelectorAll("td");
  853. glosInnerStart = 0;
  854. }
  855. var rgxKey = />[^><]+</;
  856. var rgxKeyClean = /[><]+/g;
  857. var rgxKeyPunct = /[\(\)\[\]\:\!]/g;
  858. var rgxContentClean = /<[^<]*>/g;
  859. var textOrg = "";
  860. var textEng = "";
  861. var isTextReplaced = false;
  862. var isOutdated = false;
  863.  
  864. var eleBtnResummit = document.querySelector("input[type='submit'][value^='RESUBMIT']");
  865. if (eleBtnResummit != null)
  866. {
  867. isTextReplaced = true;
  868. }
  869. else
  870. {
  871. var eleTextOrg = document.querySelector("#suggestion_value_new");
  872. if (eleTextOrg != null)
  873. {
  874. textOrg = eleTextOrg.value.trim().toLowerCase();
  875. }
  876. if (textOrg == "")
  877. {
  878. isTextReplaced = true;
  879. }
  880. }
  881. if (!isTextReplaced)
  882. {
  883. var eleTrs = document.querySelectorAll(".progress tr");
  884. isOutdated = (eleTrs.length >= 3);
  885. if (isOutdated)
  886. {
  887. textEng = eleTrs[eleTrs.length - 1].firstElementChild.textContent.trim().toLowerCase();
  888. }
  889. }
  890. for (var i = 0; i < glosOuters.length; i++)
  891. {
  892. var glosOuter = glosOuters[i];
  893. var glosInners = glosOuter.innerHTML.split(br);
  894. isEdit = false;
  895. for (var j = glosInnerStart; j < glosInners.length; j++)
  896. {
  897. var glossary = glosInners[j].trim();
  898. if (glossary.length > 0 && glossary.indexOf(tag) == 0)
  899. {
  900. var colonIndex = glossary.indexOf(colon);
  901. var contentHead = glossary.substr(0, colonIndex + 3);
  902. var contentAll = glossary.substr(colonIndex + 3);
  903. var contentWords = contentAll.split(comma);
  904. var contentFirst = contentWords[0].trim();
  905. for (var k = 0; k < contentWords.length; k++)
  906. {
  907. var contentNew = contentWords[k].trim();
  908. var contentSub = null;
  909. var bracketPos = contentNew.indexOf(" (");
  910. if (bracketPos > -1)
  911. {
  912. contentSub = contentNew.substr(bracketPos);
  913. contentNew = contentNew.substr(0, bracketPos);
  914. }
  915. contentNew = " <span id='stsh_gls_" + countGl
  916. + "' onclick='clickToSelect(this)'>"
  917. + contentNew + "</span>";
  918. //+ "<span style='color: white; cursor: pointer;'>^</span>";
  919. if (contentSub != null)
  920. {
  921. contentNew += "<span "
  922. + "onclick='clickToSelect(this.previousElementSibling)'>"
  923. + contentSub + "</span>";
  924. }
  925. contentWords[k] = contentNew;
  926. countGl++;
  927. }
  928. if (!isTextReplaced)
  929. {
  930. var keys = contentHead.match(rgxKey);
  931. if (keys != null && keys.length > 0)
  932. {
  933. var key = keys[0].replace(rgxKeyClean, "").trim().toLowerCase();
  934. var contentClean = contentFirst.replace(rgxContentClean, "");
  935. var contentLower = contentClean.toLowerCase();
  936. var textCur = "";
  937. if (key == textOrg.replace(rgxKeyPunct, ""))
  938. {
  939. textCur = textOrg;
  940. }
  941. else if (key == textEng.replace(rgxKeyPunct, ""))
  942. {
  943. textCur = textEng;
  944. }
  945. if (textCur != "" && key != contentLower)
  946. {
  947. var rgxReplace = new RegExp(key, "i");
  948. eleTextOrg.value = textCur.replace(rgxReplace, contentClean);
  949. isTextReplaced = true;
  950. }
  951. }
  952. }
  953. glosInners[j] = contentHead + contentWords.join(comma);
  954. isEdit = true;
  955. }
  956. }
  957. if (isEdit)
  958. {
  959. glosOuter.innerHTML = glosInners.join(brSpace);
  960. }
  961. }
  962. }
  963. }, 200);
  964. }
  965. // Restyle glossary
  966. {
  967. var eleP = null;
  968. var elesA = document.querySelectorAll("a[href='glossary.php']");
  969. for (var i = 0; i < elesA.length; i++)
  970. {
  971. if (elesA[i].textContent.trim() == "GLOSSARY FEATURE")
  972. {
  973. eleP = elesA[i].parentElement;
  974. break;
  975. }
  976. }
  977. if (eleP != null)
  978. {
  979. var nodeText = eleP.firstElementChild.nextSibling;
  980. if (nodeText.nodeType == document.TEXT_NODE)
  981. {
  982. var ele = document.createElement("span");
  983. ele.textContent = nodeText.textContent;
  984. nodeText.parentElement.removeChild(nodeText);
  985. insertAfterElement(ele, eleP.firstElementChild);
  986. }
  987. var eleHead;
  988. if (eleP.nextElementSibling.tagName == "TABLE")
  989. {
  990. eleHead = eleP.nextElementSibling;
  991. }
  992. else
  993. {
  994. eleHead = eleP;
  995. }
  996. eleHead.classList.add("stsh_glossary_header");
  997. var elesTerm = eleHead.querySelectorAll("a[href^='http://translation.steampowered.com/translate.php?search_input=']");
  998. for (var i = 0; i < elesTerm.length; i++)
  999. {
  1000. elesTerm[i].classList.add("stsh_glossary_term");
  1001. }
  1002. }
  1003. }
  1004. // Auto link http
  1005. // Format comment
  1006. {
  1007. var countSugStatus = document.querySelectorAll(
  1008. ".suggestions_list span[class^='suggestion_status_']").length;
  1009. var regUrl = /http[^ "]+/ig;
  1010. var hostUrl = "http://translation.steampowered.com/";
  1011. var hostReplace = "/";
  1012. var eleComments = document.querySelectorAll(""
  1013. + ".suggestion_signature > i:nth-child(3), "
  1014. + ".suggestion_signature div:nth-child(1) > i:nth-child(4), "
  1015. + ".suggestion_signature div:nth-child(1) > i:nth-child(6), "
  1016. + ".row0 > td:nth-child(2), .row1 > td:nth-child(2), .row2 > td:nth-child(2), "
  1017. + ".row-1 > td:nth-child(2) ");
  1018. for (var i = 0; i < eleComments.length; i++)
  1019. {
  1020. var comment = eleComments[i].innerHTML + " ";
  1021. if (comment.indexOf("<a") == -1)
  1022. {
  1023. var commentUrls = comment.match(regUrl) || [];
  1024. for (var j = 0; j < commentUrls.length; j++)
  1025. {
  1026. var urlDecode = commentUrls[j];
  1027. try
  1028. {
  1029. urlDecode = decodeURIComponent(commentUrls[j]);
  1030. if (countSugStatus == 0 && urlDecode.indexOf(hostUrl) == 0)
  1031. {
  1032. var query = getQueryByName("search_input", urlDecode.replace("&amp;", "&"));
  1033. if (query != "")
  1034. {
  1035. urlDecode = query;
  1036. }
  1037. else
  1038. {
  1039. urlDecode = urlDecode.replace(hostUrl, hostReplace);
  1040. }
  1041. }
  1042. }
  1043. catch (ex)
  1044. {
  1045. }
  1046. var commentUrl = commentUrls[j] + " ";
  1047. comment = comment.replace(commentUrl,"<a target='_blank' href='"
  1048. + commentUrls[j] + "' >" + urlDecode + "</a> ");
  1049. }
  1050. }
  1051. comment = comment.trim();
  1052. if (comment.indexOf("Comment:") == 0)
  1053. {
  1054. eleComments[i].classList.add("stsh_submit_comment_header");
  1055. comment = comment
  1056. .replace("Comment:", "Comment: <span class='stsh_submit_comment'>")
  1057. .replace(/\/ /g, "<span class='stsh_white'>/</span> ")
  1058. .replace(/ \//g, " <span class='stsh_white'>/</span>")
  1059. .replace(/\-\&gt\;/g, "<span class='stsh_white'>-&gt;</span>")
  1060. .replace(/\,/g, "<span class='stsh_white'>,</span>")
  1061. + "</span>";
  1062. }
  1063. eleComments[i].innerHTML = comment;
  1064. var eleAs = eleComments[i].querySelectorAll("a");
  1065. for (var j = 0; j < eleAs.length; j++)
  1066. {
  1067. var href = eleAs[j].getAttribute("href");
  1068. if (href.indexOf("#") > -1)
  1069. {
  1070. eleAs[j].setAttribute("href", href.replace(/\#/g,"%23"));
  1071. }
  1072. }
  1073. //if (comment.indexOf("Comment:") != 0)
  1074. {
  1075. // Discussion comment
  1076. var elesA = eleComments[i].querySelectorAll("a");
  1077. for (var j = 0; j < elesA.length; j++)
  1078. {
  1079. var href = elesA[j].getAttribute("href");
  1080. if (href.endsWith(".jpg") || href.endsWith(".png") || href.endsWith(".gif"))
  1081. {
  1082. if (elesA[j].querySelectorAll("img").length == 0)
  1083. {
  1084. var ele = document.createElement("img");
  1085. ele.classList.add("stsh_comment_img");
  1086. ele.setAttribute("src", href);
  1087. ele.setAttribute("title", href);
  1088. ele.setAttribute("onclick", " if (this.style.minWidth != '850px') "
  1089. + " { this.style.minWidth = '850px'; } "
  1090. + " else { this.style.minWidth = '400px'; } ");
  1091. insertAfterElement(ele, elesA[j]);
  1092. }
  1093. }
  1094. }
  1095. }
  1096. }
  1097. }
  1098. var divIntro = document.querySelector("#suggestionmain > div.smallcopy");
  1099. if (divIntro != null)
  1100. {
  1101. var qBranch = getQueryByName("branch");
  1102. var htmlToken = "You are editing";
  1103. var htmlTokenReplace = "";
  1104. var htmlToken2 = "token-key";
  1105. var htmlToken2Replace = "Token-key";
  1106. var htmlFile = "of file";
  1107. var htmlFileReplace = '<br>File: <font class="stsh_blue" onclick="clickToSelect(this)">' + qBranch + '</font> >> ';
  1108. var htmlSugg = 'You have <font style="';
  1109. var htmlSuggReplace = 'You have <font title="Enter and submit new suggestions below. Do not alter HTML tags or variables." style="cursor: pointer; ';
  1110. var htmlIntro = "Enter and submit new suggestions below. Do not alter HTML tags or variables.";
  1111. var htmlIntroReplace = ' <a href="mailto:translationserver@valvesoftware.com" '
  1112. + 'title="Please report truncated tokens to translationserver@valvesoftware.com">'
  1113. + '<font style="color:white;">Report Tokens</font></a>';
  1114. var htmlContact = '<br>Please report truncated tokens to: <a href="mailto:translationserver@valvesoftware.com"><font style="color:white;">translationserver@valvesoftware.com</font></a>';
  1115. var htmlContactReplace = '';
  1116. if (key != "")
  1117. {
  1118. htmlIntroReplace += ' <br>Share: <font class="stsh_green" style="font-size: 0.8em;" onclick="clickToSelect(this)">'
  1119. + 'http://translation.steampowered.com/translate.php?search_input=' + key
  1120. + "</font> <br>";
  1121. }
  1122. var isComplete = (divIntro.innerHTML.indexOf(htmlContact) > -1);
  1123. divIntro.innerHTML = divIntro.innerHTML
  1124. .replace(htmlToken, htmlTokenReplace)
  1125. .replace(htmlToken2, htmlToken2Replace)
  1126. .replace(htmlFile, htmlFileReplace)
  1127. .replace(htmlSugg, htmlSuggReplace)
  1128. .replace(htmlIntro, htmlIntroReplace)
  1129. .replace(htmlContact, htmlContactReplace)
  1130. .trim();
  1131. if (!isComplete)
  1132. {
  1133. var stsh_introReplace_start = new Date();
  1134. var stsh_introReplace_itv = setIntervalCustom(function(params)
  1135. {
  1136. var divIntro = params[0];
  1137. var htmlContact = params[1];
  1138. var htmlContactReplace = params[2];
  1139. var stsh_introReplace_isEnd = false;
  1140. var stsh_introReplace_cur = new Date();
  1141. if (divIntro.innerHTML.indexOf(htmlContact) > -1)
  1142. {
  1143. divIntro.innerHTML = divIntro.innerHTML
  1144. .replace(htmlContact, htmlContactReplace);
  1145. stsh_introReplace_isEnd = true;
  1146. }
  1147. if (stsh_introReplace_isEnd || stsh_introReplace_cur - stsh_introReplace_start > 10000)
  1148. {
  1149. clearInterval(stsh_introReplace_itv);
  1150. }
  1151. }, 100, [divIntro, htmlContact, htmlContactReplace]);
  1152. }
  1153. }
  1154. var formComments = document.querySelectorAll(".lbAction");
  1155. for (var i = 0; i < formComments.length; i++)
  1156. {
  1157. var formComment = formComments[i];
  1158. var inputComment = formComment.querySelector("input[type=submit]");
  1159. if (inputComment != null)
  1160. {
  1161. addKeyCtrlEnter(formComment, inputComment);
  1162. }
  1163. }
  1164. var inputApprove = document.querySelector(".suggestion_signature input[value~='APPROVE']");
  1165. if (inputApprove != null)
  1166. {
  1167. addKeyAlt(document, inputApprove, 219, "["); // [
  1168. addKeyAlt(document, inputApprove, "BracketLeft", ""); // [
  1169. //addKeyAlt(document, inputApprove, 0, ""); // [
  1170. //addKeyAlt(document, inputApprove, 53, ""); // [
  1171. addKeyAlt(document, inputApprove, 79, ""); // O
  1172. addKeyAlt(document, inputApprove, 65, ""); // A
  1173. }
  1174. var inputApproveNext = document.querySelector(".suggestion_signature input[value~='Next']");
  1175. if (inputApproveNext != null)
  1176. {
  1177. inputApproveNext.value = "Next";
  1178. addKeyAlt(document, inputApproveNext, 221, "]"); // ]
  1179. addKeyAlt(document, inputApproveNext, "BracketRight", ""); // ]
  1180. //addKeyAlt(document, inputApproveNext, 188, ""); // ]
  1181. //addKeyAlt(document, inputApproveNext, 173, ""); // ]
  1182. //addKeyAlt(document, inputApproveNext, 169, ""); // ]
  1183. addKeyAlt(document, inputApproveNext, 80, ""); // P
  1184. addKeyAlt(document, inputApproveNext, 83, ""); // S
  1185. addKeyCtrl(document, inputApproveNext, 45, ""); // INS
  1186. disableAfterClick(inputApproveNext);
  1187. if (inputApproveNext.disabled && inputApprove != null)
  1188. {
  1189. addKeyAlt(document, inputApprove, 221, ""); // ]
  1190. addKeyAlt(document, inputApprove, "BracketRight", ""); // ]
  1191. //addKeyAlt(document, inputApprove, 188, ""); // ]
  1192. //addKeyAlt(document, inputApprove, 173, ""); // ]
  1193. //addKeyAlt(document, inputApprove, 169, ""); // ]
  1194. addKeyAlt(document, inputApprove, 80, ""); // P
  1195. addKeyAlt(document, inputApprove, 83, ""); // S
  1196. addKeyCtrl(document, inputApprove, 45, ""); // INS
  1197. }
  1198. }
  1199. var inputDecline = document.querySelector(".suggestion_signature input[value~='DECLINE']");
  1200. if (inputDecline != null)
  1201. {
  1202. addKeyCtrl(document, inputDecline, 46, ""); // DEL
  1203. }
  1204. var inputDeclineNext = document.querySelector(".suggestion_signature input[value~='Next']:nth-child(5)");
  1205. if (inputDeclineNext != null)
  1206. {
  1207. inputDeclineNext.value = "Next";
  1208. }
  1209. var inputPrev = document.querySelector("#suggestions_nav > input[value^='Prev']");
  1210. if (inputPrev != null)
  1211. {
  1212. addKeyCtrl(document, inputPrev, 219, "["); // [
  1213. addKeyCtrl(document, inputPrev, "BracketLeft", ""); // [
  1214. //addKeyCtrl(document, inputPrev, 0, ""); // [
  1215. //addKeyCtrl(document, inputPrev, 53, ""); // [
  1216. disableAfterClick(inputPrev);
  1217. }
  1218. var inputNext = document.querySelector("#suggestions_nav > input[value~='Next']");
  1219. if (inputNext != null)
  1220. {
  1221. addKeyCtrl(document, inputNext, 221, "]"); // ]
  1222. addKeyCtrl(document, inputNext, "BracketRight", ""); // ]
  1223. //addKeyCtrl(document, inputNext, 188, ""); // ]
  1224. //addKeyCtrl(document, inputNext, 173, ""); // ]
  1225. //addKeyCtrl(document, inputNext, 169, ""); // ]
  1226. disableAfterClick(inputNext);
  1227. }
  1228. // Check special chars
  1229. {
  1230. var h1s = document.querySelectorAll(".progress h1");
  1231. if (h1s.length == 2)
  1232. {
  1233. var h1Org = h1s[0];
  1234. var h1Trn = h1s[1];
  1235. var tdOrg = document.querySelector(".progress tr:last-child > td:nth-child(1)");
  1236. var tdTrn = document.querySelector(".progress tr:last-child > td:nth-child(3)");
  1237. if (tdOrg != null && tdTrn != null)
  1238. {
  1239. var strOrg = tdOrg.textContent.trim();
  1240. var strTrn = tdTrn.textContent.trim();
  1241. var statusTrnArr = checkSpecialCharMatched(strOrg, strTrn);
  1242. var statusTrnMatched = statusTrnArr[0];
  1243. var spOrg = statusTrnArr[1];
  1244. var spTrn = statusTrnArr[2];
  1245. if (spOrg > 0)
  1246. {
  1247. var spanSpOrg = document.createElement("span");
  1248. spanSpOrg.id = "stsh_spanSpOrg";
  1249. spanSpOrg.classList.add("stsh_blue");
  1250. spanSpOrg.innerHTML = " &nbsp;&nbsp;&nbsp;SpecialChar: " + spOrg;
  1251. h1Org.parentElement.appendChild(spanSpOrg);
  1252. // Check chars in translated
  1253. if (strTrn != "")
  1254. {
  1255. var spanSpTrn = document.createElement("span");
  1256. spanSpTrn.id = "stsh_spanSpTrn";
  1257. if (statusTrnMatched == 0)
  1258. {
  1259. spanSpTrn.classList.add("stsh_green");
  1260. }
  1261. else
  1262. {
  1263. spanSpTrn.classList.add("stsh_red");
  1264. }
  1265. var outputTrn = " &nbsp;&nbsp;&nbsp;SpecialChar: " + spTrn;
  1266. if (statusTrnMatched == 0)
  1267. {
  1268. outputTrn += " (Matched)";
  1269. }
  1270. else if (statusTrnMatched == 1)
  1271. {
  1272. outputTrn += " (Order not matched)";
  1273. }
  1274. else
  1275. {
  1276. outputTrn += " (Not matched)";
  1277. }
  1278. spanSpTrn.innerHTML = outputTrn;
  1279. h1Trn.parentElement.appendChild(spanSpTrn);
  1280. }
  1281. // Check chars in suggested
  1282. var divSugs = document.querySelectorAll(".suggestion_text");
  1283. for (var i = 0; i < divSugs.length; i++)
  1284. {
  1285. var divSug = divSugs[i];
  1286. var strSug = divSug.textContent.trim();
  1287. var statusSugArr = checkSpecialCharMatched(strOrg, strSug);
  1288. var statusSugMatched = statusSugArr[0];
  1289. var spSug = statusSugArr[2];
  1290. var spanSpSug = document.createElement("span");
  1291. spanSpSug.classList.add("stsh_spanSpSug");
  1292. if (statusSugMatched == 0)
  1293. {
  1294. spanSpSug.classList.add("stsh_green");
  1295. }
  1296. else
  1297. {
  1298. spanSpSug.classList.add("stsh_red");
  1299. }
  1300. var outputSug = " SpecialChar: " + spSug;
  1301. if (statusSugMatched == 0)
  1302. {
  1303. outputSug += " (Matched)";
  1304. }
  1305. else if (statusSugMatched == 1)
  1306. {
  1307. outputSug += " (Order not matched)";
  1308. }
  1309. else
  1310. {
  1311. outputSug += " (Not matched)";
  1312. }
  1313. outputSug += " <br/><br/> ";
  1314. spanSpSug.innerHTML = outputSug;
  1315. divSug.insertBefore(spanSpSug, divSug.firstChild);
  1316. }
  1317. }
  1318. }
  1319. }
  1320. }
  1321. // Trim string in same token
  1322. {
  1323. var p = document.querySelector("#suggestionmain > div:nth-child(5) > p:nth-child(4)");
  1324. if (p != null)
  1325. {
  1326. for (var i = 0; i < p.childNodes.length; i++)
  1327. {
  1328. child = p.childNodes[i];
  1329. if (child.nodeName == "#text")
  1330. {
  1331. child.nodeValue = child.nodeValue.trim();
  1332. }
  1333. }
  1334. }
  1335. }
  1336. // Display newlines
  1337. {
  1338. var tdOrg = document.querySelector(".progress tr:last-child > td:nth-child(1)");
  1339. var tdTrn = document.querySelector(".progress tr:last-child > td:nth-child(3)");
  1340. if (tdOrg != null && tdTrn != null)
  1341. {
  1342. var htmlOrg = tdOrg.innerHTML.trim();
  1343. var htmlTrn = tdTrn.innerHTML.trim();
  1344. if ((htmlOrg.indexOf("\n") > -1 || htmlOrg.indexOf("\\n") > -1
  1345. || htmlTrn.indexOf("\n") > -1 || htmlTrn.indexOf("\\n") > -1)
  1346. /*&& htmlOrg.indexOf("<br") < 0
  1347. && htmlOrg.indexOf("<p") < 0 && htmlOrg.indexOf("<div") < 0 && htmlOrg.indexOf("<li") < 0*/)
  1348. {
  1349. var h2SugHeader = document.querySelector("#suggestionmain > div > h2");
  1350. if (h2SugHeader != null)
  1351. {
  1352. var btn = document.createElement("input");
  1353. btn.setAttribute("class", "stsh_btn_right");
  1354. btn.setAttribute("type", "button");
  1355. btn.setAttribute("value", "Display Newlines");
  1356. function displayNewlines(ele)
  1357. {
  1358. if (ele != null)
  1359. {
  1360. ele.innerHTML = ele.innerHTML.trim().replace(/\n/g,"\n<br>").replace(/\\n/g," \\n<br>");
  1361. }
  1362. }
  1363. btn.addEventListener("click", function(e)
  1364. {
  1365. e.target.disabled = true;
  1366. var tdOrg = document.querySelector(".progress tr:last-child > td:nth-child(1)");
  1367. var tdTrn = document.querySelector(".progress tr:last-child > td:nth-child(3)");
  1368. displayNewlines(tdOrg);
  1369. displayNewlines(tdTrn);
  1370. var divSugs = document.querySelectorAll(".suggestion_text");
  1371. for (var i = 0; i < divSugs.length; i++)
  1372. {
  1373. var divSug = divSugs[i];
  1374. displayNewlines(divSug);
  1375. }
  1376. var textarea = document.querySelector("#suggestion_value_new");
  1377. if (textarea != null)
  1378. {
  1379. textarea.focus();
  1380. }
  1381. });
  1382. h2SugHeader.appendChild(btn);
  1383. }
  1384. }
  1385. }
  1386. }
  1387. // Open comment when decline
  1388. {
  1389. var countComment = 0;
  1390. var elesComment = [];
  1391. var countSug = document.querySelectorAll(".suggestions_list .suggestion").length;
  1392. var countSugDeclined = document.querySelectorAll(
  1393. ".suggestions_list span[class='suggestion_status_declined']").length;
  1394. if (countSug == countSugDeclined)
  1395. {
  1396. var elesSugA = document.querySelectorAll(".suggestions_list span[class^='suggestion_status_'] a");
  1397. for (var i = 0; i < elesSugA.length; i++)
  1398. {
  1399. var eleComment = elesSugA[i].parentElement.parentElement.nextSibling;
  1400. if (eleComment.nodeName == "DIV" && eleComment.classList.contains("copy"))
  1401. {
  1402. if (elesSugA[i].parentElement.classList.contains("suggestion_status_declined"))
  1403. {
  1404. countComment++;
  1405. elesComment.push(eleComment);
  1406. }
  1407. }
  1408. }
  1409. if (countComment == elesSugA.length)
  1410. {
  1411. var isFocus = false;
  1412. for (var i = 0; i < elesComment.length; i++)
  1413. {
  1414. elesComment[i].style.display = "block";
  1415. if (!isFocus)
  1416. {
  1417. var eleTxt = elesComment[i].querySelector("textarea[name='suggestion_comment']");
  1418. if (eleTxt != null)
  1419. {
  1420. eleTxt.focus();
  1421. var eleSugOuter = elesComment[i].parentElement.parentElement.parentElement.parentElement;
  1422. if (eleSugOuter.classList.contains("suggestion"))
  1423. {
  1424. var eleOnion = eleSugOuter.querySelector(".suggestion_text font[style='color:#01ec00;']");
  1425. if (eleOnion != null)
  1426. {
  1427. eleTxt.value = "onion";
  1428. }
  1429. }
  1430. var eleSugComment = elesComment[i].parentElement
  1431. .parentElement.parentElement.querySelector(".stsh_submit_comment font");
  1432. if (eleSugComment != null && eleSugComment.textContent.trim() ==
  1433. "ATTENTION - English string was updated. This suggestion might be outdated.")
  1434. {
  1435. eleTxt.value = "outdated";
  1436. }
  1437. isFocus = true;
  1438. }
  1439. }
  1440. }
  1441. }
  1442. }
  1443. }
  1444. // Convert time
  1445. {
  1446. var rgxTime = /\d{2}-\d{2}-\d{4}, \d{2}:\d{2} [AP]M/;
  1447. var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
  1448. var eleFriends = document.querySelectorAll(".friend_block_avatar, .friend_block_discussions");
  1449. for (var i = 0; i < eleFriends.length; i++)
  1450. {
  1451. var nodes = [];
  1452. if (eleFriends[i].classList.contains("friend_block_avatar"))
  1453. {
  1454. nodes = eleFriends[i].childNodes;
  1455. }
  1456. else if (eleFriends[i].classList.contains("friend_block_discussions"))
  1457. {
  1458. nodes = eleFriends[i].parentElement.nextElementSibling.childNodes[2].childNodes;
  1459. }
  1460. for (var j = 0; j < nodes.length; j++)
  1461. {
  1462. var nodeVal = nodes[j].nodeValue;
  1463. if (nodeVal != null)
  1464. {
  1465. var dateTimes = rgxTime.exec(nodeVal);
  1466. if (dateTimes != null)
  1467. {
  1468. var dateTime = dateTimes[0];
  1469. var month = dateTime.substr(0, 2);
  1470. var day = dateTime.substr(3, 2);
  1471. var year = dateTime.substr(6, 4);
  1472. var hour = dateTime.substr(12, 2);
  1473. var minute = dateTime.substr(15, 2);
  1474. var period = dateTime.substr(18, 2);
  1475. if (period == "AM")
  1476. {
  1477. if (hour == "12")
  1478. {
  1479. hour = "00"
  1480. }
  1481. }
  1482. else if (period == "PM")
  1483. {
  1484. hour = parseInt(hour) + 12;
  1485. if (hour == 24)
  1486. {
  1487. hour = 12;
  1488. }
  1489. }
  1490. var dateTimeStd = year + "-" + month + "-" + day;
  1491. if (isDstUsa(year, month, day, hour))
  1492. {
  1493. dateTimeStd += "T" + hour + ":" + minute + ":00-0700";
  1494. }
  1495. else
  1496. {
  1497. dateTimeStd += "T" + hour + ":" + minute + ":00-0800";
  1498. }
  1499. var dateStd = new Date(dateTimeStd);
  1500. if (dateStd.toLocaleString() != "Invalid Date")
  1501. {
  1502. var gmt = dateStd.getTimezoneOffset() / 60 * -1;
  1503. var gmtStr = " GMT";
  1504. if (gmt > 0)
  1505. {
  1506. gmtStr += "+" + gmt;
  1507. }
  1508. else if (gmt < 0)
  1509. {
  1510. gmtStr += "" + gmt;
  1511. }
  1512. var dateNew = dateStd.getDate()
  1513. + " " + months[dateStd.getMonth()]
  1514. + " " + dateStd.getFullYear()
  1515. + ", " + padZero(dateStd.getHours(), 2)
  1516. + ":" + padZero(dateStd.getMinutes(), 2)
  1517. + gmtStr;
  1518. //console.log("Time: " + dateTimeStd);
  1519. //console.log("Time: " + dateTime + " -> " + dateNew);
  1520. //var dateNew2 = dateStd.toLocaleString() + gmtStr;
  1521. //console.log("Time: " + dateTime + " -> " + dateNew2);
  1522. var nodeValBegin = nodeVal.substr(0, nodeVal.indexOf(dateTime));
  1523. var nodeValEnd = nodeVal.substr(nodeVal.indexOf(dateTime) + dateTime.length);
  1524. nodes[j].nodeValue = nodeValBegin;
  1525. var ele = document.createElement("span");
  1526. ele.classList.add("stsh_time_convert");
  1527. ele.setAttribute("title", dateTime);
  1528. ele.textContent = dateNew;
  1529. insertAfterElement(ele, nodes[j]);
  1530. if (nodeValEnd != "")
  1531. {
  1532. insertAfterElement(document.createTextNode(nodeValEnd), ele);
  1533. }
  1534. }
  1535. else
  1536. {
  1537. console.log("Invalid Date: " + dateTimeStd);
  1538. }
  1539. }
  1540. }
  1541. }
  1542. }
  1543. }
  1544. // Add Steam profile links
  1545. {
  1546. var eleSpans = document.querySelectorAll("span[title='Send this user a private message']");
  1547. for (var i = 0; i < eleSpans.length; i++)
  1548. {
  1549. var href = eleSpans[i].parentElement.firstElementChild.getAttribute("href");
  1550. if (href != null && href.indexOf("user_activity.php?user=") == 0)
  1551. {
  1552. var profile = href.replace("user_activity.php?user=", "");
  1553. var ele = document.createElement("a");
  1554. ele.classList.add("stsh_steamProfile");
  1555. ele.setAttribute("target", "_blank");
  1556. ele.setAttribute("title", "View Steam profile");
  1557. ele.setAttribute("href", "http://steamcommunity.com/profiles/" + profile);
  1558. ele.textContent = " Steam ";
  1559. insertBeforeElement(ele, eleSpans[i]);
  1560. }
  1561. }
  1562. }
  1563. // Add auto approve
  1564. {
  1565. if (inputApprove != null)
  1566. {
  1567. var eleInput = document.createElement("input");
  1568. eleInput.id = "stsh_autoApprove";
  1569. eleInput.setAttribute("type", "checkbox");
  1570. eleInput.setAttribute("value", "auto");
  1571. eleInput.textContent = "";
  1572. var eleLabel = document.createElement("label");
  1573. eleLabel.classList.add("stsh_autoApprove_label");
  1574. eleLabel.classList.add("stsh_unselectable");
  1575. eleLabel.setAttribute("for", "stsh_autoApprove");
  1576. eleLabel.setAttribute("title", "Please use with care!");
  1577. eleLabel.textContent = " Auto Approve Next ";
  1578. inputApprove.parentElement.appendChild(eleInput);
  1579. inputApprove.parentElement.appendChild(eleLabel);
  1580. function autoApprove()
  1581. {
  1582. var tm = 2000;
  1583. console.log("AutoApprove: Next in " + tm + "ms");
  1584. setTimeoutCustom(function ()
  1585. {
  1586. var eleCheck = document.querySelector("#stsh_autoApprove");
  1587. if (eleCheck != null && eleCheck.checked)
  1588. {
  1589. var isClicked = false;
  1590. var ele = document.querySelector(".suggestion_signature input[value~='Next']");
  1591. if (ele != null && !ele.disabled && isVisible())
  1592. {
  1593. var isOutdated = false;
  1594. var eleSugComment = ele.parentElement
  1595. .parentElement.parentElement.querySelector(".stsh_submit_comment font");
  1596. if (eleSugComment != null && eleSugComment.textContent.trim() ==
  1597. "ATTENTION - English string was updated. This suggestion might be outdated.")
  1598. {
  1599. isOutdated = true;
  1600. }
  1601. if (!isOutdated)
  1602. {
  1603. isClicked = true;
  1604. GM_setValue("timeAutoApproveLast", getUnixTimestamp());
  1605. ele.click();
  1606. }
  1607. }
  1608. if (!isClicked)
  1609. {
  1610. eleCheck.checked = false;
  1611. GM_setValue("isAutoApprove", "false");
  1612. }
  1613. }
  1614. }, tm);
  1615. }
  1616. var tmDiff = getUnixTimestamp() - GM_getValue("timeAutoApproveLast", 0);
  1617. if (tmDiff > 10)
  1618. {
  1619. // > 10s
  1620. eleInput.checked = false;
  1621. GM_setValue("isAutoApprove", "false");
  1622. }
  1623. if (window.parent != window)
  1624. {
  1625. var eleOuter = window.parent.document.querySelector("#suggestions_box_outer");
  1626. if (eleOuter != null)
  1627. {
  1628. if (eleOuter.style.display == "none")
  1629. {
  1630. // Closed iFrame
  1631. eleInput.checked = false;
  1632. GM_setValue("isAutoApprove", "false");
  1633. }
  1634. }
  1635. }
  1636. if (GM_getValue("isAutoApprove", 0) == "true")
  1637. {
  1638. eleInput.checked = true;
  1639. autoApprove();
  1640. }
  1641.  
  1642. eleInput.addEventListener("click", function (e)
  1643. {
  1644. var ele = e.target;
  1645. if (ele.checked)
  1646. {
  1647. GM_setValue("isAutoApprove", "true");
  1648. autoApprove();
  1649. }
  1650. else
  1651. {
  1652. GM_setValue("isAutoApprove", "false");
  1653. }
  1654. });
  1655. }
  1656. }
  1657. // Warn when remove
  1658. {
  1659. var elesRemove = document.querySelectorAll(".suggestion_signature input[value='REMOVE']");
  1660. for (var i = 0; i < elesRemove.length; i++)
  1661. {
  1662. var oldClick = elesRemove[i].getAttribute("onclick");
  1663. if (oldClick != null && oldClick.indexOf("location.href") == 0)
  1664. {
  1665. var eleSug = elesRemove[i].parentElement.parentElement.parentElement.parentElement;
  1666. if (eleSug.classList.contains("suggestion"))
  1667. {
  1668. var eleOnion = eleSug.querySelector(".suggestion_text font[style='color:#01ec00;']");
  1669. if (eleOnion != null)
  1670. {
  1671. var newClick = "if (!confirm(\"Warning: You will delete your onion. Press Cancel to go back.\")) return false; "
  1672. + oldClick;
  1673. elesRemove[i].setAttribute("onclick", newClick);
  1674. elesRemove[i].setAttribute("title", "Do not remove your onion!");
  1675. elesRemove[i].style.color = "#777";
  1676. elesRemove[i].style.cursor = "not-allowed";
  1677. }
  1678. else
  1679. {
  1680. var eleComment = elesRemove[i].previousElementSibling.previousElementSibling;
  1681. if (eleComment != null)
  1682. {
  1683. if (eleComment.textContent.trim().indexOf("Comment:") == 0)
  1684. {
  1685. var newClick = "if (!confirm(\"Warning: You should not remove this suggestion. Press OK if you really want.\")) return false; "
  1686. + oldClick;
  1687. elesRemove[i].setAttribute("onclick", newClick);
  1688. elesRemove[i].setAttribute("title", "Your suggestion that has a comment!");
  1689. elesRemove[i].style.color = "#777";
  1690. elesRemove[i].style.cursor = "not-allowed";
  1691. }
  1692. }
  1693. }
  1694. }
  1695. }
  1696. }
  1697. }
  1698. } // End suggestions.php
  1699.  
  1700. if (url.indexOf("translate.php") > -1)
  1701. {
  1702. var searchText = getQueryByName("search_input");
  1703. if (searchText != "")
  1704. {
  1705. document.title = searchText + " - " + document.title;
  1706. }
  1707. else
  1708. {
  1709. var fileID = getQueryByName("file_ID");
  1710. if (fileID != "")
  1711. {
  1712. var eleFile = document.querySelector("#leftAreaContainer label[for='chosenfile']");
  1713. if (eleFile != null)
  1714. {
  1715. var file = eleFile.textContent.trim();
  1716. if (file.indexOf("Limit search results to CURRENT FILE: ") == 0)
  1717. {
  1718. file = file.replace("Limit search results to CURRENT FILE: ", "");
  1719. var fileNew = file.split("#").reverse().join(" # ").trim();
  1720. document.title = fileNew + " - " + document.title;
  1721. }
  1722. }
  1723. }
  1724. else
  1725. {
  1726. var eleInput = document.querySelector("#search_input");
  1727. if (eleInput != null)
  1728. {
  1729. var valInput = eleInput.value.trim();
  1730. if (valInput.indexOf("SUGGESTIONS FROM: ") == 0)
  1731. {
  1732. document.title = valInput.replace("SUGGESTIONS FROM: ", "") + " - " + document.title;
  1733. }
  1734. }
  1735. }
  1736. }
  1737. var outer = document.getElementById("suggestions_box_outer");
  1738. if (outer != null)
  1739. {
  1740. outer.setAttribute("onclick","hideSuggestionsBox();");
  1741. }
  1742. var divBtn = document.createElement("div");
  1743. document.body.appendChild(divBtn);
  1744. divBtn.innerHTML = ' \
  1745. <div class="stsh_showing_group"> \
  1746. <span class="stsh_showing_header">Hide</span>\
  1747. <br/> &nbsp; <input value="App" class="stsh_btn_short" type="button" onmouseup="hideKeyAppInterval(); return false;" /> \
  1748. <input value="Game" class="stsh_btn_short" type="button" onmouseup="hideKeyGameInterval(); return false;" /> \
  1749. <br/> &nbsp; <input value="FAQ" class="stsh_btn_short" type="button" onmouseup="hideKeyFaqInterval(); return false;" /> \
  1750. <input value="Support" class="stsh_btn_short" type="button" onmouseup="hideKeySupportInterval(); return false;" /> \
  1751. <br/> &nbsp; <input value="Promo" class="stsh_btn_short" type="button" onmouseup="hideKeyPromoInterval(); return false;" /> \
  1752. <input value="Email" class="stsh_btn_short" type="button" onmouseup="hideKeyEmailInterval(); return false;" /> \
  1753. <br/> \
  1754. <br/> &nbsp; <input value="Hide not similar" class="stsh_btn_long" type="button" onmouseup="hideStrNotMatchInterval(); return false;" /> \
  1755. <br/> &nbsp; <input value="Hide very long" class="stsh_btn_long" type="button" onmouseup="hideStrLongInterval(); return false;" /> \
  1756. \
  1757. <br/> &nbsp; <span class="stsh_showing_header">Hide Suggestions</span>\
  1758. <br/> &nbsp; <input id="stsh_showing_notTranslated" value="Not Translated (0)" class="stsh_btn_long" type="button" /> \
  1759. <br/> &nbsp; <input id="stsh_showing_suggested" value="Suggested (0)" class="stsh_btn_long" type="button" /> \
  1760. <br/> &nbsp; <input id="stsh_showing_resuggested" value="Resuggested (0)" class="stsh_btn_long" type="button" /> \
  1761. <br/> &nbsp; <input id="stsh_showing_approved" value="Approved (0)" class="stsh_btn_long" type="button" /> \
  1762. <br/> &nbsp; <input id="stsh_showing_declined" value="Declined (0)" class="stsh_btn_long" type="button" /> \
  1763. <br/> &nbsp; <input id="stsh_showing_translated" value="Translated (0)" class="stsh_btn_long" type="button" /> \
  1764. \
  1765. <br/> &nbsp; <span class="stsh_showing_header">Sort by</span>\
  1766. <br/> &nbsp; <input value="Key" class="stsh_btn_short" type="button" onmouseup="sortKeyInterval(); return false;" /> \
  1767. <input value="String" class="stsh_btn_short" type="button" onmouseup="sortStringInterval(); return false;" /> \
  1768. <br/> &nbsp; <input value="Word" class="stsh_btn_short" type="button" onmouseup="sortWordInterval(); return false;" /> \
  1769. <input value="Length" class="stsh_btn_short" type="button" onmouseup="sortLengthInterval(); return false;" /> \
  1770. <br/> \
  1771. <br/> &nbsp; <input id="stsh_showing_refresh" value="Refresh" class="stsh_btn" type="button" onmouseup="hideSuggestionsBox(); return false;" /> \
  1772. <br/> &nbsp; <input id="stsh_showing_all" value="Show All" class="stsh_btn" type="button" onmouseup="showKey(); return false;" /> \
  1773. </div> \
  1774. <div id="stsh_showing_current"></div> \
  1775. <div id="stsh_showing"></div> \
  1776. ';
  1777.  
  1778. // Count showing
  1779. function countShowing()
  1780. {
  1781. if (!isVisible()) return;
  1782. var trKeys = document.querySelectorAll("#keylist > table:nth-child(1) > tbody:nth-child(1) > tr");
  1783. var countAll = document.querySelectorAll("#keylist .copysmall").length;
  1784. var countShow = 0;
  1785. var countSuggest = 0;
  1786. var countResuggest = 0;
  1787. var countApprove = 0;
  1788. var countDecline = 0;
  1789. var countNotTranslated = 0;
  1790. var countTranslated = 0;
  1791. var txtApprove = "ready for Admin";
  1792. var txtDecline = "ready for removal";
  1793. var txtSuggest = "suggestion";
  1794. for (var i = 0; i < trKeys.length; i++)
  1795. {
  1796. if (trKeys[i].style.display != "none")
  1797. {
  1798. var eleCounter = trKeys[i].querySelector("tr.copysmall > td:nth-child(3)");
  1799. if (eleCounter != null)
  1800. {
  1801. countShow++;
  1802. var txtCounter = eleCounter.textContent.trim();
  1803. if (txtCounter.indexOf(txtApprove) > -1)
  1804. {
  1805. countApprove++;
  1806. }
  1807. else if (txtCounter.indexOf(txtDecline) > -1)
  1808. {
  1809. countDecline++;
  1810. }
  1811. else if (txtCounter.indexOf(txtSuggest) > -1)
  1812. {
  1813. var eleNotTranslated = trKeys[i].querySelector("span.token_nottranslated");
  1814. if (eleNotTranslated != null)
  1815. {
  1816. countSuggest++;
  1817. }
  1818. else
  1819. {
  1820. countResuggest++;
  1821. }
  1822. }
  1823. else
  1824. {
  1825. var eleNotTranslated = trKeys[i].querySelector("span.token_nottranslated");
  1826. if (eleNotTranslated != null)
  1827. {
  1828. countNotTranslated++;
  1829. }
  1830. else
  1831. {
  1832. countTranslated++;
  1833. }
  1834. }
  1835. }
  1836. else
  1837. {
  1838. var eleTd = trKeys[i].querySelector("td");
  1839. if (eleTd != null)
  1840. {
  1841. if (eleTd.textContent.trim() == "")
  1842. {
  1843. trKeys[i].parentElement.removeChild(trKeys[i]);
  1844. }
  1845. }
  1846. }
  1847. }
  1848. }
  1849. var eleShowing = document.getElementById("stsh_showing");
  1850. if (eleShowing != null)
  1851. {
  1852. var newHtml = "Showing: <span class=\"stsh_showing_counter\">" + countShow + " of " + countAll + "</span>"
  1853. + "<!-- " + countNotTranslated + ", " + countSuggest + ", " + countResuggest
  1854. + ", " + countApprove + ", " + countDecline + ", " + countTranslated + " -->";
  1855. if (eleShowing.innerHTML != newHtml)
  1856. {
  1857. eleShowing.innerHTML = newHtml;
  1858.  
  1859. var eleBtnShowings = document.querySelectorAll("#stsh_showing_notTranslated, #stsh_showing_suggested, #stsh_showing_resuggested"
  1860. + ", #stsh_showing_approved, #stsh_showing_declined, #stsh_showing_translated");
  1861. if (eleBtnShowings.length == 6)
  1862. {
  1863. var counterArr = [countNotTranslated, countSuggest, countResuggest, countApprove, countDecline, countTranslated ];
  1864. var counterTextArr = ["Not Translated", "Suggested", "Resuggested"
  1865. , "Approved", "Declined", "Translated" ];
  1866.  
  1867. for (var i = 0; i < eleBtnShowings.length; i++)
  1868. {
  1869. eleBtnShowings[i].value = counterTextArr[i] + " ("+ counterArr[i] +")" ;
  1870. };
  1871. }
  1872. }
  1873. }
  1874. var eleShowingCur = document.getElementById("stsh_showing_current");
  1875. if (eleShowingCur != null)
  1876. {
  1877. var eleOuter = document.getElementById("suggestions_box_outer");
  1878. if (eleOuter != null)
  1879. {
  1880. if (eleOuter.style.display != "none")
  1881. {
  1882. if (eleShowingCur.style.display != "initial")
  1883. eleShowingCur.style.display = "initial";
  1884. var eleIframe = document.getElementById("suggestions_iframe");
  1885. var iUrl = eleIframe.contentWindow.location.href;
  1886. var listId = parseInt(getQueryByName("list_id", iUrl));
  1887. if (isNaN(listId))
  1888. listId = 1;
  1889. else
  1890. listId += 1;
  1891. var newHtml = "Current: <span class=\"stsh_showing_counter\">" + listId + " of " + countShow + "</span>";
  1892. if (eleShowingCur.innerHTML != newHtml)
  1893. {
  1894. eleShowingCur.innerHTML = newHtml;
  1895. }
  1896. }
  1897. else
  1898. {
  1899. if (eleShowingCur.style.display != "none")
  1900. {
  1901. eleShowingCur.style.display = "none";
  1902. eleShowingCur.innerHTML = "";
  1903. }
  1904. }
  1905. }
  1906. }
  1907. }
  1908. countShowing();
  1909. setIntervalCustom(countShowing, 1000);
  1910. // End Count showing
  1911.  
  1912. // Line Counter
  1913. function addLineCounter()
  1914. {
  1915. if (!isVisible()) return;
  1916. var elesCounter = document.querySelectorAll(".stsh_lineCounter");
  1917. if (elesCounter.length > 0)
  1918. {
  1919. var j = 1;
  1920. for (var i = 0; i < elesCounter.length; i++)
  1921. {
  1922. if (elesCounter[i].parentElement.parentElement.parentElement.parentElement.style.display != "none")
  1923. {
  1924. if (elesCounter[i].textContent.trim() != j)
  1925. {
  1926. elesCounter[i].textContent = j;
  1927. }
  1928. j++;
  1929. }
  1930. }
  1931. }
  1932. else
  1933. {
  1934. var elesDiv = document.querySelectorAll("#keylist td:nth-child(1) > div");
  1935. for (var i = 0; i < elesDiv.length; i++)
  1936. {
  1937. var eleNew = document.createElement("span");
  1938. eleNew.classList.add("stsh_lineCounter_outer");
  1939. eleNew.innerHTML =
  1940. ' <span class="stsh_lineCounter"> '
  1941. + (i + 1)
  1942. + ' </span> ';
  1943. elesDiv[i].appendChild(eleNew);
  1944. }
  1945. }
  1946. }
  1947. addLineCounter();
  1948. setIntervalCustom(addLineCounter, 1000);
  1949. // End Line Counter
  1950. // Hide suggestions
  1951. {
  1952. function hideSuggestions(mode)
  1953. {
  1954. // mode: 0-5 (0: "Not Translated", 1: "Suggested", 2: "Resuggested", 3: "Approved", 4: "Declined", 5: "Translated")
  1955.  
  1956. if (!isVisible()) return;
  1957. if (mode < 0 || mode > 5) return;
  1958.  
  1959. var display = "none";
  1960. var txtApprove = "ready for Admin";
  1961. var txtDecline = "ready for removal";
  1962. var txtSuggest = "suggestion";
  1963. var trKeys = document.querySelectorAll("#keylist > table:nth-child(1) > tbody:nth-child(1) > tr");
  1964. for (var i = 0; i < trKeys.length; i++)
  1965. {
  1966. if (trKeys[i].style.display != display)
  1967. {
  1968. var curMode = -1;
  1969.  
  1970. var eleCounter = trKeys[i].querySelector("tr.copysmall > td:nth-child(3)");
  1971. if (eleCounter != null)
  1972. {
  1973.  
  1974. var txtCounter = eleCounter.textContent.trim();
  1975. if (txtCounter.indexOf(txtApprove) > -1)
  1976. {
  1977. curMode = 3; // Approved
  1978. }
  1979. else if (txtCounter.indexOf(txtDecline) > -1)
  1980. {
  1981. curMode = 4; // Declined
  1982. }
  1983. else if (txtCounter.indexOf(txtSuggest) > -1)
  1984. {
  1985. var eleNotTranslated = trKeys[i].querySelector("span.token_nottranslated");
  1986. if (eleNotTranslated != null)
  1987. {
  1988. curMode = 1; // Suggested
  1989. }
  1990. else
  1991. {
  1992. curMode = 2; // Resuggested
  1993. }
  1994. }
  1995. else
  1996. {
  1997. var eleNotTranslated = trKeys[i].querySelector("span.token_nottranslated");
  1998. if (eleNotTranslated != null)
  1999. {
  2000. curMode = 0; // Not Translated
  2001. }
  2002. else
  2003. {
  2004. curMode = 5; // Translated
  2005. }
  2006. }
  2007. }
  2008.  
  2009. if (curMode == mode)
  2010. {
  2011. trKeys[i].style.display = display;
  2012. }
  2013. }
  2014. }
  2015. }
  2016.  
  2017. var itvTime = 300;
  2018. var itvIdHider = [0, 0, 0, 0, 0, 0];
  2019.  
  2020. var eleBtnShowings = document.querySelectorAll("#stsh_showing_notTranslated, #stsh_showing_suggested, #stsh_showing_resuggested"
  2021. + ", #stsh_showing_approved, #stsh_showing_declined, #stsh_showing_translated");
  2022. if (eleBtnShowings.length == 6)
  2023. {
  2024. for (var i = 0; i < eleBtnShowings.length; i++)
  2025. {
  2026. eleBtnShowings[i].param = i;
  2027. eleBtnShowings[i].addEventListener("click", function(ev)
  2028. {
  2029. var mode = ev.target.param;
  2030.  
  2031. clearInterval(itvIdHider[mode]);
  2032. itvIdHider[mode] = setIntervalCustom(function(ev)
  2033. {
  2034. hideSuggestions(mode);
  2035. }, itvTime);
  2036.  
  2037. hideSuggestions(mode);
  2038. countShowing();
  2039. eleBtnShowings[mode].setAttribute("disabled", "disabled");
  2040. });
  2041. }
  2042.  
  2043. var eleBtnShowAll = document.querySelector("#stsh_showing_all");
  2044. if (eleBtnShowAll != null)
  2045. {
  2046. eleBtnShowAll.addEventListener("click", function()
  2047. {
  2048. for (var i = 0; i < eleBtnShowings.length; i++)
  2049. {
  2050. clearInterval(itvIdHider[i]);
  2051. countShowing();
  2052. eleBtnShowings[i].removeAttribute("disabled");
  2053. }
  2054. });
  2055. }
  2056. }
  2057.  
  2058. } // End Hide suggestions
  2059.  
  2060. resizeSuggestionBox();
  2061. // Add Frame button when iframe load failed
  2062. {
  2063. var ifrm = document.querySelector("#suggestions_iframe");
  2064. if (ifrm != null)
  2065. {
  2066. ifrm.addEventListener("DOMAttrModified", function (ev)
  2067. {
  2068. if (ev.attrName === "src")
  2069. {
  2070. var divFrame = document.querySelector("#stsh_frame");
  2071. if (divFrame == null)
  2072. {
  2073. var divOuter = document.querySelector("#suggestions_box_outer");
  2074. if (divOuter != null)
  2075. {
  2076. divFrame = document.createElement("div");
  2077. divFrame.id = "stsh_frame";
  2078. divOuter.appendChild(divFrame);
  2079. }
  2080. }
  2081. if (divFrame != null)
  2082. {
  2083. var src = ifrm.getAttribute("src");
  2084. divFrame.innerHTML = '<br/> <a class="stsh_a_button" target="_blank" '
  2085. + ' href="' + src + '">Frame</a> ';
  2086. }
  2087. }
  2088. }, false);
  2089. }
  2090. }
  2091. } // End translate.php
  2092.  
  2093. if (url.indexOf("user_activity.php") > -1)
  2094. {
  2095. var user = "";
  2096. var eleAvatar = document.querySelector(".friend_block_avatar > a[href^='https://steamcommunity.com']");
  2097. if (eleAvatar != null)
  2098. {
  2099. eleAvatar.href = eleAvatar.href.replace("https://steamcommunity.com", "http://steamcommunity.com");
  2100. if (eleAvatar.href.indexOf("http://steamcommunity.com/profiles/") == 0)
  2101. {
  2102. user = eleAvatar.href.replace("http://steamcommunity.com/profiles/", "");
  2103. }
  2104. var name = eleAvatar.firstElementChild.getAttribute("title");
  2105. if (name == "")
  2106. {
  2107. name = user;
  2108. }
  2109. document.title = name + " - " + document.title;
  2110. }
  2111.  
  2112. var stsh_activityAddLink_start = new Date();
  2113. var stsh_activityAddLink_itv = setIntervalCustom(function(user)
  2114. {
  2115. var stsh_activityAddLink_isEnd = false;
  2116. var stsh_activityAddLink_cur = new Date();
  2117. var h3s = document.querySelectorAll("#leftAreaContainer h3");
  2118. if (h3s.length == 2)
  2119. {
  2120. var td = h3s[1].parentElement;
  2121. var matchArr = td.innerHTML.match(/<\/h3>.+<br>/i);
  2122. if (matchArr != null)
  2123. {
  2124. var name = matchArr[0].replace("</h3>-","").replace("-<br>","").replace("<br>","").trim();
  2125. if (name == "")
  2126. {
  2127. name = user;
  2128. }
  2129. if (name == "")
  2130. {
  2131. name = "Steam";
  2132. }
  2133. var tagNew = "";
  2134. if (user == "")
  2135. {
  2136. tagNew = "</h3><a id='stsh_id' class='stsh_blue' target='_blank' href='http://steamcommunity.com/my'>" + name + "</a>"
  2137. + ", <a class='stsh_green' target='_blank' href='http://translation.steampowered.com/WhereIsEsty.php'>Esty</a><br><br>";
  2138. }
  2139. else
  2140. {
  2141. tagNew = "</h3><a id='stsh_id' class='stsh_blue' target='_blank' href='http://steamcommunity.com/profiles/"
  2142. + user + "'>" + name + "</a>"
  2143. + ", <a class='stsh_green' target='_blank' href='http://translation.steampowered.com/WhereIsEsty.php?collectionof="
  2144. + user + "'>Esty</a>"
  2145. /*+ ", <a class='stsh_green' target='_blank' href='http://translation.steampowered.com/translate.php?user="
  2146. + user + "&onionhunter=1&liststatus=1'>Onion</a>*/
  2147. + " <br><br> ";
  2148. }
  2149. td.innerHTML = td.innerHTML.replace(/<\/h3>.+<br>/i, tagNew);
  2150. stsh_activityAddLink_isEnd = true;
  2151. }
  2152. if (stsh_activityAddLink_isEnd || stsh_activityAddLink_cur - stsh_activityAddLink_start > 10000)
  2153. {
  2154. clearInterval(stsh_activityAddLink_itv);
  2155. }
  2156. }
  2157. }, 300, user);
  2158. var countWord = "";
  2159. var countSugg = "";
  2160. var inputDials = document.querySelectorAll("#leftAreaContainer input.dial");
  2161. if (inputDials.length == 2)
  2162. {
  2163. countWord = inputDials[0].getAttribute("title").replace("words", "").trim();
  2164. countSugg = inputDials[1].getAttribute("title").replace("suggestions", "").trim();
  2165. }
  2166. var tdCount = document.querySelector("#leftAreaContainer td[align='left']");
  2167. if (tdCount != null)
  2168. {
  2169. tdCount.innerHTML = '<div style="width: 100px; display: inline-block; text-align: center;">Word: '
  2170. + countWord + '</div> <div style="width: 100px; display: inline-block; text-align: center; margin-left: 13px;">Suggestion: '
  2171. + countSugg + '</div>';
  2172. }
  2173. var sug = document.body.textContent;
  2174. var regComment = /VIEW COMMENT/g;
  2175. var regSuggest = /VIEW SUGGESTION/g;
  2176. var strComment = "...RECEIVED A MODERATOR COMMENT";
  2177. var strPending = "...ARE PENDING";
  2178. var strApproved = "...WERE APPROVED";
  2179. var strDeclined = "...WERE DECLINED";
  2180. var strApplied = "...HAVE BEEN APPLIED WITHIN THE LAST 14 DAYS";
  2181. var strRemoved = "...HAVE BEEN REMOVED WITHIN THE LAST 14 DAYS";
  2182. var startComment = sug.indexOf(strComment);
  2183. var startPending = sug.indexOf(strPending);
  2184. var startApproved = sug.indexOf(strApproved);
  2185. var startDeclined = sug.indexOf(strDeclined);
  2186. var startApplied = sug.indexOf(strApplied);
  2187. var startRemoved = sug.indexOf(strRemoved);
  2188. var sugComment = sug.substring(startComment,startPending);
  2189. var sugPending = sug.substring(startPending,startApproved);
  2190. var sugApproved = sug.substring(startApproved,startDeclined);
  2191. var sugDeclined = sug.substring(startDeclined,startApplied);
  2192. var sugApplied = sug.substring(startApplied,startRemoved);
  2193. var sugRemoved = sug.substring(startRemoved);
  2194. var countComment = (sugComment.match(regComment) || []).length;
  2195. var countPending = (sugPending.match(regSuggest) || []).length;
  2196. var countApproved = (sugApproved.match(regSuggest) || []).length;
  2197. var countDeclined = (sugDeclined.match(regSuggest) || []).length;
  2198. var countApplied = (sugApplied.match(regSuggest) || []).length;
  2199. var countRemoved = (sugRemoved.match(regSuggest) || []).length;
  2200. var divBtn = document.createElement("div");
  2201. document.body.appendChild(divBtn);
  2202. divBtn.innerHTML = ' \
  2203. <div style="position: fixed; z-index: 3; right: 12px; top: 84px; line-height: 24px; text-align: right;"> \
  2204. &nbsp; <input value="To Progress" class="stsh_btn_long" type="button" onmouseup="scrollToId(\'stsh_id\', -50); return false;" /> \
  2205. \
  2206. <br/> &nbsp; <span class="stsh_scroll_header">Scroll To</span>\
  2207. <br/> &nbsp; <input value="Comment (' + countComment + ')" class="stsh_btn_long" type="button" onmouseup="scrollToId(\'sectionComment\'); return false;" /> \
  2208. <br/> &nbsp; <input value="Pending (' + countPending + ')" class="stsh_btn_long" type="button" onmouseup="scrollToId(\'sectionPending\'); return false;" /> \
  2209. <br/> &nbsp; <input value="Approved (' + countApproved + ')" class="stsh_btn_long" type="button" onmouseup="scrollToId(\'sectionApproved\'); return false;" /> \
  2210. <br/> &nbsp; <input value="Declined (' + countDeclined + ')" class="stsh_btn_long" type="button" onmouseup="scrollToId(\'sectionDeclined\'); return false;" /> \
  2211. <br/> &nbsp; <input value="Applied (' + countApplied + ')" class="stsh_btn_long" type="button" onmouseup="scrollToId(\'sectionApplied\'); return false;" /> \
  2212. <br/> &nbsp; <input value="Removed (' + countRemoved + ')" class="stsh_btn_long" type="button" onmouseup="scrollToId(\'sectionRemoved\'); return false;" /> \
  2213. <br/> \
  2214. <br/> &nbsp; <input value="Hide Suggestions" class="stsh_btn_long" type="button" onmouseup="hideSuggestion(); return false;" /> \
  2215. <br/> &nbsp; <input value="Show Suggestions" class="stsh_btn_long" type="button" onmouseup="showSuggestion(); return false;" /> \
  2216. <br/> \
  2217. <br/> &nbsp; <input value="Refresh" class="stsh_btn_long" type="button" onmouseup="window.location = window.location.href; return false;" /> \
  2218. </div> \
  2219. ';
  2220.  
  2221. var divContainer = document.querySelector("#leftAreaContainer");
  2222. if (divContainer != null)
  2223. {
  2224. divContainer.innerHTML = divContainer.innerHTML
  2225. .replace("...RECEIVED A MODERATOR COMMENT","<span id='sectionComment' class='stsh_suggestion_header'>...RECEIVED A MODERATOR COMMENT (" + countComment + ")</span>")
  2226. .replace("...ARE PENDING","<span id='sectionPending' class='stsh_suggestion_header'>...ARE PENDING (" + countPending + ")</span>")
  2227. .replace("...WERE APPROVED","<span id='sectionApproved' class='stsh_suggestion_header'>...WERE APPROVED (" + countApproved + ")</span>")
  2228. .replace("...WERE DECLINED","<span id='sectionDeclined' class='stsh_suggestion_header'>...WERE DECLINED (" + countDeclined + ")</span>")
  2229. .replace("...HAVE BEEN APPLIED WITHIN THE LAST 14 DAYS","<span id='sectionApplied' class='stsh_suggestion_header'>...HAVE BEEN APPLIED WITHIN THE LAST 14 DAYS (" + countApplied + ")</span>")
  2230. .replace("...HAVE BEEN REMOVED WITHIN THE LAST 14 DAYS","<span id='sectionRemoved' class='stsh_suggestion_header'>...HAVE BEEN REMOVED WITHIN THE LAST 14 DAYS (" + countRemoved + ")</span>");
  2231. }
  2232. var cans = document.querySelectorAll("canvas");
  2233. for (var i = 0; i < cans.length; i++)
  2234. {
  2235. cans[i].parentElement.removeChild(cans[i]);
  2236. }
  2237. var aKeys = document.querySelectorAll("#leftAreaContainer li > a:nth-child(1)");
  2238. for (var i = 0; i < aKeys.length; i++)
  2239. {
  2240. var key = aKeys[i].textContent;
  2241. var keyArr = key.substr(21).trim().split(" >> ");
  2242. keyArr[0] = "<span style='color: #FFF !important;'>" + keyArr[0] + "</span>";
  2243. var keyNew = key.substr(0,21) + keyArr.join(" >> ") + "";
  2244. aKeys[i].innerHTML = keyNew;
  2245. }
  2246. var liMode = strComment;
  2247. var liSugs = document.querySelectorAll("#leftAreaContainer > li, #leftAreaContainer > form > li");
  2248. for (var i = 0; i < liSugs.length; i++)
  2249. {
  2250. if (liMode == strComment)
  2251. {
  2252. liSugs[i].setAttribute("class", "stsh_suggestion stsh_suggestion_comment");
  2253. }
  2254. else if (liMode == strPending)
  2255. {
  2256. liSugs[i].setAttribute("class", "stsh_suggestion stsh_suggestion_pending");
  2257. }
  2258. else if (liMode == strApproved)
  2259. {
  2260. liSugs[i].setAttribute("class", "stsh_suggestion stsh_suggestion_approved");
  2261. }
  2262. else if (liMode == strDeclined)
  2263. {
  2264. liSugs[i].setAttribute("class", "stsh_suggestion stsh_suggestion_declined");
  2265. }
  2266. else if (liMode == strApplied)
  2267. {
  2268. liSugs[i].setAttribute("class", "stsh_suggestion stsh_suggestion_applied");
  2269. }
  2270. else if (liMode == strRemoved)
  2271. {
  2272. liSugs[i].setAttribute("class", "stsh_suggestion stsh_suggestion_removed");
  2273. }
  2274. var content = liSugs[i].textContent;
  2275. if (content.indexOf(strRemoved) > -1)
  2276. {
  2277. liMode = strRemoved;
  2278. }
  2279. else if (content.indexOf(strApplied) > -1)
  2280. {
  2281. liMode = strApplied;
  2282. }
  2283. else if (content.indexOf(strDeclined) > -1)
  2284. {
  2285. liMode = strDeclined;
  2286. }
  2287. else if (content.indexOf(strApproved) > -1)
  2288. {
  2289. liMode = strApproved;
  2290. }
  2291. else if (content.indexOf(strPending) > -1)
  2292. {
  2293. liMode = strPending;
  2294. }
  2295. }
  2296. // Change language & correct url
  2297. {
  2298. var aProgresses = document.querySelectorAll("div > .friend_block_avatar a[onmouseout]");
  2299. for (var i = 0; i < aProgresses.length; i++)
  2300. {
  2301. var langCur = getQueryByName("lang", aProgresses[i].href);
  2302. if (langCur == "")
  2303. {
  2304. aProgresses[i].href = aProgresses[i].href + lang;
  2305. }
  2306. else
  2307. {
  2308. if (langCur != lang)
  2309. {
  2310. var langQuery = (url.indexOf("?") > -1) ? "&lang=" : "?lang=";
  2311. window.location = url + langQuery + langCur;
  2312. }
  2313. }
  2314. var aContent = aProgresses[i].textContent.trim();
  2315. if (aContent.indexOf("SUGGESTIONS") > -1)
  2316. {
  2317. aProgresses[i].href = aProgresses[i].href + "&listsort=5&liststatus=1&paginationrows=1000";
  2318. }
  2319. else if (aContent.indexOf("REVIEWS") > -1)
  2320. {
  2321. aProgresses[i].href = aProgresses[i].href + "&listsort=5&liststatus=3&paginationrows=1000";
  2322. }
  2323. }
  2324. }
  2325. // Add hours calculator
  2326. {
  2327. var eleFinalize = document.querySelector("#hours input[name='Finalize']");
  2328. if (eleFinalize != null)
  2329. {
  2330. var eleFinalizeParent = eleFinalize.parentElement;
  2331. eleFinalizeParent.setAttribute("colspan", "2");
  2332. eleFinalizeParent.style.verticalAlign = "top";
  2333. var elePad = document.createElement("td");
  2334. insertBeforeElement(elePad, eleFinalizeParent);
  2335. var eleCalc = document.createElement("td");
  2336. eleCalc.classList.add("stsh_hoursCalc");
  2337. insertBeforeElement(eleCalc, eleFinalizeParent);
  2338. var ele = document.createElement("b");
  2339. ele.textContent = " Hours Calculator ";
  2340. eleCalc.appendChild(ele);
  2341. ele = document.createElement("br");
  2342. eleCalc.appendChild(ele);
  2343. var ele = document.createElement("span");
  2344. ele.innerHTML = " Enter date or time to calculate range (calculate only hours and minutes). "
  2345. + "<br/>You can enter date \"2016-01-01 08:05:00\" or time \"08:05:00\" or time \"8:05\".";
  2346. ele.setAttribute("style", "display: inline-block; padding-bottom: 4px;");
  2347. eleCalc.appendChild(ele);
  2348. ele = document.createElement("br");
  2349. eleCalc.appendChild(ele);
  2350. var ele = document.createElement("span");
  2351. ele.textContent = " From: ";
  2352. eleCalc.appendChild(ele);
  2353. var ele = document.createElement("input");
  2354. ele.id = "stsh_hoursCalc_from"
  2355. ele.setAttribute("type", "text");
  2356. ele.setAttribute("onkeypress", "return event.keyCode != 13;");
  2357. ele.addEventListener("keyup", function()
  2358. {
  2359. calculateHours();
  2360. });
  2361. eleCalc.appendChild(ele);
  2362. var ele = document.createElement("span");
  2363. ele.innerHTML = "&nbsp;&nbsp; To: ";
  2364. eleCalc.appendChild(ele);
  2365. var ele = document.createElement("input");
  2366. ele.id = "stsh_hoursCalc_to"
  2367. ele.setAttribute("type", "text");
  2368. ele.setAttribute("onkeypress", "return event.keyCode != 13;");
  2369. ele.addEventListener("keyup", function()
  2370. {
  2371. calculateHours();
  2372. });
  2373. eleCalc.appendChild(ele);
  2374. var ele = document.createElement("span");
  2375. ele.innerHTML = "&nbsp;&nbsp; Result: ";
  2376. eleCalc.appendChild(ele);
  2377. var ele = document.createElement("b");
  2378. ele.id = "stsh_hoursCalc_result"
  2379. ele.textContent = " 00:00 ";
  2380. eleCalc.appendChild(ele);
  2381. function calculateHours()
  2382. {
  2383. var rgxDate = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/;
  2384. var rgxTime = /^\d{1,2}:\d{2}(:\d{2})?$/;
  2385. var eleFrom = document.querySelector("#stsh_hoursCalc_from");
  2386. var eleTo = document.querySelector("#stsh_hoursCalc_to");
  2387. var eleRes = document.querySelector("#stsh_hoursCalc_result");
  2388. if (eleFrom != null && eleTo != null && eleRes != null)
  2389. {
  2390. var rawFrom = eleFrom.value.trim();
  2391. var rawTo = eleTo.value.trim();
  2392. var valFrom = 0;
  2393. var valTo = 0;
  2394. if (rgxDate.test(rawFrom))
  2395. {
  2396. rawFrom = rawFrom.substr(11);
  2397. }
  2398. if (rgxTime.test(rawFrom))
  2399. {
  2400. var arrTime = rawFrom.split(":");
  2401. valFrom = parseInt(arrTime[1]) + (parseInt(arrTime[0]) * 60);
  2402. }
  2403. if (rgxDate.test(rawTo))
  2404. {
  2405. rawTo = rawTo.substr(11);
  2406. }
  2407. if (rgxTime.test(rawTo))
  2408. {
  2409. var arrTime = rawTo.split(":");
  2410. valTo = parseInt(arrTime[1]) + (parseInt(arrTime[0]) * 60);
  2411. }
  2412. var valDiff = Math.abs(valTo - valFrom);
  2413. var valHr = parseInt(valDiff / 60);
  2414. var valMn = valDiff % 60;
  2415. eleRes.textContent = padZero(valHr, 2) + ":" + padZero(valMn, 2);
  2416. }
  2417. }
  2418. }
  2419. }
  2420. } // End user_activity.php
  2421. if (/\/rally[0-9]{0,4}/.test(url))
  2422. {
  2423. resizeSuggestionBox();
  2424. var outer = document.getElementById("suggestions_box_outer");
  2425. if (outer != null)
  2426. {
  2427. outer.setAttribute("onclick","hideSuggestionsBox();");
  2428. }
  2429. // Set cur lang to first
  2430. {
  2431. var first = document.querySelector(".gradienttable tr:nth-child(6)");
  2432. var cur = null;
  2433. var tdLangs = document.querySelectorAll(".gradienttable tr > td:nth-child(1)");
  2434. for (var i = 0; i < tdLangs.length; i++)
  2435. {
  2436. if (lang == tdLangs[i].textContent.trim().toLowerCase())
  2437. {
  2438. cur = tdLangs[i].parentElement;
  2439. break;
  2440. }
  2441. }
  2442. if (cur != null)
  2443. {
  2444. first.parentElement.insertBefore(cur, first);
  2445. }
  2446. }
  2447. // Change row per page
  2448. {
  2449. var eleAs = document.querySelectorAll(".gradienttable tr:nth-child(6) a[href^='translate.php?']");
  2450. for (var i = 0; i < eleAs.length; i++)
  2451. {
  2452. eleAs[i].href = eleAs[i].href + "&paginationrows=1000";
  2453. }
  2454. }
  2455. var inputClose = document.querySelector("td:nth-child(3) > input:nth-child(1)");
  2456. if (inputClose != null)
  2457. {
  2458. inputClose.value = "Close (Esc)";
  2459. }
  2460. } // End rally.php
  2461. if (/\/rally_results_?[0-9]{0,4}/.test(url))
  2462. {
  2463. var h3 = document.querySelector("table.curved h3");
  2464. if (h3 != null)
  2465. {
  2466. document.title = h3.textContent.trim();
  2467. }
  2468. var inputClose = document.querySelector("td:nth-child(3) > input:nth-child(1)");
  2469. if (inputClose != null)
  2470. {
  2471. inputClose.value = "Close (Esc)";
  2472. inputClose.focus();
  2473. }
  2474. var src = document.documentURI;
  2475. var insert = ' <a class="stsh_a_button" target="_blank" '
  2476. + ' href="' + src + '">Frame</a> ';
  2477. var tdFirst = document.querySelector("td:nth-child(1)");
  2478. if (tdFirst != null)
  2479. {
  2480. var ele = document.createElement("td");
  2481. ele.setAttribute("align", "right");
  2482. ele.innerHTML = insert;
  2483. tdFirst.parentElement.insertBefore(ele, tdFirst);
  2484. }
  2485. var inputPrev = document.querySelector("input[value^='Prev']");
  2486. if (inputPrev != null)
  2487. {
  2488. addKeyCtrl(document, inputPrev, 219, "["); // [
  2489. addKeyCtrl(document, inputPrev, "BracketLeft", ""); // [
  2490. //addKeyCtrl(document, inputPrev, 0, ""); // [
  2491. //addKeyCtrl(document, inputPrev, 53, ""); // [
  2492. disableAfterClick(inputPrev);
  2493. }
  2494. var inputNext = document.querySelector("input[value^='Next']");
  2495. if (inputNext != null)
  2496. {
  2497. addKeyCtrl(document, inputNext, 221, "]"); // ]
  2498. addKeyCtrl(document, inputNext, "BracketRight", ""); // ]
  2499. //addKeyCtrl(document, inputNext, 188, ""); // ]
  2500. //addKeyCtrl(document, inputNext, 173, ""); // ]
  2501. //addKeyCtrl(document, inputNext, 169, ""); // ]
  2502. disableAfterClick(inputNext);
  2503. }
  2504. } // End rally_results.php
  2505. if (url.indexOf("/WhereIsEsty.php") > -1)
  2506. {
  2507. resizeSuggestionBox();
  2508. var outer = document.getElementById("suggestions_box_outer");
  2509. if (outer != null)
  2510. {
  2511. outer.setAttribute("onclick","hideSuggestionsBox();");
  2512. }
  2513. var divContainer = document.querySelector("#pageContainer");
  2514. if (divContainer != null)
  2515. {
  2516. var ele = document.createElement("div");
  2517. ele.id = "logout";
  2518. ele.innerHTML = ' <a class="stsh_a_button" target="_blank" '
  2519. + ' href="/home.php">Home</a> ';
  2520. divContainer.appendChild(ele);
  2521. }
  2522.  
  2523. var divContent = document.querySelector("#leftAreaContainer > div");
  2524. if (divContent != null)
  2525. {
  2526. var countSnap = document.querySelectorAll("div.box").length;
  2527. var user = "";
  2528. var name = "";
  2529.  
  2530. var eleImg = document.querySelector("#leftAreaContainer > div > div > a > img ");
  2531. if (eleImg != null)
  2532. {
  2533. name = eleImg.getAttribute("title");
  2534. user = eleImg.parentElement.getAttribute("href").replace("https://steamcommunity.com/profiles/", "");
  2535. }
  2536. var ele = document.createElement("div");
  2537. ele.setAttribute("class", "stsh_snapshot");
  2538. ele.innerHTML = "<a class='stsh_blue' target='_blank' href='http://translation.steampowered.com/user_activity.php?user="
  2539. + user + "'>" + name + "</a>"
  2540. + "<br>Snapshot: " + countSnap;
  2541.  
  2542. divContent.appendChild(ele);
  2543. }
  2544. } // End WhereIsEsty.php
  2545. if (url.indexOf("/stickerbox.php") > -1)
  2546. {
  2547. document.querySelector("textarea[name='add_comment']").focus();
  2548.  
  2549. var inputPrev = document.querySelector("img[src*='previous.png'");
  2550. if (inputPrev != null)
  2551. {
  2552. addKeyCtrl(document, inputPrev, 219, ""); // [
  2553. addKeyCtrl(document, inputPrev, "BracketLeft", ""); // [
  2554. //addKeyCtrl(document, inputPrev, 0, ""); // [
  2555. //addKeyCtrl(document, inputPrev, 53, ""); // [
  2556. disableAfterClick(inputPrev);
  2557. }
  2558. var inputNext = document.querySelector("img[src*='next.png'");
  2559. if (inputNext != null)
  2560. {
  2561. addKeyCtrl(document, inputNext, 221, ""); // ]
  2562. addKeyCtrl(document, inputNext, "BracketRight", ""); // ]
  2563. //addKeyCtrl(document, inputNext, 188, ""); // ]
  2564. //addKeyCtrl(document, inputNext, 173, ""); // ]
  2565. //addKeyCtrl(document, inputNext, 169, ""); // ]
  2566. disableAfterClick(inputNext);
  2567. }
  2568. } // End stickerbox.php
  2569. if (/\/(home|index)/i.test(url))
  2570. {
  2571. // Set cur lang to first
  2572. {
  2573. var first = null;
  2574. var cur = null;
  2575. var curLang = lang.substring(0, 4);
  2576. if (curLang == "schi")
  2577. curLang = "sim.";
  2578. else if (curLang == "tchi")
  2579. curLang = "tra.";
  2580. var eleLangs = document.querySelectorAll("#overall .progress");
  2581. first = eleLangs[0];
  2582. for (var i = 0; i < eleLangs.length; i++)
  2583. {
  2584. if (curLang == eleLangs[i].textContent.trim().substring(0, 4).toLowerCase())
  2585. {
  2586. cur = eleLangs[i];
  2587. break;
  2588. }
  2589. }
  2590. if (cur != null)
  2591. {
  2592. var curSib1 = cur.nextSibling;
  2593. var curSib2 = curSib1.nextSibling;
  2594. var curSib3 = curSib2.nextSibling;
  2595. var curSib4 = curSib3.nextSibling;
  2596. var curSib5 = curSib4.nextSibling;
  2597. var curSib6 = curSib5.nextSibling;
  2598. insertBeforeElement(cur, first);
  2599. insertAfterElement(curSib6, cur);
  2600. insertAfterElement(curSib5, cur);
  2601. insertAfterElement(curSib4, cur);
  2602. insertAfterElement(curSib3, cur);
  2603. insertAfterElement(curSib2, cur);
  2604. insertAfterElement(curSib1, cur);
  2605. }
  2606. }
  2607. if (document.querySelector("#logout") != null)
  2608. {
  2609. var tmplHome = ' \
  2610. <div class="stsh_home_group"> \
  2611. <span class="stsh_home_header">Shortcuts</span>\
  2612. <br/> &nbsp; <a class="stsh_a_button stsh_btn_med" target="_blank" href="/translate.php?search_input=DATE%3A+%DATE%&paginationrows=1000">New Today</a> &nbsp; \
  2613. <br/> &nbsp; <a class="stsh_a_button stsh_btn_med" target="_blank" href="/glossary.php">Glossary</a> &nbsp; \
  2614. \
  2615. <br/> <span class="stsh_home_header">Rally</span>\
  2616. <br/> &nbsp; <a class="stsh_a_button stsh_btn_med" target="_blank" href="/rally.php">Rally 2015</a> &nbsp; \
  2617. <br/> &nbsp; <a class="stsh_a_button stsh_btn_med" target="_blank" href="/rally2014.php">Rally 2014</a> &nbsp; \
  2618. <br/> &nbsp; <a class="stsh_a_button stsh_btn_med" target="_blank" href="/rally2013.php">Rally 2013</a> &nbsp; \
  2619. \
  2620. <br/> <span class="stsh_home_header">Events</span>\
  2621. <br/> &nbsp; <a class="stsh_a_button stsh_btn_med" target="_blank" href="/onionolooorm.php">Typonion</a> &nbsp; \
  2622. <br/> &nbsp; <a class="stsh_a_button stsh_btn_med" target="_blank" href="/dstbattle.php">DST Battle</a> &nbsp; \
  2623. <br/> &nbsp; <a class="stsh_a_button stsh_btn_med" target="_blank" href="/dota2.php">DOTA 2</a> &nbsp; \
  2624. </div> \
  2625. ';
  2626. var curDate = new Date();
  2627. curDate.setTime(curDate.getTime() - (1000 * 60 * 60 * 8));
  2628. if (isDstUsa(curDate.getUTCFullYear(), curDate.getUTCMonth() + 1, curDate.getUTCDate(), curDate.getUTCHours()))
  2629. {
  2630. curDate.setTime(curDate.getTime() + (1000 * 60 * 60 * 1));
  2631. }
  2632. tmplHome = tmplHome.replace("%DATE%", curDate.toISOString().substr(0, 10));
  2633. var eleNew = document.createElement("div");
  2634. eleNew.innerHTML = tmplHome;
  2635. document.body.appendChild(eleNew);
  2636. }
  2637. } // End home.php
  2638. if (url.indexOf("/glossary.php") > -1)
  2639. {
  2640. } // End glossary.php
  2641. window.addEventListener("beforeunload", function (e)
  2642. {
  2643. clearTimeoutAll();
  2644. clearIntervalAll();
  2645. });
  2646. } // End Main
  2647.  
  2648. function client()
  2649. {
  2650. var clientScript = ' \
  2651. \
  2652. var itvTime = 300; \
  2653. var itvIdHideKeyApp = 0; \
  2654. var itvIdHideKeyGame = 0; \
  2655. var itvIdHideKeyFaq = 0; \
  2656. var itvIdHideKeySupport = 0; \
  2657. var itvIdHideKeyPromo = 0; \
  2658. var itvIdHideKeyEmail = 0; \
  2659. var itvIdHideStrNotMatch = 0; \
  2660. var itvIdHideStrLong = 0; \
  2661. var itvIdSortKey = 0; \
  2662. \
  2663. var isVisible = (function() \
  2664. { \
  2665. var stateKey; \
  2666. var eventKey; \
  2667. var keys = \
  2668. { \
  2669. hidden: "visibilitychange", \
  2670. webkitHidden: "webkitvisibilitychange", \
  2671. mozHidden: "mozvisibilitychange", \
  2672. msHidden: "msvisibilitychange" \
  2673. }; \
  2674. for (stateKey in keys) \
  2675. { \
  2676. if (stateKey in document) \
  2677. { \
  2678. eventKey = keys[stateKey]; \
  2679. break; \
  2680. } \
  2681. } \
  2682. return function(c) \
  2683. { \
  2684. if (c) \
  2685. { \
  2686. document.addEventListener(eventKey, c); \
  2687. } \
  2688. return !document[stateKey]; \
  2689. } \
  2690. })(); \
  2691. \
  2692. var timeoutList = new Array(); \
  2693. var intervalList = new Array(); \
  2694. \
  2695. function setTimeoutCustom(func, tm, params) \
  2696. { \
  2697. var id = setTimeout(func, tm, params); \
  2698. timeoutList.push(id); \
  2699. return id; \
  2700. } \
  2701. \
  2702. function clearTimeoutAll() \
  2703. { \
  2704. for (var i = 0; i < timeoutList.length; i++) \
  2705. { \
  2706. clearTimeout(timeoutList[i]); \
  2707. } \
  2708. } \
  2709. \
  2710. function setIntervalCustom(func, tm, params) \
  2711. { \
  2712. var id = setInterval(func, tm, params); \
  2713. intervalList.push(id); \
  2714. return id; \
  2715. } \
  2716. \
  2717. function clearIntervalAll() \
  2718. { \
  2719. for (var i = 0; i < intervalList.length; i++) \
  2720. { \
  2721. clearInterval(intervalList[i]); \
  2722. } \
  2723. } \
  2724. \
  2725. function setVisibleKey(startKey, visible) \
  2726. { \
  2727. if (!isVisible()) return; \
  2728. \
  2729. startKey = startKey.toLowerCase(); \
  2730. var display = visible != true ? "none" : ""; \
  2731. var eleKeys = document.querySelectorAll("#keylist > table:nth-child(1) > tbody:nth-child(1) > tr > td:nth-child(1) > div:nth-child(1) > table:nth-child(1) > tbody:nth-child(2) > tr:nth-child(1) > td:nth-child(1)"); \
  2732. for (var i = 0; i < eleKeys.length; i++) \
  2733. { \
  2734. try \
  2735. { \
  2736. if (eleKeys[i].textContent.trim().toLowerCase().indexOf(startKey) > -1) \
  2737. { \
  2738. var eleTarget = eleKeys[i].parentElement.parentElement.parentElement.parentElement.parentElement.parentElement; \
  2739. if (eleTarget.style.display != display) \
  2740. { \
  2741. eleTarget.style.display = display; \
  2742. } \
  2743. } \
  2744. } \
  2745. catch (ex) \
  2746. { \
  2747. } \
  2748. } \
  2749. } \
  2750. \
  2751. function hideKeyGame() \
  2752. { \
  2753. setVisibleKey("GAMES/", false); \
  2754. setVisibleKey("TF_", false); \
  2755. } \
  2756. \
  2757. function hideKeyApp() \
  2758. { \
  2759. setVisibleKey("# storefront_english_apps.txt #", false); \
  2760. setVisibleKey("# storefront_english_main.txt # #app_", false); \
  2761. setVisibleKey("# community_english.txt # SharedFiles_App_", false); \
  2762. setVisibleKey("# appmgmt_english.txt #", false); \
  2763. } \
  2764. \
  2765. function hideKeyFaq() \
  2766. { \
  2767. setVisibleKey("# support_faq_english.txt #", false); \
  2768. } \
  2769. \
  2770. function hideKeySupport() \
  2771. { \
  2772. setVisibleKey("# supportui_english.txt #", false); \
  2773. setVisibleKey("# help_english.txt #", false); \
  2774. } \
  2775. \
  2776. function hideKeyPromo() \
  2777. { \
  2778. setVisibleKey("#promo", false); \
  2779. setVisibleKey("#hardware", false); \
  2780. setVisibleKey("ControllerBinding", false); \
  2781. setVisibleKey("Library_Controller", false); \
  2782. } \
  2783. \
  2784. function hideKeyEmail() \
  2785. { \
  2786. setVisibleKey("#email", false); \
  2787. } \
  2788. \
  2789. function showKey() \
  2790. { \
  2791. clearInterval(itvIdHideKeyApp); \
  2792. clearInterval(itvIdHideKeyGame); \
  2793. clearInterval(itvIdHideKeyFaq); \
  2794. clearInterval(itvIdHideKeySupport); \
  2795. clearInterval(itvIdHideKeyPromo); \
  2796. clearInterval(itvIdHideKeyEmail); \
  2797. clearInterval(itvIdSortKey); \
  2798. clearInterval(itvIdHideStrNotMatch); \
  2799. clearInterval(itvIdHideStrLong); \
  2800. setVisibleKey("", true); \
  2801. \
  2802. hideSuggestionsBox(); \
  2803. } \
  2804. \
  2805. function sortKey(mode) \
  2806. { \
  2807. /* \
  2808. mode: \
  2809. 1: key \
  2810. 2: string \
  2811. 3: word \
  2812. 4: length \
  2813. */ \
  2814. if (!isVisible()) return; \
  2815. \
  2816. var keyArr = new Array(); \
  2817. var valArr = new Array(); \
  2818. var key; \
  2819. var str; \
  2820. \
  2821. var dot = "..."; \
  2822. var dotLengthMinus = 0 - dot.length; \
  2823. var isDot = false; \
  2824. \
  2825. var eleKeys = document.querySelectorAll("#keylist > table:nth-child(1) > tbody:nth-child(1) > tr > td:nth-child(1) > div:nth-child(1) > table:nth-child(1) > tbody:nth-child(2) > tr:nth-child(1) > td:nth-child(1)"); \
  2826. for (var i = 0; i < eleKeys.length; i++) \
  2827. { \
  2828. try \
  2829. { \
  2830. key = eleKeys[i].textContent.trim(); \
  2831. str = ""; \
  2832. isDot = false; \
  2833. if (mode != 1) \
  2834. { \
  2835. str = eleKeys[i].parentElement.nextSibling.nextSibling.firstElementChild.textContent.trim(); \
  2836. isDot = (str.substr(dotLengthMinus) == dot); \
  2837. } \
  2838. if (mode == 2) \
  2839. { \
  2840. key = str + " ___ " + key; \
  2841. } \
  2842. else if (mode == 3) \
  2843. { \
  2844. key = (isDot ? "99_" : "00_") \
  2845. + padZero(str.split(" ").length, 2) + "_" + padZero(str.split(/[^a-z0-9 ]/i).length, 2) \
  2846. + " ___ "+ str + " ___ " + key; \
  2847. } \
  2848. else if (mode == 4) \
  2849. { \
  2850. key = (isDot ? "99_" : "00_") \
  2851. + (str.split(/[^a-z0-9]/i).length > 1 ? "99_" : "00_") \
  2852. + padZero(str.length, 3) \
  2853. + " ___ "+ str + " ___ " + key; \
  2854. } \
  2855. key = key.toLowerCase(); \
  2856. keyArr.push(key); \
  2857. valArr[key] = eleKeys[i].parentElement.parentElement.parentElement \
  2858. .parentElement.parentElement.parentElement.outerHTML.trim(); \
  2859. } \
  2860. catch (ex) \
  2861. { \
  2862. } \
  2863. } \
  2864. \
  2865. var keyArrTmp = keyArr.slice(); \
  2866. keyArr.sort(); \
  2867. \
  2868. var isSame = true; \
  2869. for (var i = 0; i < keyArr.length; i++) \
  2870. { \
  2871. if (keyArr[i] != keyArrTmp[i]) \
  2872. { \
  2873. isSame = false; \
  2874. } \
  2875. } \
  2876. \
  2877. if (!isSame) \
  2878. { \
  2879. var eleTable = document.querySelector("#keylist > table:nth-child(1) > tbody:nth-child(1)"); \
  2880. if (eleTable != null) \
  2881. { \
  2882. var newInner = ""; \
  2883. \
  2884. for (var i = 0; i < keyArr.length; i++) \
  2885. { \
  2886. newInner += valArr[keyArr[i]]; \
  2887. } \
  2888. \
  2889. eleTable.innerHTML = newInner; \
  2890. } \
  2891. } \
  2892. } \
  2893. \
  2894. function scrollToId(id, offset) \
  2895. { \
  2896. if (typeof offset == "undefined") \
  2897. { \
  2898. offset = -20; \
  2899. } \
  2900. \
  2901. var ele = document.getElementById(id); \
  2902. if (ele != null) \
  2903. { \
  2904. ele.scrollIntoView(true); \
  2905. window.scrollBy(0, offset); \
  2906. } \
  2907. } \
  2908. \
  2909. function setVisibleSuggestion(visible) \
  2910. { \
  2911. var display = visible != true ? "none" : ""; \
  2912. var els = document.querySelectorAll(".copy"); \
  2913. for (var i = 0; i < els.length; i++) \
  2914. { \
  2915. if (els[i].id.indexOf("showwalletkeys") < 0 && els[i].id != "abuse_report" \
  2916. && els[i].id != "moderator_announcement") \
  2917. { \
  2918. if (els[i].style.display != display) \
  2919. { \
  2920. els[i].style.display = display; \
  2921. } \
  2922. } \
  2923. } \
  2924. } \
  2925. \
  2926. function showSuggestion() \
  2927. { \
  2928. setVisibleSuggestion(true); \
  2929. } \
  2930. \
  2931. function hideSuggestion() \
  2932. { \
  2933. setVisibleSuggestion(false); \
  2934. } \
  2935. \
  2936. function hideKeyAppInterval() \
  2937. { \
  2938. clearInterval(itvIdHideKeyApp); \
  2939. itvIdHideKeyApp = setIntervalCustom(hideKeyApp, itvTime); \
  2940. } \
  2941. \
  2942. function hideKeyGameInterval() \
  2943. { \
  2944. clearInterval(itvIdHideKeyGame); \
  2945. itvIdHideKeyGame = setIntervalCustom(hideKeyGame, itvTime); \
  2946. } \
  2947. \
  2948. function hideKeyFaqInterval() \
  2949. { \
  2950. clearInterval(itvIdHideKeyFaq); \
  2951. itvIdHideKeyFaq = setIntervalCustom(hideKeyFaq, itvTime); \
  2952. } \
  2953. \
  2954. function hideKeySupportInterval() \
  2955. { \
  2956. clearInterval(itvIdHideKeySupport); \
  2957. itvIdHideKeySupport = setIntervalCustom(hideKeySupport, itvTime); \
  2958. } \
  2959. \
  2960. function hideKeyPromoInterval() \
  2961. { \
  2962. clearInterval(itvIdHideKeyPromo); \
  2963. itvIdHideKeyPromo = setIntervalCustom(hideKeyPromo, itvTime); \
  2964. } \
  2965. \
  2966. function hideKeyEmailInterval() \
  2967. { \
  2968. clearInterval(itvIdHideKeyEmail); \
  2969. itvIdHideKeyEmail = setIntervalCustom(hideKeyEmail, itvTime); \
  2970. } \
  2971. \
  2972. function sortKeyInterval() \
  2973. { \
  2974. clearInterval(itvIdSortKey); \
  2975. itvIdSortKey = setIntervalCustom(sortKey, itvTime, 1); \
  2976. } \
  2977. \
  2978. function sortStringInterval() \
  2979. { \
  2980. clearInterval(itvIdSortKey); \
  2981. itvIdSortKey = setIntervalCustom(sortKey, itvTime, 2); \
  2982. } \
  2983. \
  2984. function sortWordInterval() \
  2985. { \
  2986. clearInterval(itvIdSortKey); \
  2987. itvIdSortKey = setIntervalCustom(sortKey, itvTime, 3); \
  2988. } \
  2989. \
  2990. function sortLengthInterval() \
  2991. { \
  2992. clearInterval(itvIdSortKey); \
  2993. itvIdSortKey = setIntervalCustom(sortKey, itvTime, 4); \
  2994. } \
  2995. \
  2996. function pressHideSuggestion() \
  2997. { \
  2998. document.addEventListener("keydown", function(e) { \
  2999. if (e.keyCode == 27) { \
  3000. if (parent != null) \
  3001. { \
  3002. parent.hideSuggestionsBox(); \
  3003. } \
  3004. else \
  3005. { \
  3006. hideSuggestionsBox(); \
  3007. } \
  3008. } \
  3009. return false; \
  3010. }); \
  3011. } \
  3012. pressHideSuggestion(); \
  3013. \
  3014. function hideStrNotMatch() \
  3015. { \
  3016. if (!isVisible()) return; \
  3017. \
  3018. var display = "none"; \
  3019. \
  3020. var searchStr = decodeURIComponent(document.documentURI.replace(/^.*search_input=/i,"").replace(/&.*$/i,"")) \
  3021. .replace(/\\+/g," ").trim(); \
  3022. searchStr = searchStr.toLowerCase(); \
  3023. \
  3024. var eleStrs = document.querySelectorAll("#keylist > table:nth-child(1) > tbody:nth-child(1) > tr > td:nth-child(1) > div:nth-child(1) > table:nth-child(1) > tbody:nth-child(2) > tr:nth-child(2)"); \
  3025. for (var i = 0; i < eleStrs.length; i++) \
  3026. { \
  3027. try \
  3028. { \
  3029. var valStr = eleStrs[i].childElements()[0].textContent.trim().toLowerCase(); \
  3030. var valTrn = eleStrs[i].childElements()[2].textContent.trim().toLowerCase(); \
  3031. if (valStr != searchStr && valTrn != searchStr) \
  3032. { \
  3033. var eleTarget = eleStrs[i].parentElement.parentElement.parentElement.parentElement.parentElement; \
  3034. if (eleTarget.style.display != display) \
  3035. { \
  3036. eleTarget.style.display = display; \
  3037. } \
  3038. } \
  3039. } \
  3040. catch (ex) \
  3041. { \
  3042. } \
  3043. } \
  3044. } \
  3045. \
  3046. function hideStrNotMatchInterval() \
  3047. { \
  3048. clearInterval(itvIdHideStrNotMatch); \
  3049. itvIdHideStrNotMatch = setIntervalCustom(hideStrNotMatch, itvTime); \
  3050. } \
  3051. \
  3052. function hideStrLong() \
  3053. { \
  3054. if (!isVisible()) return; \
  3055. \
  3056. var display = "none"; \
  3057. var dot = "..."; \
  3058. var dotLengthMinus = 0 - dot.length; \
  3059. \
  3060. var eleStrs = document.querySelectorAll("#keylist > table:nth-child(1) > tbody:nth-child(1) > tr > td:nth-child(1) > div:nth-child(1) > table:nth-child(1) > tbody:nth-child(2) > tr:nth-child(2) > td:nth-child(1)"); \
  3061. for (var i = 0; i < eleStrs.length; i++) \
  3062. { \
  3063. try \
  3064. { \
  3065. var valStr = eleStrs[i].textContent.trim(); \
  3066. if (valStr.substr(dotLengthMinus) == dot) \
  3067. { \
  3068. var eleTarget = eleStrs[i].parentElement.parentElement.parentElement.parentElement.parentElement.parentElement; \
  3069. if (eleTarget.style.display != display) \
  3070. { \
  3071. eleTarget.style.display = display; \
  3072. } \
  3073. } \
  3074. } \
  3075. catch (ex) \
  3076. { \
  3077. } \
  3078. } \
  3079. } \
  3080. \
  3081. function hideStrLongInterval() \
  3082. { \
  3083. clearInterval(itvIdHideStrLong); \
  3084. itvIdHideStrLong = setIntervalCustom(hideStrLong, itvTime); \
  3085. } \
  3086. \
  3087. function clickToSelect(ele) \
  3088. { \
  3089. var range = document.createRange(); \
  3090. range.setStartBefore(ele.firstChild); \
  3091. range.setEndAfter(ele.lastChild); \
  3092. var sel = window.getSelection(); \
  3093. sel.removeAllRanges(); \
  3094. sel.addRange(range); \
  3095. } \
  3096. \
  3097. function syncUrlArray() \
  3098. { \
  3099. if (!isVisible()) return; \
  3100. \
  3101. var displayNone = "none"; \
  3102. var strStart = "showSuggestionsBox( \'"; \
  3103. var strEnd = "\' ); return false;"; \
  3104. var strCur = "&list_id="; \
  3105. var strAll = "&endnext="; \
  3106. var regPos = /&list_id=\\d+&endnext=\\d+/g; \
  3107. var isEdit = false; \
  3108. var eleDivs = []; \
  3109. var urls = []; \
  3110. \
  3111. var trKeys = document.querySelectorAll("#keylist > table:nth-child(1) > tbody:nth-child(1) > tr"); \
  3112. for (var i = 0; i < trKeys.length; i++) \
  3113. { \
  3114. if (trKeys[i].style.display != displayNone) \
  3115. { \
  3116. var eleDiv = trKeys[i].childNodes[0].childNodes[0]; \
  3117. if (typeof eleDiv.getAttribute != "undefined" \
  3118. && eleDiv.getAttribute("onclick") != null) \
  3119. { \
  3120. eleDivs.push(eleDiv); \
  3121. } \
  3122. } \
  3123. } \
  3124. \
  3125. for (var i = 0, l = eleDivs.length; i < l; i++) \
  3126. { \
  3127. var evOld = eleDivs[i].getAttribute("onclick"); \
  3128. if (evOld != null) \
  3129. { \
  3130. var url = evOld.replace(strStart,"").replace(strEnd,"").replace(regPos,""); \
  3131. url = url + strCur + i + strAll + l; \
  3132. urls.push(url); \
  3133. \
  3134. var evNew = strStart + url + strEnd; \
  3135. if (evOld != evNew) \
  3136. { \
  3137. eleDivs[i].setAttribute("onclick", evNew); \
  3138. isEdit = true; \
  3139. } \
  3140. } \
  3141. } \
  3142. \
  3143. if (isEdit || typeof URLarray == "undefined" || URLarray.length != urls.length) \
  3144. { \
  3145. URLarray = urls; \
  3146. } \
  3147. } \
  3148. \
  3149. function setFrameColor(color) \
  3150. { \
  3151. var frame = document.querySelector("div#suggestions_box iframe"); \
  3152. if (frame != null) \
  3153. { \
  3154. if (frame.style.backgroundColor != color) \
  3155. { \
  3156. frame.style.setProperty("background-color", color, "important"); \
  3157. } \
  3158. } \
  3159. } \
  3160. \
  3161. function padZero(num, size) \
  3162. { \
  3163. return (1e15+num+"").slice(-size); \
  3164. } \
  3165. \
  3166. function doInstant() \
  3167. { \
  3168. var url = document.documentURI; \
  3169. if (url.indexOf("user_activity.php") > -1) \
  3170. { \
  3171. showSuggestion(); \
  3172. \
  3173. document.addEventListener("DOMContentLoaded", function (e) \
  3174. { \
  3175. if (typeof $ != "undefined") \
  3176. { \
  3177. $(".dial").css("display", "none"); \
  3178. setTimeoutCustom(function() \
  3179. { \
  3180. /* Restore drawing progress */ \
  3181. $(function() { \
  3182. $(".dial").css("display", ""); \
  3183. $(".dial").knob({ \
  3184. "draw" : function () { \
  3185. $(this.i).val(this.cv + "%"); \
  3186. } \
  3187. }); \
  3188. }) \
  3189. }, 50); \
  3190. } \
  3191. }); \
  3192. } \
  3193. else if (url.indexOf("translate.php") > -1) \
  3194. { \
  3195. setIntervalCustom(function() \
  3196. { \
  3197. syncUrlArray(); \
  3198. }, itvTime); \
  3199. } \
  3200. else if (url.indexOf("suggestions.php") > -1) \
  3201. { \
  3202. if (parent != window) \
  3203. { \
  3204. var main = document.querySelector("#suggestionmain"); \
  3205. if (main != null) \
  3206. { \
  3207. var color = window.getComputedStyle(main).backgroundColor; \
  3208. parent.setFrameColor(color); \
  3209. } \
  3210. } \
  3211. } \
  3212. \
  3213. window.addEventListener("beforeunload", function (e) \
  3214. { \
  3215. clearTimeoutAll(); \
  3216. clearIntervalAll(); \
  3217. }); \
  3218. \
  3219. } \
  3220. doInstant(); \
  3221. \
  3222. ';
  3223.  
  3224. var eleClientScript = document.createElement("script");
  3225. eleClientScript.innerHTML = clientScript;
  3226. document.head.appendChild(eleClientScript);
  3227. } // End client
  3228.  
  3229. attachOnReady(client);
  3230. attachOnReady(main);
  3231.  
  3232.  
  3233.  
  3234. // End