STS Helper

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

当前为 2016-06-16 提交的版本,查看 最新版本

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