STS Helper

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

目前為 2017-06-15 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name STS Helper
  3. // @namespace iFantz7E.StsHelper
  4. // @version 1.98
  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. //// Compatibility: Firefox 14+ from Mutation Observer
  16.  
  17. // http://userscripts.org/scripts/show/325610
  18. // https://greasyfork.org/scripts/2250-sts-helper/
  19.  
  20. (function ()
  21. {
  22. "use strict";
  23. // jshint multistr:true
  24. function initStyle()
  25. {
  26. GM_addStyle(" \
  27. #logout { \
  28. position: fixed; z-index: 1001; right: 12px; top: 10px; \
  29. line-height: 24px; text-align: right; } \
  30. input[type='button'], input[type='submit'] { cursor: pointer; padding: 1px 9px; } \
  31. input[type='button']:disabled { cursor: default; color: #777; } \
  32. #suggestionmain { overflow-x: hidden; } \
  33. #suggestionmain > div:nth-child(4) > form:nth-child(2) > div:nth-child(1) { \
  34. text-align: left; } \
  35. .lbAction > div > input[value^='SUBMIT'] { \
  36. width: 750px; height: 30px; border-color: #777 #333 #777 #777; } \
  37. .lbAction > div > input[value^='RESUBMIT'] { \
  38. width: 641px; height: 30px; border-color: #777 #333 #777 #777; } \
  39. .lbAction > div > input[value='CANCEL'] { \
  40. width: 100px; height: 30px; margin-right: 5px; } \
  41. form.lbAction:nth-child(1) > div:nth-child(2) > input:nth-child(1) { \
  42. width: 90%; margin-top: 5px; } \
  43. .suggestion .lbAction textarea { \
  44. max-width: 700px !important; min-height: 50px; } \
  45. .progress td { vertical-align: top; } \
  46. div#suggestions_nav { \
  47. z-index: 3; position: absolute; width: 440px; \
  48. left: 543px; top: 2px; text-align: right; line-height: 24px; } \
  49. #suggestionmain .smallcopy { width: 855px; min-height: 70px; max-height: 70px; } \
  50. #suggestionmain .progress { margin-top: -12px; } \
  51. #leftAreaContainer > table > tbody:nth-child(1) > tr > td:nth-child(1) { \
  52. vertical-align: top; } \
  53. #leftAreaContainer > table, #leftAreaContainer > table th, #leftAreaContainer > table td { \
  54. border: 1px solid #333; border-collapse: collapse; padding: 4px; } \
  55. #suggestions_box { margin-top: 1px !important; position: relative; z-index: 20; } \
  56. #suggestions_iframe { min-height: 100px !important; } \
  57. #keylist td:nth-child(1) > div { \
  58. background-image: none !important; min-height: 43px; } \
  59. #keylist tr:nth-child(2n) > td:nth-child(1) > div { \
  60. background-color: #060606 !important; } \
  61. #keylist tr:nth-child(2n) > td:nth-child(1) > div:hover { \
  62. background-color: #0D0D0D !important; } \
  63. #keylist td:nth-child(1) > div:hover { \
  64. background-repeat: no-repeat; background-position: center; \
  65. background-color: #0D0D0D !important; \
  66. background-image: url('./public/images/row_over.gif') !important; } \
  67. .progress h1 { display: inline-block; width: 484px; } \
  68. div#suggestions_box iframe { background-color: #111 !important; } \
  69. .suggestions_list { border-right: 0px none !important; } \
  70. .suggestion { \
  71. resize: both; overflow: hidden; border-right: 1px solid #505050; \
  72. max-width: 953px; min-width: 200px; min-height: 50px; } \
  73. .suggestion_signature { font-family: Verdana; } \
  74. .suggestion_signature input[value~='APPROVE'] \
  75. , .suggestion_signature input[value~='Next'] { \
  76. color: #A4B23C } \
  77. .suggestion_signature input[value~='DECLINE'] \
  78. , .suggestion_signature input[value~='Next']:nth-child(5) { \
  79. color: #F22 } \
  80. .suggestion_signature input[disabled='disabled'] { color: #777 !important; } \
  81. .lbAction input[value~='COMMENT'] { \
  82. vertical-align: top; margin-top: 1px; height: 52px; } \
  83. .lbAction input[value~='DISCUSS'] { \
  84. vertical-align: top; margin-top: 1px; height: 21px; top: 0px !important; } \
  85. #votes_container a[title='not translated'] { background-color: #333; } \
  86. #suggestion_value_new { min-height: 84px; max-width: 960px; min-width: 200px; } \
  87. #hours > table > tbody > tr:nth-child(2) > th:nth-child(1) { width: 106px; text-align: center; } \
  88. #hours > table > tbody > tr:nth-child(2) > th:nth-child(3) { text-align: center; } \
  89. #hours > table > tbody > tr:nth-child(2) > th:nth-child(4) { text-align: center; } \
  90. #hours > table > tbody > tr > td:nth-child(1) { padding-right: 4px; } \
  91. #hours > table input[name*='[remarks]'] { width: 520px; } \
  92. #hours > table input[name*='[hours]'] { width: 100px; } \
  93. #hours > table input[name*='[minutes]'] { width: 100px; } \
  94. #suggestions_box_outer { overflow: hidden !important; } \
  95. #add_to_discussion { height: 19px; min-height: 19px; } \
  96. .gradienttable td > div { top: 1px !important; } \
  97. .copysmall > td:nth-child(1) { \
  98. white-space: nowrap; overflow: hidden; text-overflow: ellipsis; \
  99. display: inline-block; width: 430px; direction: ltr; } \
  100. div:hover > table > tbody > tr.copysmall > td:nth-child(1) { \
  101. direction: rtl; } \
  102. .stsh_btn { width: 90px; } \
  103. .stsh_btn_med { min-width: 112px; } \
  104. .stsh_btn_long { min-width: 136px; } \
  105. .stsh_btn_short { min-width: 66px; } \
  106. .stsh_btn_right { position: relative; float: right; margin-left: 4px; } \
  107. .stsh_suggestion_header { color: #A4B23C; } \
  108. .stsh_suggestion_comment:before { background-color: #CF8B37 !important; } \
  109. .stsh_suggestion_pending:before { background-color: #FFF !important; } \
  110. .stsh_suggestion_approved:before { background-color: #A4B23C !important; } \
  111. .stsh_suggestion_declined:before { background-color: red !important; } \
  112. .stsh_suggestion_applied:before { background-color: #2EBCEB !important; } \
  113. .stsh_suggestion_removed:before { background-color: #555 !important; } \
  114. .stsh_suggestion { list-style: none; } \
  115. .stsh_suggestion:before { \
  116. content: ''; display: inline-block; position: relative; height: 6px; width: 6px; \
  117. border-radius: 3px; background-clip: padding-box; margin-right: -6px; \
  118. top: -1px; left: -12px; background-color: green; }\
  119. #stsh_frame { \
  120. text-align: center; position: fixed; z-index: 10; \
  121. top: 100px; left: 50%; margin-left: -322px;} \
  122. #stsh_frame_sub { \
  123. background-color: #111; width: 600px; display: inline-block; \
  124. padding: 20px; border: 2px solid #cf9e5f; } \
  125. .stsh_blue { color: #2ebceb; } \
  126. .stsh_green { color: #a4b23c; } \
  127. .stsh_red { color: #F00; } \
  128. .stsh_white { color: #fff; } \
  129. .stsh_grey { color: #777; } \
  130. .stsh_orange { color: #CF8B37; } \
  131. .stsh_pink { color: pink; } \
  132. .stsh_border_green { border-color: #76802B !important; } \
  133. .stsh_cursor_notallowed { cursor: not-allowed; } \
  134. #stsh_showing { \
  135. color: #CCDAD6; position: fixed; z-index: 1001; \
  136. right: 12px; bottom: 12px; text-align: right; line-height: 14px;} \
  137. #stsh_showing_current { \
  138. color: #CCDAD6; position: fixed; z-index: 1001; \
  139. right: 12px; bottom: 28px; text-align: right; line-height: 14px;} \
  140. .stsh_showing_counter { \
  141. display: inline-block; min-width: 60px; text-align: center; } \
  142. .stsh_showing_header { \
  143. color: #CCDAD6; display: inline-block; width: 135px; \
  144. text-align: center; padding-top: 10px; } \
  145. .stsh_showing_group { \
  146. position: fixed; z-index: 3; right: 10px; top: 74px; \
  147. line-height: 24px; text-align: right; } \
  148. .stsh_home_header { color: #CCDAD6; display: inline-block; padding-top: 10px; } \
  149. .stsh_home_group { \
  150. position: fixed; z-index: 3; right: 0px; top: 74px; \
  151. line-height: 24px; text-align: center; width: 164px; } \
  152. .stsh_scroll_header { \
  153. color: #CCDAD6; display: inline-block; width: 130px; \
  154. text-align: center; padding-top: 10px; } \
  155. #stsh_specialEvent { position: absolute; z-index: 2; right: 164px; top: 13px; } \
  156. .stsh_snapshot { \
  157. position: absolute; top: 320px; left: 790px; \
  158. width: 140px; text-align: center; color: #FFF; } \
  159. .stsh_text_comment_header { vertical-align: top; } \
  160. .stsh_text_comment { vertical-align: top; display: inline-block; max-width: 850px; } \
  161. #stsh_autoApprove { vertical-align: -2px; margin-left: 15px; margin-right: 1px; } \
  162. .stsh_unselectable { \
  163. -webkit-touch-callout: none !important; \
  164. -webkit-user-select: none !important; \
  165. -khtml-user-select: none !important; \
  166. -moz-user-select: none !important; \
  167. -ms-user-select: none !important; \
  168. user-select: none !important; } \
  169. .stsh_a_button { \
  170. background-color: #1D1D1D; \
  171. font-family: tahoma,arial,helvetica,trebuchet ms,sans-serif; \
  172. color: #E1E1E1; font-size: 13px; border: 1px solid #777; padding: 1px 9px; } \
  173. .stsh_a_button:link, .stsh_a_button:hover, .stsh_a_button:active, .stsh_a_button:visited { \
  174. color: #E1E1E1; text-decoration: none; } \
  175. .stsh_a_button.stsh_btn { \
  176. display: inline-block; padding: 0px; \
  177. height: 19px; line-height: 19px; width: 88px; } \
  178. .stsh_a_button.stsh_btn_med { \
  179. display: inline-block; padding: 0px; \
  180. height: 19px; line-height: 19px; min-width: 110px; } \
  181. .stsh_a_button.stsh_btn_long { \
  182. display: inline-block; padding: 0px; \
  183. height: 19px; line-height: 19px; min-width: 134px; } \
  184. .stsh_lineCounter_outer { position: relative; } \
  185. .stsh_lineCounter { \
  186. position: absolute; width: 30px; left: -35px; top: -28px; \
  187. line-height: 28px; text-align: right; \
  188. color: #ACACAC; font-size: 9px; text-shadow: 0px 0px 3px #111; } \
  189. .stsh_glossary_term { min-width: 50px; display: inline-block; } \
  190. .stsh_glossary_header, .stsh_glossary_header td { color: #DDD; } \
  191. .stsh_glossary_header *, .stsh_glossary_header td * { color: #858585; } \
  192. .stsh_glossary_header > tbody:nth-child(1) > tr:nth-child(1) > td:nth-child(4) { \
  193. width: 10px !important; } \
  194. .stsh_time_convert { cursor: help; } \
  195. .stsh_comment_img { \
  196. display: block; cursor: zoom-in; cursor: -webkit-zoom-in; cursor: -moz-zoom-in; \
  197. max-width: 400px; margin-top: 5px; margin-bottom: 20px; } \
  198. .stsh_hours_curDate { color: #A4B23C; } \
  199. .stsh_hours_curDate input { border-color: #A4B23C; } \
  200. .stsh_submit_suggestion_right { \
  201. height: 30px; width: 214px; margin-right: 5px; border-color: #777 #777 #777 #333; } \
  202. .stsh_truncate { \
  203. white-space: nowrap; overflow: hidden; text-overflow: ellipsis; \
  204. display: inline-block; vertical-align: bottom; } \
  205. .stsh_token_name { max-width: 500px; } \
  206. .stsh_token_share { max-width: 600px; font-size: 0.8em; direction: rtl; } \
  207. .stsh_token_share:hover { direction: ltr; } \
  208. .stsh_pad { padding-left: 2px; padding-right: 2px; } \
  209. .stsh_hidden { display: none; } \
  210. table.gradienttable .stsh_curLang td, table.gradienttable .stsh_dst_curLang td \
  211. , table.gradienttable .stsh_dst_curLang th { \
  212. background: transparent \
  213. linear-gradient(to bottom, #171717 0%, rgba(71, 77, 26, 0.66) 40%, #121212 100%) \
  214. repeat scroll 0% 0% !important; } \
  215. .stsh_delta #suggestion_value_new { border-color: #1B6A85; } \
  216. .stsh_delta .stsh_text_submit { \
  217. color: #2EBCEB; border-color: #1B6A85 #083F52 #1B6A85 #1B6A85 !important; } \
  218. .stsh_delta .stsh_submit_suggestion_right { \
  219. color: #2EBCEB; border-color: #1B6A85 #1B6A85 #1B6A85 #083F52 !important; } \
  220. .stsh_delta .suggestions_list, .stsh_delta .suggestion { \
  221. border-color: #083F52 !important; } \
  222. .stsh_usThem_curLang { background-color: #2F3317; color: #E1E1E1; } \
  223. .stsh_dst_curLang, table.gradienttable .stsh_dst_curLang th, .stsh_dst_curLang a { \
  224. color: #2ebceb; } \
  225. .stsh_text_trn .lbAction textarea { max-width: 450px !important; } \
  226. .stsh_text_trn .lbAction input[value~='COMMENT'] { height: auto; } \
  227. .stsh_text_trn .stsh_text_submit { width: 270px !important; } \
  228. .stsh_text_trn .stsh_submit_suggestion_right { \
  229. width: 184px !important; margin-right: 32px !important; } \
  230. .stsh_text_org, .stsh_text_trn { min-height: 21px; display: block; } \
  231. .stsh_autoLoginOption { display: inline-block; vertical-align: top; line-height: 69px; padding-left: 30px; } \
  232. #stsh_autoLogin { margin-right: 0px; } \
  233. ");
  234. }
  235.  
  236. function attachOnLoad(callback)
  237. {
  238. window.addEventListener("load", function (e)
  239. {
  240. callback();
  241. });
  242. }
  243.  
  244. function attachOnReady(callback)
  245. {
  246. document.addEventListener("DOMContentLoaded", function (e)
  247. {
  248. callback();
  249. });
  250. }
  251.  
  252. function insertBeforeElement(newNode, referenceNode)
  253. {
  254. referenceNode.parentNode.insertBefore(newNode, referenceNode);
  255. }
  256.  
  257. function insertAfterElement(newNode, referenceNode)
  258. {
  259. referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
  260. }
  261.  
  262. function addKeyCtrl(ele, input, keyCode, keyName)
  263. {
  264. if (ele && input)
  265. {
  266. if (keyName && keyName != "")
  267. {
  268. if (input.tagName == "INPUT")
  269. {
  270. input.value += " (Ctrl+" + keyName + ")";
  271. }
  272. }
  273. ele.addEventListener("keydown", function (e)
  274. {
  275. if (e.ctrlKey && !e.shiftKey && !e.altKey)
  276. {
  277. var isSameKey = false;
  278. if (Number.isInteger(keyCode))
  279. {
  280. isSameKey = (e.keyCode == keyCode);
  281. }
  282. else
  283. {
  284. // Firefox 32+
  285. isSameKey = (e.code != undefined && e.code == keyCode)
  286. }
  287. if (isSameKey)
  288. {
  289. e.preventDefault();
  290. input.focus();
  291. input.click();
  292. return false;
  293. }
  294. }
  295. }, true);
  296. }
  297. }
  298.  
  299. function addKeyCtrlShift(ele, input, keyCode, keyName)
  300. {
  301. if (ele && input)
  302. {
  303. if (keyName && keyName != "")
  304. {
  305. if (input.tagName == "INPUT")
  306. {
  307. input.value += " (Ctrl+Shift+" + keyName + ")";
  308. }
  309. }
  310. ele.addEventListener("keydown", function (e)
  311. {
  312. if (e.ctrlKey && e.shiftKey && !e.altKey)
  313. {
  314. var isSameKey = false;
  315. if (Number.isInteger(keyCode))
  316. {
  317. isSameKey = (e.keyCode == keyCode);
  318. }
  319. else
  320. {
  321. // Firefox 32+
  322. isSameKey = (e.code != undefined && e.code == keyCode)
  323. }
  324.  
  325. if (isSameKey)
  326. {
  327. e.preventDefault();
  328. input.focus();
  329. input.click();
  330. return false;
  331. }
  332. }
  333. }, true);
  334. }
  335. }
  336.  
  337. function addKeyAlt(ele, input, keyCode, keyName)
  338. {
  339. if (ele && input)
  340. {
  341. if (keyName && keyName != "")
  342. {
  343. if (input.tagName == "INPUT")
  344. {
  345. input.value += " (Alt+" + keyName + ")";
  346. }
  347. }
  348.  
  349. ele.addEventListener("keydown", function (e)
  350. {
  351. if (!e.ctrlKey && !e.shiftKey && e.altKey)
  352. {
  353. var isSameKey = false;
  354. if (Number.isInteger(keyCode))
  355. {
  356. isSameKey = (e.keyCode == keyCode);
  357. }
  358. else
  359. {
  360. // Firefox 32+
  361. isSameKey = (e.code != undefined && e.code == keyCode)
  362. }
  363. if (isSameKey)
  364. {
  365. e.preventDefault();
  366. input.focus();
  367. input.click();
  368. return false;
  369. }
  370. }
  371. }, true);
  372. }
  373. }
  374.  
  375. function addKeyCtrlEnter(form, input)
  376. {
  377. addKeyCtrl(form, input, 13, "Enter")
  378. }
  379.  
  380. function addKeyCtrlShiftEnter(form, input)
  381. {
  382. addKeyCtrlShift(form, input, 13, "Enter")
  383. }
  384.  
  385. function disableAfterClick(ele)
  386. {
  387. ele.addEventListener("click", function (e)
  388. {
  389. var ele = e.target;
  390. var tagName = ele.tagName;
  391. if (tagName == "INPUT")
  392. {
  393. // don't change color after disable
  394. var styleCp = window.getComputedStyle(ele);
  395. if (styleCp)
  396. {
  397. ele.style.setProperty("color", styleCp.color, "important");
  398. }
  399. ele.disabled = true;
  400. }
  401. else if (tagName == "IMG")
  402. {
  403. ele.removeAttribute("onclick");
  404. }
  405. }, true);
  406. }
  407.  
  408. function removeAllEventListeners(element)
  409. {
  410. if (element)
  411. {
  412. var clone = element.cloneNode(false);
  413. while (element.firstChild)
  414. {
  415. clone.appendChild(element.lastChild);
  416. }
  417. element.parentNode.replaceChild(clone, element);
  418. }
  419. }
  420.  
  421. function scrollToId(id, offset)
  422. {
  423. scrollToElement("#" + id, offset);
  424. }
  425.  
  426. function scrollToElement(selector, offset)
  427. {
  428. if (typeof offset === "undefined")
  429. {
  430. offset = -20;
  431. }
  432. var ele = document.querySelector(selector);
  433. if (ele)
  434. {
  435. ele.scrollIntoView(true);
  436. window.scrollBy(0, offset);
  437. }
  438. }
  439.  
  440. function resizeSuggestionBox()
  441. {
  442. var script = document.createElement('script');
  443. script.innerHTML = " \
  444. var stsh_showSuggestionsBox_start = new Date(); \
  445. var stsh_showSuggestionsBox_itv = setIntervalCustom(function() \
  446. { \
  447. var stsh_showSuggestionsBox_isEnd = false; \
  448. var stsh_showSuggestionsBox_cur = new Date(); \
  449. if (typeof showSuggestionsBox !== 'undefined') \
  450. { \
  451. showSuggestionsBox = function(url) \
  452. { \
  453. /* Edit from STS */ \
  454. g_suggestionsBoxIsOpen = true; \
  455. $('suggestions_box_outer').appear( \
  456. { \
  457. duration : 0.1 \
  458. } \
  459. ); \
  460. $('suggestions_iframe').setAttribute('src', url); \
  461. if (!Prototype.Browser.IE) \
  462. { \
  463. $('suggestions_iframe').focus(); \
  464. } \
  465. $('suggestions_iframe').style.height = (document.viewport.getHeight() * 0.99) + 'px'; \
  466. return false; \
  467. }; \
  468. stsh_showSuggestionsBox_isEnd = true; \
  469. } \
  470. if (stsh_showSuggestionsBox_isEnd || stsh_showSuggestionsBox_cur - stsh_showSuggestionsBox_start > 10000) \
  471. { \
  472. clearInterval(stsh_showSuggestionsBox_itv); \
  473. } \
  474. }, 300); \
  475. ";
  476. document.head.appendChild(script);
  477.  
  478. window.addEventListener("resize", function()
  479. {
  480. var iframe = document.querySelector("#suggestions_iframe");
  481. if (iframe)
  482. {
  483. iframe.style.height = (window.innerHeight * 0.99) + "px";
  484. }
  485. });
  486. }
  487.  
  488. function getQueryByName(name, url)
  489. {
  490. if (!url)
  491. {
  492. url = (!location) ? "" : location.search;
  493. }
  494. name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
  495. var regex = new RegExp("[\\?&]" + name + "=([^&#]*)");
  496. var results = regex.exec(url);
  497. var retVal = "";
  498. if (results)
  499. {
  500. retVal = results[1].replace(/\+/g, " ");
  501. try
  502. {
  503. retVal = decodeURIComponent(retVal);
  504. }
  505. catch (ex)
  506. {
  507. console.error("getQueryByName", ex.message);
  508. }
  509. }
  510. return retVal;
  511. }
  512.  
  513. function padZero(num, size)
  514. {
  515. return (1e15 + num + "").slice(-size);
  516. }
  517.  
  518. function padZeroHex(num, size)
  519. {
  520. return ("00000000000000000000000" + num.toString(16)).slice(-size).toUpperCase();
  521. }
  522.  
  523. function randNum(min, max)
  524. {
  525. return Math.round(Math.random() * (max - min) + min);
  526. }
  527.  
  528. function isSpecialChar(ch)
  529. {
  530. var chCode = -1;
  531. if (typeof ch === 'number')
  532. {
  533. chCode = ch;
  534. }
  535. else
  536. {
  537. chCode = ch.charCodeAt(0);
  538. }
  539. if ((chCode > -1 && chCode < 9) // 0-8
  540. || (chCode > 10 && chCode < 13) // 11-12
  541. || (chCode > 13 && chCode < 32)) // 14-31
  542. {
  543. return true;
  544. }
  545. return false;
  546. }
  547.  
  548. function hasSpecialChar(str)
  549. {
  550. 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]+/;
  551. return rgxSpCh.test(str);
  552. }
  553. function checkSpecialCharMatched(str1, str2)
  554. {
  555. // return (status, numSp1, numSp2)
  556. // status: 0:Match, 1:NotMatch, 2:NotEqual
  557. var strOut1 = "";
  558. var strOut2 = "";
  559. if (str1 && str2)
  560. {
  561. for (var i = 0; i < str1.length; i++)
  562. {
  563. if (isSpecialChar(str1[i]))
  564. {
  565. strOut1 += str1[i];
  566. }
  567. }
  568. for (var i = 0; i < str2.length; i++)
  569. {
  570. if (isSpecialChar(str2[i]))
  571. {
  572. strOut2 += str2[i];
  573. }
  574. }
  575. }
  576. var retVal = 0;
  577. if (strOut1 == strOut2)
  578. retVal = 0;
  579. else if (strOut1.length == strOut2.length)
  580. retVal = 1;
  581. else
  582. retVal = 2;
  583. return new Array(retVal, strOut1.length, strOut2.length);
  584. }
  585.  
  586. function trimSpace(str)
  587. {
  588. return str.replace(/^[ \r\n\t]+/, "").replace(/[ \r\n\t]+$/, "");
  589. }
  590.  
  591. if (!String.prototype.endsWith)
  592. {
  593. String.prototype.endsWith = function(searchString, position)
  594. {
  595. var subjectString = this.toString();
  596. if (typeof position !== 'number' || !isFinite(position)
  597. || Math.floor(position) !== position || position > subjectString.length)
  598. {
  599. position = subjectString.length;
  600. }
  601. position -= searchString.length;
  602. var lastIndex = subjectString.indexOf(searchString, position);
  603. return lastIndex !== -1 && lastIndex === position;
  604. };
  605. }
  606.  
  607. function reload()
  608. {
  609. var curHref = window.location.href;
  610. var posHashtag = curHref.indexOf("#");
  611. if (posHashtag > -1)
  612. {
  613. window.location = curHref.substr(0, posHashtag);
  614. }
  615. else
  616. {
  617. window.location = curHref;
  618. }
  619. }
  620.  
  621. function getCookie(c_name) {
  622. var c_value = document.cookie;
  623. var c_start = c_value.indexOf(" " + c_name + "=");
  624. if (c_start == -1) {
  625. c_start = c_value.indexOf(c_name + "=");
  626. }
  627. if (c_start == -1) {
  628. c_value = null;
  629. }
  630. else {
  631. c_start = c_value.indexOf("=", c_start) + 1;
  632. var c_end = c_value.indexOf(";", c_start);
  633. if (c_end == -1) {
  634. c_end = c_value.length;
  635. }
  636. c_value = unescape(c_value.substring(c_start, c_end));
  637. }
  638. return c_value;
  639. }
  640.  
  641. var isVisible = (function()
  642. {
  643. var stateKey;
  644. var eventKey;
  645. var keys =
  646. {
  647. hidden: "visibilitychange",
  648. webkitHidden: "webkitvisibilitychange",
  649. mozHidden: "mozvisibilitychange",
  650. msHidden: "msvisibilitychange"
  651. };
  652. for (stateKey in keys)
  653. {
  654. if (stateKey in document)
  655. {
  656. eventKey = keys[stateKey];
  657. break;
  658. }
  659. }
  660. return function(c)
  661. {
  662. if (c)
  663. {
  664. document.addEventListener(eventKey, c);
  665. }
  666. return !document[stateKey];
  667. }
  668. })();
  669.  
  670. function isDstUsa(year, month, day, hour)
  671. {
  672. // 2016, 3, 1, 15 == 1 Mar 2016 15:00
  673. var isDst = false;
  674. try
  675. {
  676. var y = parseInt(year);
  677. var m = parseInt(month);
  678. var d = parseInt(day);
  679. var h = parseInt(hour);
  680. function checkDstUsa(dayMar, dayNov, m, d, h)
  681. {
  682. var isDst = false;
  683. if ((m == 3 && d >= dayMar) || (m > 3 && m < 11) || (m == 11 && d <= dayNov))
  684. isDst = true;
  685. if ((m == 3 && d == dayMar && h < 2) || (m == 11 && d == dayNov && h >= 2))
  686. isDst = false;
  687. return isDst;
  688. }
  689. if (y == 2007 || y == 2012 || y == 2018 || y == 2029)
  690. {
  691. isDst = checkDstUsa(11, 4, m, d, h);
  692. }
  693. else if (y == 2013 || y == 2019 || y == 2024)
  694. {
  695. isDst = checkDstUsa(10, 3, m, d, h);
  696. }
  697. else if (y == 2008 || y == 2014 || y == 2025)
  698. {
  699. isDst = checkDstUsa(9, 2, m, d, h);
  700. }
  701. else if (y == 2009 || y == 2015 || y == 2020 || y == 2026)
  702. {
  703. isDst = checkDstUsa(8, 1, m, d, h);
  704. }
  705. else if (y == 2010 || y == 2021 || y == 2027)
  706. {
  707. isDst = checkDstUsa(14, 7, m, d, h);
  708. }
  709. else if (y == 2011 || y == 2016 || y == 2022)
  710. {
  711. isDst = checkDstUsa(13, 6, m, d, h);
  712. }
  713. else if (y == 2017 || y == 2023 || y == 2028)
  714. {
  715. isDst = checkDstUsa(12, 5, m, d, h);
  716. }
  717. }
  718. catch (ex)
  719. {
  720. console.error("isDstUsa", ex.message);
  721. }
  722. return isDst;
  723. }
  724.  
  725. function getUnixTimestamp()
  726. {
  727. return parseInt((new Date()) / 1000);
  728. }
  729. var pattUrlTimestamp1 = /\?t=[0-9]{6,}\&/g;
  730. var pattUrlTimestamp2 = /\&t=[0-9]{6,}/g;
  731. var pattUrlTimestamp3 = /\?t=[0-9]{6,}/g;
  732. var pattUrlTimestamp4 = /\&[0-9]{6,}\&/g;
  733.  
  734. function cleanUrlTimestamp(eles)
  735. {
  736. if (!eles || !eles.length)
  737. return;
  738.  
  739. for (var i = 0; i < eles.length; i++)
  740. {
  741. var val = "";
  742. var attr = "";
  743. if (eles[i].tagName === "A")
  744. {
  745. attr = "href";
  746. }
  747. else if (eles[i].tagName === "FORM")
  748. {
  749. attr = "action";
  750. }
  751. else if (eles[i].tagName === "DIV")
  752. {
  753. attr = "onclick";
  754. }
  755. var isEdit = false;
  756. val = eles[i].getAttribute(attr);
  757. if (pattUrlTimestamp1.test(val))
  758. {
  759. eles[i].setAttribute(attr, val.replace(pattUrlTimestamp1,"?"));
  760. isEdit = true;
  761. }
  762. else if (pattUrlTimestamp2.test(val))
  763. {
  764. eles[i].setAttribute(attr, val.replace(pattUrlTimestamp2,""));
  765. isEdit = true;
  766. }
  767. else if (pattUrlTimestamp3.test(val))
  768. {
  769. eles[i].setAttribute(attr, val.replace(pattUrlTimestamp3,""));
  770. isEdit = true;
  771. }
  772. if (isEdit)
  773. {
  774. val = eles[i].getAttribute(attr);
  775. }
  776. if (pattUrlTimestamp4.test(val))
  777. {
  778. //console.log("T4: " + val);
  779. eles[i].setAttribute(attr, val.replace(pattUrlTimestamp4,"&"));
  780. }
  781. }
  782. }
  783.  
  784. var timeoutList = new Array();
  785. var intervalList = new Array();
  786.  
  787. function setTimeoutCustom(func, tm, params)
  788. {
  789. var id = setTimeout(func, tm, params);
  790. timeoutList.push(id);
  791. return id;
  792. }
  793.  
  794. function clearTimeoutAll()
  795. {
  796. for (var i = 0; i < timeoutList.length; i++)
  797. {
  798. clearTimeout(timeoutList[i]);
  799. }
  800. }
  801.  
  802. function setIntervalCustom(func, tm, params)
  803. {
  804. var id = setInterval(func, tm, params);
  805. intervalList.push(id);
  806. return id;
  807. }
  808.  
  809. function clearIntervalAll()
  810. {
  811. for (var i = 0; i < intervalList.length; i++)
  812. {
  813. clearInterval(intervalList[i]);
  814. }
  815. }
  816.  
  817. function main()
  818. {
  819. var url = document.documentURI;
  820. var lang = getCookie("Language");
  821. // Auto refresh when error
  822. {
  823. var h1 = document.querySelector("#leftAreaContainer > h1, body > h1");
  824. if (h1)
  825. {
  826. var text = h1.textContent.trim();
  827. if (text == "Steam Translation Server - Maintenance Warning"
  828. || text == "Forbidden")
  829. {
  830. console.log("stsh: refresh");
  831. setTimeoutCustom(reload, 60000);
  832. return;
  833. }
  834. }
  835. }
  836.  
  837. // Clean links
  838. {
  839. setTimeoutCustom(function()
  840. {
  841. var eles = document.querySelectorAll("a, form[action]");
  842. cleanUrlTimestamp(eles);
  843. }, 1000);
  844. }
  845.  
  846. var eleLogout = document.querySelector("#logout");
  847. if (eleLogout)
  848. {
  849. var logoutHtml = ' <a class="stsh_a_button" target="_blank" '
  850. + ' href="/user_activity.php">My Profile</a> '
  851. + ' <input name="login_button" value="Logout?" type="submit" onclick="return confirm(\'Logout?\');" /> ';
  852. eleLogout.innerHTML = logoutHtml;
  853. }
  854.  
  855. // Special event button
  856. {
  857. var eleLogoff = document.querySelector("#logoff");
  858. if (eleLogoff)
  859. {
  860. var d = new Date();
  861. if ((d.getUTCMonth() > 8) || (d.getUTCMonth() == 8 && d.getUTCDate() >= 25) || (d.getUTCMonth() == 0 && d.getUTCDate() <= 1))
  862. {
  863. var divSpecial = document.createElement("div");
  864. divSpecial.id = "stsh_specialEvent";
  865. divSpecial.innerHTML = ' <a class="stsh_a_button" target="_blank" '
  866. + ' href="/rally.php">Year-End Rally</a> ';
  867. eleLogoff.appendChild(divSpecial);
  868. }
  869. }
  870. }
  871.  
  872. if (url.indexOf("Us_And_Them.php") > -1)
  873. {
  874. var container = "\"";
  875. var tdEng = document.querySelector("#leftAreaContainer > table > tbody:nth-child(1) > tr:nth-child(1) > td:nth-child(2)");
  876. if (tdEng)
  877. {
  878. tdEng.innerHTML = container + tdEng.innerHTML + container;
  879. }
  880. var h1 = document.querySelector("#leftAreaContainer > h1:nth-child(2)");
  881. if (h1)
  882. {
  883. var header = h1.textContent.trim();
  884. var key = header.split(" ")[0];
  885. h1.innerHTML = header.replace(key, "<a href='http://translation.steampowered.com/translate.php?keyonly=1&search_input="
  886. + encodeURIComponent(key) + "' >" + key + "</a>");
  887. document.title = key + " - " + document.title;
  888. }
  889. // Hilight cur lang
  890. {
  891. //var first = document.querySelector("#leftAreaContainer tr:nth-child(1) > td:nth-child(1) > a");
  892. //if (first)
  893. {
  894. var cur = null;
  895. var elesLang = document.querySelectorAll("#leftAreaContainer tr > td:nth-child(1) > a");
  896. for (var i = 1; i < elesLang.length; i++)
  897. {
  898. if (lang === elesLang[i].textContent.trim().toLowerCase())
  899. {
  900. cur = elesLang[i].parentElement.parentElement;
  901. break;
  902. }
  903. }
  904. if (cur)
  905. {
  906. cur.classList.add("stsh_usThem_curLang");
  907. //insertAfterElement(cur, first.parentElement.parentElement);
  908. }
  909. }
  910. }
  911. } // End Us_And_Them.php
  912.  
  913. if (url.indexOf("suggestions.php") > -1)
  914. {
  915. var eleTextOrg = document.querySelector(".progress tr:last-child > td:nth-child(1)");
  916. if (eleTextOrg)
  917. {
  918. eleTextOrg.classList.add("stsh_text_org");
  919. }
  920. var eleTextTrn = document.querySelector(".progress tr:last-child > td:nth-child(3)");
  921. if (eleTextTrn)
  922. {
  923. eleTextTrn.classList.add("stsh_text_trn");
  924. }
  925. var eleTextSubmit = document.querySelector(".lbAction[name='suggestion_temp'] input[accesskey='s']");
  926. if (eleTextSubmit)
  927. {
  928. eleTextSubmit.classList.add("stsh_text_submit");
  929. }
  930. var elesTextRemoveComment = document.querySelectorAll(".suggestion_signature .lbAction[name^='mymodcomment'] a");
  931. for (var i = 0; i < elesTextRemoveComment.length; i++)
  932. {
  933. elesTextRemoveComment[i].removeAttribute("href");
  934. elesTextRemoveComment[i].classList.add("stsh_text_removeComment");
  935. }
  936. var elesTextComment = document.querySelectorAll("textarea[name='suggestion_comment']");
  937. for (var i = 0; i < elesTextComment.length; i++)
  938. {
  939. elesTextComment[i].nextElementSibling.classList.add("stsh_submit_comment");
  940. }
  941. var eleTextNew = document.querySelector("#suggestion_value_new");
  942. if (eleTextNew)
  943. {
  944. eleTextNew.style.width = "960px";
  945. eleTextNew.style.height = "64px";
  946. eleTextNew.style.marginLeft = "3px";
  947. }
  948. var inputClose = document.querySelector("#suggestions_nav > input[value^='Close']");
  949. if (inputClose)
  950. {
  951. inputClose.value = "Close (Esc)";
  952. }
  953. // Move region
  954. {
  955. var td = eleTextTrn;
  956. if (td && td.textContent.trim() == "")
  957. {
  958. function moveSuggestionBox()
  959. {
  960. var td = document.querySelector(".stsh_text_trn");
  961. if (td && td.textContent.trim() == "")
  962. {
  963. td.innerHTML = "";
  964. var eleTarget = document.querySelector("#suggestionmain > div:nth-child(4) > .lbAction");
  965. if (eleTarget)
  966. {
  967. td.appendChild(eleTarget);
  968. td.style.padding = "0px";
  969. var textarea = document.querySelector("#suggestion_value_new");
  970. if (textarea)
  971. {
  972. textarea.style.width = "98%";
  973. textarea.style.marginLeft = "0px";
  974. if (textarea.scrollHeight < 1000)
  975. {
  976. textarea.style.height = (textarea.scrollHeight + 20) + "px";
  977. }
  978. else
  979. {
  980. textarea.style.height = "1000px";
  981. }
  982. textarea.focus();
  983. }
  984. }
  985. }
  986. }
  987. function moveSuggestionList()
  988. {
  989. var td = document.querySelector(".stsh_text_trn");
  990. if (td && td.textContent.trim() == "")
  991. {
  992. td.innerHTML = "";
  993. var eleTarget = document.querySelector(".suggestion");
  994. if (eleTarget)
  995. {
  996. td.appendChild(eleTarget);
  997. td.style.padding = "0px";
  998. eleTarget.style.marginTop = "-2px";
  999. eleTarget.style.paddingTop = "0px";
  1000. eleTarget.style.borderBottomWidth = "0px";
  1001. eleTarget.style.borderRightWidth = "0px";
  1002. eleTarget.style.resize = "none";
  1003. var eleAutoApprove = document.querySelector("#stsh_autoApprove");
  1004. if (eleAutoApprove)
  1005. {
  1006. eleAutoApprove.classList.add("stsh_hidden");
  1007. }
  1008. var eleAutoApproveLabel = document.querySelector(".stsh_autoApprove_label");
  1009. if (eleAutoApproveLabel)
  1010. {
  1011. eleAutoApproveLabel.classList.add("stsh_hidden");
  1012. }
  1013. }
  1014. }
  1015. }
  1016. var eleMoveBox = document.createElement("input");
  1017. eleMoveBox.id = "stsh_moveSuggestionBox";
  1018. eleMoveBox.setAttribute("value", "Move Box Here");
  1019. eleMoveBox.setAttribute("type", "button");
  1020. eleMoveBox.style.marginRight = "5px";
  1021. eleMoveBox.addEventListener("click", function(e)
  1022. {
  1023. moveSuggestionBox();
  1024. });
  1025. td.appendChild(eleMoveBox);
  1026. var eleMoveList = document.createElement("input");
  1027. eleMoveList.id = "stsh_moveSuggestionList";
  1028. eleMoveList.setAttribute("value", "Move Suggestion Here");
  1029. eleMoveList.setAttribute("type", "button");
  1030. eleMoveList.style.marginRight = "5px";
  1031. eleMoveList.addEventListener("click", function(e)
  1032. {
  1033. moveSuggestionList();
  1034. });
  1035. td.appendChild(eleMoveList);
  1036. }
  1037. }
  1038. if (eleTextNew)
  1039. {
  1040. var resizeTextNew = function(eleTextNew)
  1041. {
  1042. eleTextNew.focus();
  1043. if (eleTextNew.scrollHeight < 1000)
  1044. {
  1045. eleTextNew.style.height = (eleTextNew.scrollHeight + 20) + "px";
  1046. }
  1047. else
  1048. {
  1049. eleTextNew.style.height = "1000px";
  1050. }
  1051. if (eleTextNew.scrollHeight > 200 && document.querySelector(".suggestion"))
  1052. {
  1053. eleTextNew.scrollIntoView();
  1054. }
  1055. };
  1056. if (isVisible())
  1057. {
  1058. resizeTextNew(eleTextNew);
  1059. }
  1060. else
  1061. {
  1062. // Fix size error in iframe when inactive
  1063. setTimeoutCustom(resizeTextNew, 100, eleTextNew);
  1064. }
  1065. }
  1066. var br = document.querySelector("form.lbAction:nth-child(2) > div:nth-child(2) > br:nth-child(1)");
  1067. if (br)
  1068. {
  1069. br.parentElement.removeChild(br);
  1070. }
  1071. var key = "";
  1072. var divNav = document.querySelector("div#suggestions_nav");
  1073. if (divNav)
  1074. {
  1075. var insert = "";
  1076. var spliter = "_";
  1077. var regApp = /[0-9]{4,}/;
  1078. var aKey = document.querySelector(".smallcopy > font:nth-child(2) > a:nth-child(1)");
  1079. if (aKey)
  1080. {
  1081. insert += ' <br/> &nbsp; ';
  1082. key = encodeURIComponent(aKey.textContent.trim());
  1083. if (key == "token-key")
  1084. {
  1085. aKey = document.querySelector(".smallcopy > a:nth-child(3)");
  1086. if (aKey)
  1087. {
  1088. key = encodeURIComponent(aKey.textContent.trim());
  1089. }
  1090. }
  1091. if (key != "")
  1092. {
  1093. document.title = key + " - " + document.title;
  1094. if (key.split(spliter).length > 1)
  1095. {
  1096. if (key.indexOf("%23") == 0)
  1097. {
  1098. var firstSpliter = key.indexOf(spliter);
  1099. var keySharp = key.substring(0, firstSpliter);
  1100. insert += ' <a class="stsh_a_button" target="_blank" '
  1101. + ' href="/translate.php?keyonly=1&paginationrows=1000&search_input='
  1102. + keySharp + '">Search by Hashtag</a> ';
  1103. }
  1104. var lastSpliter = key.lastIndexOf(spliter);
  1105. var keyGroup = key.substring(0, lastSpliter);
  1106. insert += ' <a class="stsh_a_button" target="_blank" '
  1107. + ' href="/translate.php?keyonly=1&paginationrows=1000&search_input='
  1108. + keyGroup + '">Search by Group</a> ';
  1109. }
  1110. insert += ' <a class="stsh_a_button" target="_blank" '
  1111. + ' href="/translate.php?keyonly=1&search_input='
  1112. + key + '">Search by Key</a> ';
  1113. }
  1114. }
  1115. var tdText = eleTextOrg;
  1116. if (tdText)
  1117. {
  1118. var text = encodeURIComponent(tdText.textContent.trim()).replace(/(%20|%09)/g,"+")
  1119. .replace(/'/g,"\\'").replace("%0A","+").replace(/\++/g,"+").substr(0, 80);
  1120. if (text.length >= 80)
  1121. {
  1122. text = text.substr(0, text.lastIndexOf("+"));
  1123. }
  1124. if (text.indexOf(".") > 20)
  1125. {
  1126. text = text.substr(0, text.indexOf(".") + 1);
  1127. }
  1128. if (text.indexOf("%5C") > 10)
  1129. {
  1130. text = text.substr(0, text.indexOf("%5C"));
  1131. }
  1132. var eleSubmit = document.querySelector(".stsh_text_submit");
  1133. if (eleSubmit)
  1134. {
  1135. var elePrev = eleSubmit.previousElementSibling;
  1136. if (!elePrev || elePrev.tagName != "BR")
  1137. {
  1138. var eleNew = document.createElement("br");
  1139. insertBeforeElement(eleNew, eleSubmit);
  1140. }
  1141. }
  1142. if (text != "")
  1143. {
  1144. insert += ' <br/> &nbsp; <a class="stsh_a_button" target="_blank" '
  1145. + ' href="/translate.php?keyonly=2&paginationrows=1000&search_input='
  1146. + text + '">Search by String</a> ';
  1147. var eleSubmitNext = document.querySelector(".lbAction input[type='submit'][accesskey='a']");
  1148. if (eleSubmitNext)
  1149. {
  1150. eleSubmitNext.value = "Next";
  1151. eleSubmitNext.classList.add("stsh_submit_suggestion_right");
  1152. var eleForm = eleSubmitNext.parentElement.parentElement;
  1153. if (eleForm.tagName == "FORM")
  1154. {
  1155. addKeyCtrlShiftEnter(eleForm, eleSubmitNext);
  1156. }
  1157. }
  1158. else
  1159. {
  1160. if (eleSubmit)
  1161. {
  1162. var eleNew = document.createElement("input");
  1163. eleNew.id = "stsh_submit_suggestion_next";
  1164. eleNew.classList.add("stsh_submit_suggestion_right");
  1165. eleNew.setAttribute("type", "submit");
  1166. eleNew.setAttribute("value", "Next");
  1167. eleNew.setAttribute("name", "submitandnext");
  1168. insertAfterElement(eleNew, eleSubmit);
  1169. eleNew.addEventListener("click", function(ev)
  1170. {
  1171. var textOrg = "";
  1172. var textTrn = "";
  1173. var textCur = "";
  1174. var eleTextOrg = document.querySelector(".stsh_text_org");
  1175. if (eleTextOrg)
  1176. {
  1177. textOrg = trimSpace(eleTextOrg.textContent);
  1178. }
  1179. var eleTextTrn = document.querySelector(".stsh_text_trn");
  1180. if (eleTextTrn)
  1181. {
  1182. textTrn = trimSpace(eleTextTrn.textContent);
  1183. }
  1184. var eleTextCur = document.querySelector("#suggestion_value_new");
  1185. if (eleTextCur)
  1186. {
  1187. textCur = trimSpace(eleTextCur.value);
  1188. }
  1189. if (textCur == "" || textOrg == textCur || textTrn == textCur)
  1190. {
  1191. ev.preventDefault();
  1192. var eleSubmit = document.querySelector(".stsh_text_submit");
  1193. if (eleSubmit)
  1194. {
  1195. eleSubmit.click();
  1196. }
  1197. }
  1198. });
  1199. var eleForm = eleSubmit.parentElement.parentElement;
  1200. if (eleForm.tagName == "FORM")
  1201. {
  1202. addKeyCtrlShiftEnter(eleForm, eleNew);
  1203. }
  1204. }
  1205. }
  1206. }
  1207. else
  1208. {
  1209. if (eleTextNew && eleSubmit)
  1210. {
  1211. var eleNew = document.createElement("input");
  1212. eleNew.id = "stsh_submit_suggestion_space";
  1213. eleNew.classList.add("stsh_submit_suggestion_right");
  1214. eleNew.setAttribute("type", "button");
  1215. eleNew.setAttribute("value", "Submit Space (Alt+0160)");
  1216. insertAfterElement(eleNew, eleSubmit);
  1217. eleNew.addEventListener("click", function(ev)
  1218. {
  1219. var eleTextNew = document.querySelector("#suggestion_value_new");
  1220. if (eleTextNew)
  1221. {
  1222. eleTextNew.value = String.fromCharCode(160);
  1223. eleTextNew.focus();
  1224. ev.preventDefault();
  1225. var eleSubmit = document.querySelector(".stsh_text_submit");
  1226. if (eleSubmit)
  1227. {
  1228. eleSubmit.click();
  1229. }
  1230. }
  1231. });
  1232. }
  1233. }
  1234. }
  1235. var app = regApp.exec(key.replace("%23",""));
  1236. if (key.indexOf("faq") < 0 && app)
  1237. {
  1238. insert += ' <br/> &nbsp; ';
  1239. if (key.indexOf("SharedFiles_App_") == 0)
  1240. {
  1241. insert += ' <a class="stsh_a_button" target="_blank" '
  1242. + ' href="http://steamcommunity.com/workshop/browse?appid='
  1243. + app + '">View Workshop</a> ';
  1244. }
  1245. insert += ' <a class="stsh_a_button" target="_blank" '
  1246. + ' href="http://steamcommunity.com/app/'
  1247. + app + '">View Community</a> '
  1248. insert += ' <a class="stsh_a_button" target="_blank" '
  1249. + ' href="http://store.steampowered.com/app/'
  1250. + app + '">View App</a> ';
  1251. }
  1252. var insertBefore = ' <input id="stsh_refresh" value="Refresh" '
  1253. + ' onclick="return false;" type="button"> '
  1254. + ' <a class="stsh_a_button" target="_blank" '
  1255. + ' href="' + url + '">Frame</a> ';
  1256. var innerNew = divNav.innerHTML
  1257. .replace('<input value="Previous','&nbsp;&nbsp;<input value="Prev')
  1258. .replace('<input value="Close','&nbsp;&nbsp;<input value="Close');
  1259. divNav.innerHTML = insertBefore + innerNew + insert + " <br/> ";
  1260. var eleRefresh = document.querySelector("#stsh_refresh");
  1261. if (eleRefresh)
  1262. {
  1263. eleRefresh.addEventListener("click", function()
  1264. {
  1265. reload();
  1266. });
  1267. }
  1268. }
  1269. // Regroup glossary and auto replace matched string
  1270. {
  1271. setTimeoutCustom(function()
  1272. {
  1273. var br = "<br>";
  1274. var brSpace = " <br> ";
  1275. var tag = "<a";
  1276. var colon = ">: ";
  1277. var comma = ",";
  1278. var bracket = " (";
  1279. var isEdit = false;
  1280. var p = null;
  1281. var aGls = document.querySelectorAll("a[href='glossary.php']");
  1282. for (var i = 0; i < aGls.length; i++)
  1283. {
  1284. if (aGls[i].textContent.trim() == "GLOSSARY FEATURE")
  1285. {
  1286. p = aGls[i].parentElement;
  1287. break;
  1288. }
  1289. }
  1290. if (p)
  1291. {
  1292. var glosOuters = [];
  1293. var glosInnerStart = 0;
  1294. var countGl = 0;
  1295. var glossaries = p.innerHTML.split(br);
  1296. if (glossaries.length > 2)
  1297. {
  1298. glosOuters = [p];
  1299. glosInnerStart = 2;
  1300. }
  1301. else
  1302. {
  1303. glosOuters = p.nextSibling.querySelectorAll("td");
  1304. glosInnerStart = 0;
  1305. }
  1306. var rgxKey = />[^><]+</;
  1307. var rgxKeyClean = /[><]+/g;
  1308. var rgxKeyPunct = /[\(\)\[\]\:\!]/g;
  1309. var rgxContentClean = /<[^<]*>/g;
  1310. var textOrg = "";
  1311. var textEng = "";
  1312. var isTextReplaced = false;
  1313. var isOutdated = false;
  1314.  
  1315. var eleBtnResummit = document.querySelector("input[type='submit'][value^='RESUBMIT']");
  1316. if (eleBtnResummit)
  1317. {
  1318. isTextReplaced = true;
  1319. }
  1320. else
  1321. {
  1322. var eleTextOrg = document.querySelector("#suggestion_value_new");
  1323. if (eleTextOrg)
  1324. {
  1325. textOrg = eleTextOrg.value.trim().toLowerCase();
  1326. }
  1327. if (textOrg == "")
  1328. {
  1329. isTextReplaced = true;
  1330. }
  1331. }
  1332. if (!isTextReplaced)
  1333. {
  1334. var eleTrs = document.querySelectorAll(".progress tr");
  1335. isOutdated = (eleTrs.length >= 3);
  1336. if (isOutdated)
  1337. {
  1338. textEng = eleTrs[eleTrs.length - 1].firstElementChild.textContent.trim().toLowerCase();
  1339. }
  1340. }
  1341. for (var i = 0; i < glosOuters.length; i++)
  1342. {
  1343. var glosOuter = glosOuters[i];
  1344. var glosInners = glosOuter.innerHTML.split(br);
  1345. isEdit = false;
  1346. for (var j = glosInnerStart; j < glosInners.length; j++)
  1347. {
  1348. var glossary = glosInners[j].trim();
  1349. if (glossary.length > 0 && glossary.indexOf(tag) == 0)
  1350. {
  1351. var colonIndex = glossary.indexOf(colon);
  1352. var contentHead = glossary.substr(0, colonIndex + 3);
  1353. var contentAll = glossary.substr(colonIndex + 3);
  1354. var contentWords = contentAll.split(comma);
  1355. var contentFirst = contentWords[0].trim();
  1356. for (var k = 0; k < contentWords.length; k++)
  1357. {
  1358. var contentNew = contentWords[k].trim();
  1359. var contentSub = null;
  1360. var bracketPos = contentNew.indexOf(" (");
  1361. if (bracketPos > -1)
  1362. {
  1363. contentSub = contentNew.substr(bracketPos);
  1364. contentNew = contentNew.substr(0, bracketPos);
  1365. }
  1366. contentNew = " <span id='stsh_gls_" + countGl
  1367. + "' onclick='clickToSelect(this)'>"
  1368. + contentNew + "</span>";
  1369. //+ "<span style='color: white; cursor: pointer;'>^</span>";
  1370. if (contentSub)
  1371. {
  1372. contentNew += "<span "
  1373. + "onclick='clickToSelect(this.previousElementSibling)'>"
  1374. + contentSub + "</span>";
  1375. }
  1376. contentWords[k] = contentNew;
  1377. countGl++;
  1378. }
  1379. if (!isTextReplaced)
  1380. {
  1381. var keys = contentHead.match(rgxKey);
  1382. if (keys && keys.length > 0)
  1383. {
  1384. var key = keys[0].replace(rgxKeyClean, "").trim().toLowerCase();
  1385. var contentClean = contentFirst.replace(rgxContentClean, "");
  1386. var contentLower = contentClean.toLowerCase();
  1387. var textCur = "";
  1388. if (key == textOrg.replace(rgxKeyPunct, ""))
  1389. {
  1390. textCur = textOrg;
  1391. }
  1392. else if (key == textEng.replace(rgxKeyPunct, ""))
  1393. {
  1394. textCur = textEng;
  1395. }
  1396. if (textCur != "" && key != contentLower)
  1397. {
  1398. var rgxReplace = new RegExp(key, "i");
  1399. eleTextOrg.value = textCur.replace(rgxReplace, contentClean);
  1400. console.log("Replaced: " + eleTextOrg.value);
  1401. isTextReplaced = true;
  1402. }
  1403. }
  1404. }
  1405. glosInners[j] = contentHead + contentWords.join(comma);
  1406. isEdit = true;
  1407. }
  1408. }
  1409. if (isEdit && false)
  1410. {
  1411. // old feature
  1412. glosOuter.innerHTML = glosInners.join(brSpace);
  1413. }
  1414. }
  1415. }
  1416. }, 200);
  1417. }
  1418. // Insert clicked word in last textarea
  1419. {
  1420. var eleTextLast = null;
  1421. if (document.activeElement && document.activeElement.tagName == "TEXTAREA")
  1422. {
  1423. eleTextLast = document.activeElement;
  1424. }
  1425. var elesText = document.querySelectorAll("textarea#suggestion_value_new \
  1426. , textarea[name='suggestion_comment'] \
  1427. , textarea#add_to_discussion \
  1428. , textarea[name^='autoreplace']");
  1429. for (var i = 0; i < elesText.length; i++)
  1430. {
  1431. elesText[i].addEventListener('focus', function(ev)
  1432. {
  1433. eleTextLast = ev.target;
  1434. });
  1435. }
  1436. setTimeoutCustom(function()
  1437. {
  1438. var elesInsert = document.querySelectorAll(".insertword");
  1439. for (var i = 0; i < elesInsert.length; i++)
  1440. {
  1441. removeAllEventListeners(elesInsert[i]);
  1442. }
  1443. function insertAtCaret(txtarea, text)
  1444. {
  1445. // Edit from STS
  1446. var scrollPos = txtarea.scrollTop;
  1447. var strPos = 0;
  1448. var strLength = 0;
  1449. var br = ((txtarea.selectionStart || txtarea.selectionStart == '0') ? "ff" : (document.selection ? "ie" : false));
  1450. if (br == "ie")
  1451. {
  1452. txtarea.focus();
  1453. var range = document.selection.createRange();
  1454. range.moveStart('character', -txtarea.value.length);
  1455. strPos = range.text.length;
  1456. }
  1457. else if (br == "ff")
  1458. {
  1459. strPos = txtarea.selectionStart;
  1460. strLength = txtarea.selectionEnd - txtarea.selectionStart;
  1461. }
  1462. var front = (txtarea.value).substring(0, strPos);
  1463. var back = (txtarea.value).substring(strPos + strLength, txtarea.value.length);
  1464. txtarea.value = front + text + back;
  1465. strPos = strPos + text.length;
  1466. if (br == "ie")
  1467. {
  1468. txtarea.focus();
  1469. var range = document.selection.createRange();
  1470. range.moveStart('character', -txtarea.value.length);
  1471. range.moveStart('character', strPos);
  1472. range.moveEnd('character', 0);
  1473. range.select();
  1474. }
  1475. else if (br == "ff")
  1476. {
  1477. txtarea.selectionStart = strPos;
  1478. txtarea.selectionEnd = strPos;
  1479. txtarea.focus();
  1480. }
  1481. txtarea.scrollTop = scrollPos;
  1482. }
  1483. elesInsert = document.querySelectorAll(".insertword");
  1484. for (var i = 0; i < elesInsert.length; i++)
  1485. {
  1486. //elesInsert[i].classList.add("stsh_unselectable");
  1487. elesInsert[i].addEventListener("click", function(ev)
  1488. {
  1489. if (eleTextLast)
  1490. {
  1491. insertAtCaret(eleTextLast , ev.target.textContent.trim());
  1492. }
  1493. });
  1494. }
  1495. }, 500);
  1496. }
  1497. // Restyle glossary
  1498. {
  1499. var eleP = null;
  1500. var elesA = document.querySelectorAll("a[href='glossary.php']");
  1501. for (var i = 0; i < elesA.length; i++)
  1502. {
  1503. if (elesA[i].textContent.trim() == "GLOSSARY FEATURE")
  1504. {
  1505. eleP = elesA[i].parentElement;
  1506. break;
  1507. }
  1508. }
  1509. if (eleP)
  1510. {
  1511. var nodeText = eleP.firstElementChild.nextSibling;
  1512. if (nodeText.nodeType == document.TEXT_NODE)
  1513. {
  1514. var ele = document.createElement("span");
  1515. ele.textContent = nodeText.textContent;
  1516. nodeText.parentElement.removeChild(nodeText);
  1517. insertAfterElement(ele, eleP.firstElementChild);
  1518. }
  1519. var eleHead;
  1520. if (eleP.nextElementSibling.tagName == "TABLE")
  1521. {
  1522. eleHead = eleP.nextElementSibling;
  1523. }
  1524. else
  1525. {
  1526. eleHead = eleP;
  1527. }
  1528. eleHead.classList.add("stsh_glossary_header");
  1529. var elesTerm = eleHead.querySelectorAll("a[href^='http://translation.steampowered.com/translate.php?search_input=']");
  1530. for (var i = 0; i < elesTerm.length; i++)
  1531. {
  1532. elesTerm[i].classList.add("stsh_glossary_term");
  1533. }
  1534. {
  1535. var eleSpan = null;
  1536. if (eleHead.tagName == "TABLE")
  1537. {
  1538. eleSpan = eleHead.previousElementSibling.querySelector("span");
  1539. }
  1540. else
  1541. {
  1542. eleSpan = eleHead.querySelector("span");
  1543. }
  1544. eleSpan.textContent = eleSpan.textContent.replace("(click to copy to top)", "(click to copy to suggestion or comment)");
  1545. }
  1546. }
  1547. }
  1548. // Auto link http
  1549. // Format comment
  1550. {
  1551. var countSugStatus = document.querySelectorAll(
  1552. ".suggestions_list span[class^='suggestion_status_']").length;
  1553. var regUrl = /http[^ "]+/ig;
  1554. var hostUrl = "http://translation.steampowered.com/";
  1555. var hostReplace = "/";
  1556. var eleComments = document.querySelectorAll(""
  1557. + ".suggestion_signature > i:nth-child(3), "
  1558. + ".suggestion_signature div:nth-child(1) > i:nth-child(4), "
  1559. + ".suggestion_signature div:nth-child(1) > i:nth-child(6), "
  1560. + "*[class^='row'] > td:nth-child(2) ");
  1561. for (var i = 0; i < eleComments.length; i++)
  1562. {
  1563. var comment = eleComments[i].innerHTML + " ";
  1564. if (comment.indexOf("<a") == -1)
  1565. {
  1566. var commentUrls = comment.match(regUrl) || [];
  1567. for (var j = 0; j < commentUrls.length; j++)
  1568. {
  1569. var urlDecode = commentUrls[j];
  1570. try
  1571. {
  1572. urlDecode = decodeURIComponent(commentUrls[j]);
  1573. if (countSugStatus == 0 && urlDecode.indexOf(hostUrl) == 0)
  1574. {
  1575. var query = getQueryByName("search_input", urlDecode.replace("&amp;", "&"));
  1576. if (query != "")
  1577. {
  1578. urlDecode = query;
  1579. }
  1580. else
  1581. {
  1582. urlDecode = urlDecode.replace(hostUrl, hostReplace);
  1583. }
  1584. }
  1585. }
  1586. catch (ex)
  1587. {
  1588. console.error("FormatComment", ex.message);
  1589. }
  1590. var commentUrl = commentUrls[j] + " ";
  1591. comment = comment.replace(commentUrl,"<a target='_blank' href='"
  1592. + commentUrls[j] + "' >" + urlDecode + "</a> ");
  1593. }
  1594. }
  1595. comment = comment.trim();
  1596. if (comment.indexOf("Comment:") == 0)
  1597. {
  1598. eleComments[i].classList.add("stsh_text_comment_header");
  1599. comment = comment
  1600. .replace("Comment:", "Comment: <span class='stsh_text_comment'>")
  1601. .replace(/\/ /g, "<span class='stsh_white stsh_pad'>/</span> ")
  1602. .replace(/ \//g, " <span class='stsh_white stsh_pad'>/</span>")
  1603. .replace(/\-\&gt\;/g, "<span class='stsh_white stsh_pad'>-&gt;</span>")
  1604. .replace(/\-\-/g, "<span class='stsh_white stsh_pad'>--</span>")
  1605. .replace(/\, /g, "<span class='stsh_white stsh_pad'>, </span>")
  1606. .replace(/\* /g, "<span class='stsh_white stsh_pad'><br>* </span>")
  1607. + "</span>";
  1608. }
  1609. eleComments[i].innerHTML = comment;
  1610. var eleAs = eleComments[i].querySelectorAll("a");
  1611. for (var j = 0; j < eleAs.length; j++)
  1612. {
  1613. var href = eleAs[j].getAttribute("href");
  1614. if (href.indexOf("#") > -1)
  1615. {
  1616. eleAs[j].setAttribute("href", href.replace(/\#/g,"%23"));
  1617. }
  1618. }
  1619. //if (comment.indexOf("Comment:") != 0)
  1620. {
  1621. // Discussion comment
  1622. var rgxImg = /(\.(jpg|png|gif)|\/ugc\/)/i;
  1623. var rgxHolder = /:\/\/imgur.com\/[a-z0-9]+/i;
  1624. var strHolder = "://imgur.com/";
  1625. var strHolderReplace = "://i.imgur.com/";
  1626. var elesA = eleComments[i].querySelectorAll("a");
  1627. for (var j = 0; j < elesA.length; j++)
  1628. {
  1629. var href = elesA[j].getAttribute("href");
  1630. if (rgxImg.test(href))
  1631. {
  1632. if (elesA[j].querySelectorAll("img").length == 0)
  1633. {
  1634. var ele = document.createElement("img");
  1635. ele.classList.add("stsh_comment_img");
  1636. ele.setAttribute("src", href);
  1637. ele.setAttribute("title", href);
  1638. ele.setAttribute("onclick", " if (this.style.minWidth != '850px') "
  1639. + " { this.style.minWidth = this.naturalWidth < 850 ? this.naturalWidth + 'px' : '850px'; } "
  1640. + " else { this.style.minWidth = '400px'; } ");
  1641. insertAfterElement(ele, elesA[j]);
  1642. }
  1643. }
  1644. else if (rgxHolder.test(href))
  1645. {
  1646. var hrefNew = href.replace(strHolder, strHolderReplace) + ".jpg";
  1647. var ele = document.createElement("img");
  1648. ele.classList.add("stsh_comment_img");
  1649. ele.setAttribute("src", hrefNew);
  1650. ele.setAttribute("title", hrefNew);
  1651. ele.setAttribute("onclick", " if (this.style.minWidth != '850px') "
  1652. + " { this.style.minWidth = this.naturalWidth < 850 ? this.naturalWidth + 'px' : '850px'; } "
  1653. + " else { this.style.minWidth = '400px'; } ");
  1654. insertAfterElement(ele, elesA[j]);
  1655. }
  1656. }
  1657. }
  1658. }
  1659. }
  1660. // Restyle token info
  1661. {
  1662. var divIntro = document.querySelector("#suggestionmain > div.smallcopy");
  1663. if (divIntro)
  1664. {
  1665. var qBranch = getQueryByName("branch");
  1666. var htmlEdit = "You are editing";
  1667. var htmlEditReplace = "";
  1668. var htmlToken = "Token <";
  1669. var htmlTokenReplace = "Token: <";
  1670. var htmlToken2 = "token-key";
  1671. var htmlToken2Replace = "Token";
  1672. var htmlLiveLinkMoved =
  1673. '<font style="color:red;">This FAQ likely does not exist anymore!</font>'
  1674. + ' The generated <a href="https://support.steampowered.com/kb_article.php?ref="'
  1675. + ' target="_blank">live link</a>'
  1676. + ' seems dead or is redirecting.';
  1677. var htmlLiveLinkMovedReplace =
  1678. '<font style="color:red; cursor: help;"'
  1679. + ' title="The generated live link seems dead or is redirecting.">'
  1680. + 'This FAQ likely does not exist anymore!</font>';
  1681. var htmlLiveLinkMovedWithLiveLink =
  1682. '<font style="color:red;">This FAQ likely does not exist anymore!</font>'
  1683. + ' The generated <a href="https://support.steampowered.com/kb_article.php?ref='
  1684. var htmlLiveLinkMovedWithLiveLinkReplace =
  1685. '<a href="https://support.steampowered.com/kb_article.php?ref=';
  1686. var htmlLiveLinkMovedWithLiveLink2 =
  1687. '" target="_blank">live link</a>'
  1688. + ' seems dead or is redirecting.';
  1689. var htmlLiveLinkMovedWithLiveLink2Replace =
  1690. '" target="_blank">Live link</a>'
  1691. + ' - <font style="color:red; cursor: help;"'
  1692. + ' title="The generated live link seems dead or is redirecting.">'
  1693. + 'This FAQ likely does not exist anymore!</font>';
  1694. var htmlLiveLink = 'target="_blank">Live link';
  1695. var htmlLiveLinkReplace = 'target="_blank">Live link'; // Change in condition
  1696. var htmlFile = " of <";
  1697. var htmlFileReplace = ' <br>File: <font class="stsh_info_file stsh_blue" onclick="clickToSelect(this)">' + qBranch + '</font> >> <';
  1698. var htmlFrom = "<br>Added on <";
  1699. var htmlFromReplace = " &nbsp;&nbsp;Added: <";
  1700. var htmlUpdated = ">. Updated on <";
  1701. var htmlUpdatedReplace = "> &nbsp;&nbsp;Updated: <";
  1702. var htmlUpdated2 = "<br> Updated on <";
  1703. var htmlUpdated2Replace = " &nbsp;&nbsp;Updated: <";
  1704. var htmlSugg = 'You have <font style="';
  1705. var htmlSuggReplace = 'You have <font title="Enter and submit new suggestions below. Do not alter HTML tags or variables." style="cursor: help; ';
  1706. var htmlIntro = "Enter and submit new suggestions below. Do not alter HTML tags or variables.";
  1707. var htmlIntroReplace = ' &nbsp;&nbsp;<a href="mailto:translationserver@valvesoftware.com" '
  1708. + ' title="Please report token issues by posting a TOKEN DISCUSSION \r\nor email to translationserver@valvesoftware.com" '
  1709. + ' style="cursor: help; ">'
  1710. + '<font style="color:white;">Report Tokens</font></a>';
  1711. var htmlContact = '<br>Please report token issues by posting a <font style="color:#a4b23c;">TOKEN DISCUSSION</font> tagged<input style="border:none; color:#FFFFFF; background-color:#111111; cursor:pointer;" onclick="tosts(\'truncated\')" value="[sts_admin][truncated]" type="button">or<input style="border:none; color:#FFFFFF; background-color:#111111; cursor:pointer;" onclick="tosts(\'typo\');" value="[sts_admin][typo]" type="button">or<input style="border:none; color:#FFFFFF; background-color:#111111; cursor:pointer;" onclick="tosts(\'unlockpls\')" value="[sts_admin][unlockpls]" type="button">or by <a href="mailto:translationserver@valvesoftware.com">email</a>.';
  1712. var htmlContactReplace = '';
  1713. var htmlContact2 = '<br>Please report token issues by posting a <font style="color:#a4b23c;">TOKEN DISCUSSION</font> tagged<input style="border:none; color:#FFFFFF; background-color:#111111; cursor:pointer;" type="button" onclick="tosts(\'truncated\')" value="[sts_admin][truncated]">or<input style="border:none; color:#FFFFFF; background-color:#111111; cursor:pointer;" type="button" onclick="tosts(\'typo\');" value="[sts_admin][typo]">or<input style="border:none; color:#FFFFFF; background-color:#111111; cursor:pointer;" type="button" onclick="tosts(\'unlockpls\')" value="[sts_admin][unlockpls]">or by <a href="mailto:translationserver@valvesoftware.com">email</a>.';
  1714. var htmlContact2Replace = '';
  1715. var rgxTestEmail = /<br><font style="color:#a4b23c;">This is part of email message .+ - you can test it by following this link:<\/font> /;
  1716. var htmlTestEmailReplace = '';
  1717. var rgxTestEmail2 = /<a href="test_email\.php\?filename=.+\&amp;lang=thai" target="_blank">Test<\/a>/;
  1718. var htmlTestEmail2Replace = '';
  1719. var htmlsTestEmail = rgxTestEmail.exec(divIntro.innerHTML);
  1720. if (htmlsTestEmail && htmlsTestEmail.length > 0)
  1721. {
  1722. var htmlTestEmail = htmlsTestEmail[0].replace('<br><font style="color:#a4b23c;">This is part of email message ', "")
  1723. .replace(' - you can test it by following this link:</font> ', "");
  1724. var htmlTestEmail2 = "";
  1725. var htmlsTestEmail2 = rgxTestEmail2.exec(divIntro.innerHTML);
  1726. if (htmlsTestEmail2 && htmlsTestEmail2.length > 0)
  1727. {
  1728. htmlTestEmail2 = htmlsTestEmail2[0].replace('<a href="', "")
  1729. .replace('" target="_blank">Test</a>', "");
  1730. }
  1731. htmlIntroReplace += ' &nbsp;&nbsp;Test: <a href="' + htmlTestEmail2
  1732. + '" title="You can test email by following this link." target="_blank">'
  1733. + htmlTestEmail + '</a>';
  1734. }
  1735. if (key !== "")
  1736. {
  1737. htmlIntroReplace += ' <br>Share: <font class="stsh_token_share stsh_green stsh_truncate" '
  1738. + 'onclick="clickToSelect(this)">'
  1739. + 'http://translation.steampowered.com/translate.php?search_input=' + key
  1740. + "</font> <br>";
  1741. }
  1742. var urlLiveLink = "https://support.steampowered.com/kb_article.php?ref=";
  1743. var eleLiveLink = divIntro.querySelector("a[href^='" + urlLiveLink + "']");
  1744. if (eleLiveLink)
  1745. {
  1746. htmlLiveLinkReplace = 'target="_blank" title="Live link">' + eleLiveLink.getAttribute("href").replace(urlLiveLink, "");
  1747. }
  1748. var isComplete = (divIntro.innerHTML.indexOf(htmlContact) > -1);
  1749. divIntro.innerHTML = divIntro.innerHTML
  1750. .replace(htmlEdit, htmlEditReplace)
  1751. .replace(htmlToken, htmlTokenReplace)
  1752. .replace(htmlToken2, htmlToken2Replace)
  1753. .replace(htmlLiveLinkMoved, htmlLiveLinkMovedReplace)
  1754. .replace(htmlLiveLinkMovedWithLiveLink, htmlLiveLinkMovedWithLiveLinkReplace)
  1755. .replace(htmlLiveLinkMovedWithLiveLink2, htmlLiveLinkMovedWithLiveLink2Replace)
  1756. .replace(htmlLiveLink, htmlLiveLinkReplace)
  1757. .replace(htmlFile, htmlFileReplace)
  1758. .replace(htmlFrom, htmlFromReplace)
  1759. .replace(htmlUpdated, htmlUpdatedReplace)
  1760. .replace(htmlUpdated2, htmlUpdated2Replace)
  1761. .replace(htmlSugg, htmlSuggReplace)
  1762. .replace(htmlIntro, htmlIntroReplace)
  1763. .replace(htmlContact, htmlContactReplace)
  1764. .replace(htmlContact2, htmlContact2Replace)
  1765. .replace(rgxTestEmail, htmlTestEmailReplace)
  1766. .replace(rgxTestEmail2, htmlTestEmail2Replace)
  1767. .trim();
  1768. var eleToken = document.querySelector("a[href^='Us_And_Them.php?']");
  1769. if (eleToken)
  1770. {
  1771. if (eleToken.textContent != "Token")
  1772. {
  1773. eleToken.classList.add("stsh_token_name");
  1774. eleToken.classList.add("stsh_truncate");
  1775. }
  1776. }
  1777. if (!isComplete)
  1778. {
  1779. var stsh_introReplace_start = new Date();
  1780. var stsh_introReplace_itv = setIntervalCustom(function(params)
  1781. {
  1782. var divIntro = params[0];
  1783. var htmlContact = params[1];
  1784. var htmlContactReplace = params[2];
  1785. var stsh_introReplace_isEnd = false;
  1786. var stsh_introReplace_cur = new Date();
  1787. if (divIntro.innerHTML.indexOf(htmlContact) > -1)
  1788. {
  1789. divIntro.innerHTML = divIntro.innerHTML
  1790. .replace(htmlContact, htmlContactReplace);
  1791. stsh_introReplace_isEnd = true;
  1792. }
  1793. if (stsh_introReplace_isEnd || stsh_introReplace_cur - stsh_introReplace_start > 10000)
  1794. {
  1795. clearInterval(stsh_introReplace_itv);
  1796. }
  1797. }, 100, [divIntro, htmlContact, htmlContactReplace]);
  1798. }
  1799. }
  1800. }
  1801. // Restyle token discussion
  1802. {
  1803. var eleDiscuss = document.querySelector("a[name='tokendiscussion']");
  1804. if (eleDiscuss)
  1805. {
  1806. var htmlHeader = "TOKEN DISCUSSION (keep global comments English please!):";
  1807. var htmlHeaderReplace = "TOKEN DISCUSSION:";
  1808. var eleHeader = eleDiscuss.nextElementSibling;
  1809. if (eleHeader)
  1810. {
  1811. eleHeader.setAttribute("title", "Keep global comments English please!");
  1812. eleHeader.style.cursor = "help";
  1813. eleHeader.textContent = eleHeader.textContent.replace(htmlHeader, htmlHeaderReplace);
  1814. }
  1815. var eleParent = eleDiscuss.parentElement;
  1816. eleParent.classList.add("stsh_discussion_header");
  1817. if (eleParent.nextElementSibling)
  1818. {
  1819. eleParent.nextElementSibling.classList.add("stsh_discussion_section");
  1820. }
  1821. var elesInput = document.querySelectorAll("input[value='[stsadmin]']");
  1822. if (elesInput.length === 2)
  1823. {
  1824. elesInput[1].parentElement.removeChild(elesInput[1]);
  1825. }
  1826. var eleSpan = document.createElement("span");
  1827. eleSpan.innerHTML = '<input style="border:none; color:#888888; background-color:#111111; cursor:pointer;" onclick="tosts(\'truncated\')" value="[sts_admin][truncated]" type="button">'
  1828. + '<input style="border:none; color:#888888; background-color:#111111; cursor:pointer;" onclick="tosts(\'typo\');" value="[sts_admin][typo]" type="button">'
  1829. + '<input style="border:none; color:#888888; background-color:#111111; cursor:pointer;" onclick="tosts(\'unlockpls\')" value="[sts_admin][unlockpls]" type="button">';
  1830. eleParent.appendChild(eleSpan);
  1831. var eleCopy = document.querySelector("#autocopy");
  1832. if (eleCopy)
  1833. {
  1834. eleCopy.previousElementSibling.classList.add("stsh_autoCopy_header");
  1835. }
  1836. var eleFriendDiscuss = document.querySelector(".friend_block_discussions");
  1837. if (eleFriendDiscuss)
  1838. {
  1839. if (eleCopy)
  1840. {
  1841. insertBeforeElement(document.createElement("br"), eleCopy.previousElementSibling);
  1842. }
  1843. var eleTableDiscuss = eleFriendDiscuss.parentElement.parentElement.parentElement.parentElement;
  1844. if (eleTableDiscuss.tagName === "TABLE")
  1845. {
  1846. eleTableDiscuss.classList.add("stsh_discussion_table");
  1847. //insertBeforeElement(eleTableDiscuss, eleTableDiscuss.previousElementSibling.previousElementSibling);
  1848. }
  1849. }
  1850. }
  1851. }
  1852. // Move up glossary
  1853. {
  1854. var eleFriendDiscuss = document.querySelector(".friend_block_discussions");
  1855. if (!eleFriendDiscuss)
  1856. {
  1857. var eleDiscuss = document.querySelector(".stsh_discussion_header");
  1858. if (eleDiscuss)
  1859. {
  1860. var eleGlosGroup = document.createElement("div");
  1861. eleGlosGroup.classList.add("stsh_glossary_group");
  1862. insertBeforeElement(eleGlosGroup, eleDiscuss);
  1863. var eleHead = document.querySelector(".stsh_glossary_header");
  1864. if (eleHead)
  1865. {
  1866. if (!(eleHead.childNodes.length === 5
  1867. && eleHead.childNodes[4].nodeType === document.TEXT_NODE
  1868. && eleHead.childNodes[4].nodeValue === "No results"))
  1869. {
  1870. eleGlosGroup.appendChild(document.createElement("br"));
  1871. if (eleHead.tagName === "TABLE")
  1872. {
  1873. eleGlosGroup.appendChild(eleHead.previousElementSibling);
  1874. }
  1875. else
  1876. {
  1877. insertAfterElement(document.createElement("br"), eleHead);
  1878. }
  1879. eleGlosGroup.appendChild(eleHead);
  1880. var eleCopy = document.querySelector(".stsh_autoCopy_header");
  1881. if (eleCopy)
  1882. {
  1883. insertBeforeElement(document.createElement("br"), eleCopy);
  1884. }
  1885. }
  1886. }
  1887. }
  1888. }
  1889. }
  1890. // Add shortcut keys
  1891. {
  1892. var elesForm = document.querySelectorAll(".lbAction");
  1893. for (var i = 0; i < elesForm.length; i++)
  1894. {
  1895. var eleForm = elesForm[i];
  1896. var eleSubmit = eleForm.querySelector("input[type=submit]");
  1897. if (eleSubmit)
  1898. {
  1899. addKeyCtrlEnter(eleForm, eleSubmit);
  1900. }
  1901. }
  1902. var elesInputApprove = document.querySelectorAll(".suggestion_signature input[value~='APPROVE']");
  1903. if (elesInputApprove.length > 0)
  1904. {
  1905. var eleBind = elesInputApprove[0];
  1906. addKeyAlt(document, eleBind, 219, ""); // [
  1907. addKeyAlt(document, eleBind, "BracketLeft", ""); // [
  1908. addKeyAlt(document, eleBind, 79, ""); // O
  1909. addKeyAlt(document, eleBind, 65, ""); // A
  1910. disableAfterClick(eleBind);
  1911. }
  1912. var eleInputApproveNext = document.querySelector(".suggestion_signature input[value~='Next']");
  1913. if (eleInputApproveNext)
  1914. {
  1915. eleInputApproveNext.value = "Next";
  1916. var eleBind = null;
  1917. if (!eleInputApproveNext.disabled)
  1918. {
  1919. // Can go next
  1920. if (elesInputApprove.length === 1)
  1921. {
  1922. // Go next if only 1 suggestion
  1923. eleBind = eleInputApproveNext;
  1924. }
  1925. else if (elesInputApprove.length > 1)
  1926. {
  1927. // Only approve if more than 1 suggestion
  1928. eleBind = elesInputApprove[0];
  1929. }
  1930. }
  1931. else
  1932. {
  1933. // Can't go next
  1934. if (elesInputApprove.length > 0)
  1935. {
  1936. var eleBind = elesInputApprove[0];
  1937. }
  1938. }
  1939. if (eleBind)
  1940. {
  1941. addKeyAlt(document, eleBind, 221, ""); // ]
  1942. addKeyAlt(document, eleBind, "BracketRight", ""); // ]
  1943. addKeyAlt(document, eleBind, 80, ""); // P
  1944. addKeyAlt(document, eleBind, 83, ""); // S
  1945. addKeyCtrl(document, eleBind, 220, ""); // Backslash
  1946. addKeyCtrl(document, eleBind, "Backslash", ""); // Backslash
  1947. addKeyCtrl(document, eleBind, 45, "Ins"); // INS
  1948. disableAfterClick(eleBind);
  1949. }
  1950. }
  1951. var eleInputDecline = document.querySelector(".suggestion_signature input[value~='DECLINE']");
  1952. if (eleInputDecline)
  1953. {
  1954. var eleBind = eleInputDecline;
  1955. addKeyCtrl(document, eleBind, 46, "Del"); // DEL
  1956. disableAfterClick(eleBind);
  1957. }
  1958. else
  1959. {
  1960. var eleReconsider = document.querySelector(".suggestion_status_approved > a, .suggestion_status_declined > a");
  1961. if (eleReconsider)
  1962. {
  1963. if (eleReconsider.parentElement.classList.contains("suggestion_status_approved"))
  1964. {
  1965. eleReconsider.firstElementChild.textContent += " (Ctrl+Del)";
  1966. var eleBind = eleReconsider;
  1967. addKeyCtrl(document, eleBind, 46, ""); // DEL
  1968. }
  1969. else
  1970. {
  1971. if (!eleReconsider.parentElement.parentElement
  1972. .querySelector(".suggestion_signature .lbAction[name^='mymodcomment']"))
  1973. {
  1974. eleReconsider.firstElementChild.textContent += " (Ctrl+Ins)";
  1975. var eleBind = eleReconsider;
  1976. addKeyAlt(document, eleBind, 221, ""); // ]
  1977. addKeyAlt(document, eleBind, "BracketRight", ""); // ]
  1978. addKeyAlt(document, eleBind, 80, ""); // P
  1979. addKeyAlt(document, eleBind, 83, ""); // S
  1980. addKeyCtrl(document, eleBind, 220, ""); // Backslash
  1981. addKeyCtrl(document, eleBind, "Backslash", ""); // Backslash
  1982. addKeyCtrl(document, eleBind, 45, "Ins"); // INS
  1983. }
  1984. }
  1985. }
  1986. }
  1987. var inputDeclineNext = document.querySelector(".suggestion_signature input[value~='Next']:nth-child(5)");
  1988. if (inputDeclineNext)
  1989. {
  1990. inputDeclineNext.value = "Next";
  1991. }
  1992. var elesTextRemoveComment = document.querySelectorAll(".stsh_text_removeComment");
  1993. if (elesTextRemoveComment.length > 0)
  1994. {
  1995. // Remove last comment
  1996. var i = elesTextRemoveComment.length - 1;
  1997. elesTextRemoveComment[i].firstElementChild.textContent += " (Ctrl+Bksp)";
  1998.  
  1999. var eleBind = elesTextRemoveComment[i];
  2000. addKeyCtrl(document, eleBind, 8, "Bksp"); // Backspace
  2001. }
  2002. var inputPrev = document.querySelector("#suggestions_nav > input[value^='Prev']");
  2003. if (inputPrev)
  2004. {
  2005. var eleBind = inputPrev;
  2006. addKeyCtrl(document, eleBind, 219, "["); // [
  2007. addKeyCtrl(document, eleBind, "BracketLeft", ""); // [
  2008. disableAfterClick(eleBind);
  2009. }
  2010. var inputNext = document.querySelector("#suggestions_nav > input[value~='Next']");
  2011. if (inputNext)
  2012. {
  2013. var eleBind = inputNext;
  2014. addKeyCtrl(document, eleBind, 221, "]"); // ]
  2015. addKeyCtrl(document, eleBind, "BracketRight", ""); // ]
  2016. disableAfterClick(eleBind);
  2017. }
  2018. }
  2019. // Check special chars
  2020. {
  2021. var h1s = document.querySelectorAll(".progress h1");
  2022. if (h1s.length == 2)
  2023. {
  2024. var h1Org = h1s[0];
  2025. var h1Trn = h1s[1];
  2026. var tdOrg = eleTextOrg;
  2027. var tdTrn = eleTextTrn;
  2028. if (tdOrg && tdTrn)
  2029. {
  2030. var strOrg = trimSpace(tdOrg.textContent);
  2031. var strTrn = trimSpace(tdTrn.textContent);
  2032. var statusTrnArr = checkSpecialCharMatched(strOrg, strTrn);
  2033. var statusTrnMatched = statusTrnArr[0];
  2034. var spOrg = statusTrnArr[1];
  2035. var spTrn = statusTrnArr[2];
  2036. if (spOrg > 0)
  2037. {
  2038. var spanSpOrg = document.createElement("span");
  2039. spanSpOrg.id = "stsh_spanSpOrg";
  2040. spanSpOrg.classList.add("stsh_blue");
  2041. spanSpOrg.innerHTML = " SpecialChar: " + spOrg;
  2042. h1Org.parentElement.appendChild(spanSpOrg);
  2043. // Check chars in translated
  2044. if (strTrn != "")
  2045. {
  2046. var spanSpTrn = document.createElement("span");
  2047. spanSpTrn.id = "stsh_spanSpTrn";
  2048. if (statusTrnMatched == 0)
  2049. {
  2050. spanSpTrn.classList.add("stsh_green");
  2051. }
  2052. else
  2053. {
  2054. spanSpTrn.classList.add("stsh_red");
  2055. }
  2056. var outputTrn = " SpecialChar: " + spTrn;
  2057. if (statusTrnMatched == 0)
  2058. {
  2059. outputTrn += " (Matched)";
  2060. }
  2061. else if (statusTrnMatched == 1)
  2062. {
  2063. outputTrn += " (Order not matched)";
  2064. }
  2065. else
  2066. {
  2067. outputTrn += " (Not matched)";
  2068. }
  2069. spanSpTrn.innerHTML = outputTrn;
  2070. h1Trn.parentElement.appendChild(spanSpTrn);
  2071. }
  2072. // Check chars in suggested
  2073. var divSugs = document.querySelectorAll(".suggestion_text");
  2074. for (var i = 0; i < divSugs.length; i++)
  2075. {
  2076. var divSug = divSugs[i];
  2077. var strSug = trimSpace(divSug.textContent);
  2078. var statusSugArr = checkSpecialCharMatched(strOrg, strSug);
  2079. var statusSugMatched = statusSugArr[0];
  2080. var spSug = statusSugArr[2];
  2081. var spanSpSug = document.createElement("span");
  2082. spanSpSug.classList.add("stsh_spanSpSug");
  2083. if (statusSugMatched == 0)
  2084. {
  2085. spanSpSug.classList.add("stsh_green");
  2086. }
  2087. else
  2088. {
  2089. spanSpSug.classList.add("stsh_red");
  2090. }
  2091. var outputSug = " SpecialChar: " + spSug;
  2092. if (statusSugMatched == 0)
  2093. {
  2094. outputSug += " (Matched)";
  2095. }
  2096. else if (statusSugMatched == 1)
  2097. {
  2098. outputSug += " (Order not matched)";
  2099. }
  2100. else
  2101. {
  2102. outputSug += " (Not matched)";
  2103. }
  2104. outputSug += " <br/><br/> ";
  2105. spanSpSug.innerHTML = outputSug;
  2106. divSug.insertBefore(spanSpSug, divSug.firstChild);
  2107. }
  2108. }
  2109. }
  2110. }
  2111. }
  2112. // Trim string in same token
  2113. {
  2114. var p = document.querySelector("#suggestionmain > div:nth-child(5) > p:nth-child(4)");
  2115. if (p)
  2116. {
  2117. for (var i = 0; i < p.childNodes.length; i++)
  2118. {
  2119. var child = p.childNodes[i];
  2120. if (child.nodeName == "#text")
  2121. {
  2122. child.nodeValue = child.nodeValue.trim();
  2123. }
  2124. }
  2125. }
  2126. }
  2127. // Display newlines
  2128. // Display specialChars
  2129. // Display HTML tags
  2130. {
  2131. if (eleTextOrg && eleTextTrn)
  2132. {
  2133. var htmlOrg = eleTextOrg.innerHTML.trim();
  2134. var htmlTrn = eleTextTrn.innerHTML.trim();
  2135. // Display newlines
  2136. if ((htmlOrg.indexOf("\n") > -1 || htmlOrg.indexOf("\\n") > -1
  2137. || htmlTrn.indexOf("\n") > -1 || htmlTrn.indexOf("\\n") > -1)
  2138. /*&& htmlOrg.indexOf("<br") < 0
  2139. && htmlOrg.indexOf("<p") < 0 && htmlOrg.indexOf("<div") < 0 && htmlOrg.indexOf("<li") < 0*/)
  2140. {
  2141. var h2SugHeader = document.querySelector("#suggestionmain > div > h2");
  2142. if (h2SugHeader)
  2143. {
  2144. var btn = document.createElement("input");
  2145. btn.id = "stsh_btn_displayNewlines";
  2146. btn.setAttribute("class", "stsh_btn_right");
  2147. btn.setAttribute("type", "button");
  2148. btn.setAttribute("value", "Display Newlines");
  2149. h2SugHeader.appendChild(btn);
  2150. function displayNewlines(ele)
  2151. {
  2152. if (ele)
  2153. {
  2154. ele.innerHTML = ele.innerHTML.trim()
  2155. .replace(/\n/g, "\n<br>")
  2156. .replace(/\\n/g, ' <span class="stsh_grey">\\n</span><br>')
  2157. .replace(/\\r \\n/g, ' <span class="stsh_grey">\\r\\n</span><br>')
  2158. .replace(/\<br\>[\s]+/g, "<br>&nbsp;");
  2159. }
  2160. }
  2161. btn.addEventListener("click", function(e)
  2162. {
  2163. e.target.disabled = true;
  2164. var eleBtnHtmlTags = document.querySelector("#stsh_btn_displayHtmlTags");
  2165. if (eleBtnHtmlTags)
  2166. {
  2167. eleBtnHtmlTags.disabled = true;
  2168. }
  2169. var tdOrg = document.querySelector(".stsh_text_org");
  2170. var tdTrn = document.querySelector(".stsh_text_trn");
  2171. displayNewlines(tdOrg);
  2172. displayNewlines(tdTrn);
  2173. var divSugs = document.querySelectorAll(".suggestion_text");
  2174. for (var i = 0; i < divSugs.length; i++)
  2175. {
  2176. var divSug = divSugs[i];
  2177. displayNewlines(divSug);
  2178. }
  2179. var textarea = document.querySelector("#suggestion_value_new");
  2180. if (textarea)
  2181. {
  2182. textarea.focus();
  2183. }
  2184. });
  2185. }
  2186. }
  2187. // Display specialChars
  2188. if (hasSpecialChar(htmlOrg) || hasSpecialChar(htmlTrn))
  2189. {
  2190. var h2SugHeader = document.querySelector("#suggestionmain > div > h2");
  2191. if (h2SugHeader)
  2192. {
  2193. var btn = document.createElement("input");
  2194. btn.id = "stsh_btn_displaySpecialChars";
  2195. btn.setAttribute("class", "stsh_btn_right");
  2196. btn.setAttribute("type", "button");
  2197. btn.setAttribute("value", "Display SpecialChars");
  2198. h2SugHeader.appendChild(btn);
  2199. function replaceSpecialChars(str, unicodeNumber)
  2200. {
  2201. var rgx = new RegExp("\\u" + padZeroHex(unicodeNumber, 4), "g");
  2202. return str.replace(rgx, '<span class="stsh_grey">[' + unicodeNumber + ']</span>');
  2203. }
  2204. function displaySpecialChars(ele)
  2205. {
  2206. if (ele)
  2207. {
  2208. var strInner = ele.innerHTML.trim();
  2209. for (var i = 0; i < 32; i++)
  2210. {
  2211. if (hasSpecialChar(strInner))
  2212. {
  2213. if (isSpecialChar(i))
  2214. {
  2215. strInner = replaceSpecialChars(strInner, i);
  2216. }
  2217. }
  2218. else
  2219. {
  2220. break;
  2221. }
  2222. }
  2223. ele.innerHTML = strInner;
  2224. }
  2225. }
  2226. btn.addEventListener("click", function(e)
  2227. {
  2228. e.target.disabled = true;
  2229. var tdOrg = document.querySelector(".stsh_text_org");
  2230. var tdTrn = document.querySelector(".stsh_text_trn");
  2231. displaySpecialChars(tdOrg);
  2232. displaySpecialChars(tdTrn);
  2233. var divSugs = document.querySelectorAll(".suggestion_text");
  2234. for (var i = 0; i < divSugs.length; i++)
  2235. {
  2236. var divSug = divSugs[i];
  2237. displaySpecialChars(divSug);
  2238. }
  2239. var textarea = document.querySelector("#suggestion_value_new");
  2240. if (textarea)
  2241. {
  2242. textarea.focus();
  2243. }
  2244. });
  2245. }
  2246. }
  2247. // Display HTML tags
  2248. if (htmlOrg.indexOf("<") > -1 || (htmlTrn.indexOf("<") > -1 && !eleTextTrn.querySelector("#stsh_moveSuggestionBox")))
  2249. {
  2250. var h2SugHeader = document.querySelector("#suggestionmain > div > h2");
  2251. if (h2SugHeader)
  2252. {
  2253. var btn = document.createElement("input");
  2254. btn.id = "stsh_btn_displayHtmlTags";
  2255. btn.setAttribute("class", "stsh_btn_right");
  2256. btn.setAttribute("type", "button");
  2257. btn.setAttribute("value", "Display HTML tags");
  2258. btn.setAttribute("title"
  2259. , "Some closing tags and attributes are autogenerated by web browser. \nPlease use with care!");
  2260. h2SugHeader.appendChild(btn);
  2261. function displayHtmlTags(ele)
  2262. {
  2263. if (ele)
  2264. {
  2265. var isSkip = false;
  2266. if (ele.classList.contains("stsh_text_org"))
  2267. {
  2268. if (ele.querySelector("span[style='color:#ff0000;']"))
  2269. {
  2270. ele.innerHTML = ele.innerHTML.replace(/<[\/]?span[^>]*>/ig, "");
  2271. }
  2272. if (ele.querySelector("font[style='BACKGROUND-COLOR: blue']"))
  2273. {
  2274. ele.innerHTML = ele.innerHTML.replace(/<[\/]?font[^>]*>/ig, "");
  2275. }
  2276. }
  2277. else if (ele.classList.contains("stsh_text_trn"))
  2278. {
  2279. if (ele.querySelector("#stsh_moveSuggestionBox"))
  2280. {
  2281. isSkip = true;
  2282. }
  2283. else if (ele.querySelector("span[style='color:#ff0000;']"))
  2284. {
  2285. ele.innerHTML = ele.innerHTML.replace(/<[\/]?span[^>]*>/ig, "");
  2286. }
  2287. }
  2288. else if (ele.classList.contains("suggestion_text"))
  2289. {
  2290. if (ele.querySelector("span[style='color:red;']"))
  2291. {
  2292. ele.innerHTML = ele.innerHTML.replace(/<[\/]?span[^>]*>/ig, "");
  2293. }
  2294. }
  2295. if (!isSkip)
  2296. {
  2297. ele.textContent = ele.innerHTML.trim();
  2298. var newHtml = ele.innerHTML;
  2299. newHtml = newHtml.replace(/&amp;/ig, "&")
  2300. .replace(/\n/ig, "\n<br>")
  2301. .replace(/&lt;/ig, '<span class="stsh_grey">&lt;')
  2302. .replace(/&gt;/ig, '&gt;</span>');
  2303. ele.innerHTML = newHtml;
  2304. }
  2305. }
  2306. }
  2307. btn.addEventListener("click", function(e)
  2308. {
  2309. e.target.disabled = true;
  2310. var eleBtnNewlines = document.querySelector("#stsh_btn_displayNewlines");
  2311. if (eleBtnNewlines)
  2312. {
  2313. eleBtnNewlines.disabled = true;
  2314. }
  2315. var tdOrg = document.querySelector(".stsh_text_org");
  2316. var tdTrn = document.querySelector(".stsh_text_trn");
  2317. displayHtmlTags(tdOrg);
  2318. displayHtmlTags(tdTrn);
  2319. var divSugs = document.querySelectorAll(".suggestion_text");
  2320. for (var i = 0; i < divSugs.length; i++)
  2321. {
  2322. var divSug = divSugs[i];
  2323. displayHtmlTags(divSug);
  2324. }
  2325. var textarea = document.querySelector("#suggestion_value_new");
  2326. if (textarea)
  2327. {
  2328. textarea.focus();
  2329. }
  2330. });
  2331. }
  2332. }
  2333. }
  2334. }
  2335. // Open comment when decline
  2336. {
  2337. var countComment = 0;
  2338. var elesComment = [];
  2339. var countSug = document.querySelectorAll(".suggestions_list .suggestion").length;
  2340. if (countSug > 0)
  2341. {
  2342. var countSugDeclined = document.querySelectorAll(
  2343. ".suggestions_list span[class='suggestion_status_declined']").length;
  2344. if (countSug !== countSugDeclined)
  2345. {
  2346. /*
  2347. // Test
  2348. var countSugApprovedByOther = 0;
  2349. var elesSugApproved = document.querySelectorAll(".suggestions_list span[class='suggestion_status_approved']");
  2350. for (var i = 0; i < elesSugApproved.length; i++)
  2351. {
  2352. if (!elesSugApproved[i].querySelector("a"))
  2353. {
  2354. countSugApprovedByOther++;
  2355. }
  2356. }
  2357. countSugDeclined += countSugApprovedByOther;
  2358. */
  2359. var elesSugCheck = document.querySelectorAll(".suggestions_list span[class^='suggestion_status_']");
  2360. if (countSug === elesSugCheck.length)
  2361. {
  2362. var eleSugDeclined = document.querySelector(".suggestions_list span[class='suggestion_status_declined']");
  2363. if (eleSugDeclined && eleSugDeclined === elesSugCheck[0] && eleSugDeclined.querySelector("a"))
  2364. {
  2365. countSugDeclined = countSug;
  2366. }
  2367. }
  2368. }
  2369. if (countSug === countSugDeclined)
  2370. {
  2371. var elesSugA = document.querySelectorAll(".suggestions_list span[class^='suggestion_status_'] a");
  2372. for (var i = 0; i < elesSugA.length; i++)
  2373. {
  2374. var eleComment = elesSugA[i].parentElement.parentElement.nextSibling;
  2375. if (eleComment.nodeName == "DIV" && eleComment.classList.contains("copy"))
  2376. {
  2377. if (elesSugA[i].parentElement.classList.contains("suggestion_status_declined"))
  2378. {
  2379. countComment++;
  2380. elesComment.push(eleComment);
  2381. }
  2382. }
  2383. }
  2384. if (countComment == elesSugA.length)
  2385. {
  2386. var isFocus = false;
  2387. for (var i = 0; i < elesComment.length; i++)
  2388. {
  2389. elesComment[i].style.display = "block";
  2390. if (!isFocus)
  2391. {
  2392. var eleTxt = elesComment[i].querySelector("textarea[name='suggestion_comment']");
  2393. if (eleTxt)
  2394. {
  2395. eleTxt.focus();
  2396. // Auto paste last comment
  2397. {
  2398. //var eleTextOrg = document.querySelector(".stsh_text_org");
  2399. if (eleTextOrg)
  2400. {
  2401. var textOrg = trimSpace(eleTextOrg.innerHTML).substr(0, 1000).toLowerCase();
  2402. if (textOrg == GM_getValue("textLastOrg_Comment", ""))
  2403. {
  2404. var textLastCur = GM_getValue("textLastCur_Comment", "");
  2405. if (textLastCur != "")
  2406. {
  2407. eleTxt.value = textLastCur;
  2408. }
  2409. setTimeoutCustom(function(ele)
  2410. {
  2411. if (ele)
  2412. {
  2413. var textLastCur = GM_getValue("textLastCur_Comment", "");
  2414. if (textLastCur != "")
  2415. {
  2416. ele.value = textLastCur;
  2417. //ele.selectionStart = 0;
  2418. //ele.selectionEnd = ele.value.length;
  2419. }
  2420. }
  2421. }, 250, eleTxt);
  2422. }
  2423. }
  2424. }
  2425. /*
  2426. // Typonion
  2427. var eleSugOuter = elesComment[i].parentElement.parentElement.parentElement.parentElement;
  2428. if (eleSugOuter.classList.contains("suggestion"))
  2429. {
  2430. var eleOnion = eleSugOuter.querySelector(".suggestion_text font[style='color:#01ec00;']");
  2431. if (eleOnion)
  2432. {
  2433. eleTxt.value = "onion";
  2434. }
  2435. }
  2436. */
  2437. var eleSugComment = elesComment[i].parentElement
  2438. .parentElement.parentElement.querySelector(".stsh_text_comment font");
  2439. if (eleSugComment && eleSugComment.textContent.trim() ==
  2440. "ATTENTION - English string was updated. This suggestion might be outdated.")
  2441. {
  2442. eleTxt.value = "outdated";
  2443. }
  2444. isFocus = true;
  2445. }
  2446. }
  2447. }
  2448. }
  2449. }
  2450. }
  2451. }
  2452. // Convert time
  2453. {
  2454. var rgxTime = /\d{2}-\d{2}-\d{4}, \d{2}:\d{2} [AP]M/;
  2455. var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
  2456. var eleFriends = document.querySelectorAll(".friend_block_avatar, .friend_block_discussions");
  2457. for (var i = 0; i < eleFriends.length; i++)
  2458. {
  2459. var nodes = [];
  2460. if (eleFriends[i].classList.contains("friend_block_avatar"))
  2461. {
  2462. nodes = eleFriends[i].childNodes;
  2463. }
  2464. else if (eleFriends[i].classList.contains("friend_block_discussions"))
  2465. {
  2466. nodes = eleFriends[i].parentElement.nextElementSibling.childNodes[2].childNodes;
  2467. }
  2468. for (var j = 0; j < nodes.length; j++)
  2469. {
  2470. var nodeVal = nodes[j].nodeValue;
  2471. if (nodeVal)
  2472. {
  2473. var dateTimes = rgxTime.exec(nodeVal);
  2474. if (dateTimes)
  2475. {
  2476. var dateTime = dateTimes[0];
  2477. var month = dateTime.substr(0, 2);
  2478. var day = dateTime.substr(3, 2);
  2479. var year = dateTime.substr(6, 4);
  2480. var hour = dateTime.substr(12, 2);
  2481. var minute = dateTime.substr(15, 2);
  2482. var period = dateTime.substr(18, 2);
  2483. if (period == "AM")
  2484. {
  2485. if (hour == "12")
  2486. {
  2487. hour = "00"
  2488. }
  2489. }
  2490. else if (period == "PM")
  2491. {
  2492. hour = parseInt(hour) + 12;
  2493. if (hour == 24)
  2494. {
  2495. hour = 12;
  2496. }
  2497. }
  2498. var dateTimeStd = year + "-" + month + "-" + day;
  2499. if (isDstUsa(year, month, day, hour))
  2500. {
  2501. dateTimeStd += "T" + hour + ":" + minute + ":00-0700";
  2502. }
  2503. else
  2504. {
  2505. dateTimeStd += "T" + hour + ":" + minute + ":00-0800";
  2506. }
  2507. var dateStd = new Date(dateTimeStd);
  2508. if (dateStd.toLocaleString() != "Invalid Date")
  2509. {
  2510. var gmt = dateStd.getTimezoneOffset() / 60 * -1;
  2511. var gmtStr = " GMT";
  2512. if (gmt > 0)
  2513. {
  2514. gmtStr += "+" + gmt;
  2515. }
  2516. else if (gmt < 0)
  2517. {
  2518. gmtStr += "" + gmt;
  2519. }
  2520. var dateNew = dateStd.getDate()
  2521. + " " + months[dateStd.getMonth()]
  2522. + " " + dateStd.getFullYear()
  2523. + ", " + padZero(dateStd.getHours(), 2)
  2524. + ":" + padZero(dateStd.getMinutes(), 2)
  2525. + gmtStr;
  2526. //console.log("Time: " + dateTimeStd);
  2527. //console.log("Time: " + dateTime + " -> " + dateNew);
  2528. //var dateNew2 = dateStd.toLocaleString() + gmtStr;
  2529. //console.log("Time: " + dateTime + " -> " + dateNew2);
  2530. var nodeValBegin = nodeVal.substr(0, nodeVal.indexOf(dateTime));
  2531. var nodeValEnd = nodeVal.substr(nodeVal.indexOf(dateTime) + dateTime.length);
  2532. nodes[j].nodeValue = nodeValBegin;
  2533. var ele = document.createElement("span");
  2534. ele.classList.add("stsh_time_convert");
  2535. ele.setAttribute("title", dateTime);
  2536. ele.textContent = dateNew;
  2537. insertAfterElement(ele, nodes[j]);
  2538. if (nodeValEnd != "")
  2539. {
  2540. insertAfterElement(document.createTextNode(nodeValEnd), ele);
  2541. }
  2542. }
  2543. else
  2544. {
  2545. console.log("Invalid Date: " + dateTimeStd);
  2546. }
  2547. }
  2548. }
  2549. }
  2550. }
  2551. }
  2552. // Add Steam profile links
  2553. {
  2554. var eleSpans = document.querySelectorAll("span[title='Send this user a private message']");
  2555. for (var i = 0; i < eleSpans.length; i++)
  2556. {
  2557. var href = eleSpans[i].parentElement.firstElementChild.getAttribute("href");
  2558. if (href && href.indexOf("user_activity.php?user=") == 0)
  2559. {
  2560. var profile = href.replace("user_activity.php?user=", "");
  2561. var ele = document.createElement("a");
  2562. ele.classList.add("stsh_steamProfile");
  2563. ele.setAttribute("target", "_blank");
  2564. ele.setAttribute("title", "View Steam profile");
  2565. ele.setAttribute("href", "http://steamcommunity.com/profiles/" + profile);
  2566. ele.textContent = " Steam ";
  2567. insertBeforeElement(ele, eleSpans[i]);
  2568. }
  2569. }
  2570. }
  2571. // Add auto approve
  2572. {
  2573. if (elesInputApprove.length > 0)
  2574. {
  2575. var eleInput = document.createElement("input");
  2576. eleInput.id = "stsh_autoApprove";
  2577. eleInput.setAttribute("type", "checkbox");
  2578. eleInput.setAttribute("value", "auto");
  2579. eleInput.textContent = "";
  2580. var eleLabel = document.createElement("label");
  2581. eleLabel.classList.add("stsh_autoApprove_label");
  2582. eleLabel.classList.add("stsh_unselectable");
  2583. eleLabel.setAttribute("for", "stsh_autoApprove");
  2584. eleLabel.setAttribute("title", "Please use with care!");
  2585. eleLabel.textContent = " Auto Approve Next ";
  2586. elesInputApprove[0].parentElement.appendChild(eleInput);
  2587. elesInputApprove[0].parentElement.appendChild(eleLabel);
  2588. function autoApprove()
  2589. {
  2590. var tm = 2000;
  2591. console.log("AutoApprove: Next in " + tm + "ms");
  2592. setTimeoutCustom(function ()
  2593. {
  2594. var eleCheck = document.querySelector("#stsh_autoApprove");
  2595. if (eleCheck && eleCheck.checked)
  2596. {
  2597. var isClicked = false;
  2598. var ele = document.querySelector(".suggestion_signature input[value~='Next']");
  2599. if (ele && !ele.disabled && isVisible())
  2600. {
  2601. var isOutdated = false;
  2602. var eleSugComment = ele.parentElement
  2603. .parentElement.parentElement.querySelector(".stsh_text_comment font");
  2604. if (eleSugComment && eleSugComment.textContent.trim() ==
  2605. "ATTENTION - English string was updated. This suggestion might be outdated.")
  2606. {
  2607. isOutdated = true;
  2608. }
  2609. if (!isOutdated)
  2610. {
  2611. isClicked = true;
  2612. GM_setValue("timeAutoApproveLast", getUnixTimestamp());
  2613. ele.click();
  2614. }
  2615. }
  2616. if (!isClicked)
  2617. {
  2618. eleCheck.checked = false;
  2619. GM_setValue("isAutoApprove", "false");
  2620. }
  2621. }
  2622. }, tm);
  2623. }
  2624. var tmDiff = getUnixTimestamp() - GM_getValue("timeAutoApproveLast", 0);
  2625. if (tmDiff > 10)
  2626. {
  2627. // > 10s
  2628. eleInput.checked = false;
  2629. GM_setValue("isAutoApprove", "false");
  2630. }
  2631. if (window !== window.parent)
  2632. {
  2633. var eleOuter = window.parent.document.querySelector("#suggestions_box_outer");
  2634. if (eleOuter)
  2635. {
  2636. if (eleOuter.style.display == "none")
  2637. {
  2638. // Closed iFrame
  2639. eleInput.checked = false;
  2640. GM_setValue("isAutoApprove", "false");
  2641. }
  2642. }
  2643. }
  2644. if (GM_getValue("isAutoApprove", 0) == "true")
  2645. {
  2646. eleInput.checked = true;
  2647. autoApprove();
  2648. }
  2649.  
  2650. eleInput.addEventListener("click", function (e)
  2651. {
  2652. var ele = e.target;
  2653. if (ele.checked)
  2654. {
  2655. GM_setValue("isAutoApprove", "true");
  2656. autoApprove();
  2657. }
  2658. else
  2659. {
  2660. GM_setValue("isAutoApprove", "false");
  2661. }
  2662. });
  2663. }
  2664. }
  2665. // Warn when remove
  2666. // Suggest to remove
  2667. {
  2668. var elesRemove = document.querySelectorAll(".suggestion_signature input[value='REMOVE']");
  2669. for (var i = 0; i < elesRemove.length; i++)
  2670. {
  2671. var oldClick = elesRemove[i].getAttribute("onclick");
  2672. if (oldClick && oldClick.indexOf("location.href") == 0)
  2673. {
  2674. var eleSug = elesRemove[i].parentElement.parentElement.parentElement.parentElement;
  2675. if (eleSug.classList.contains("suggestion"))
  2676. {
  2677. /*
  2678. // Typonion
  2679. var eleOnion = eleSug.querySelector(".suggestion_text font[style='color:#01ec00;']");
  2680. if (eleOnion)
  2681. {
  2682. var newClick = "if (!confirm(\"Warning: You will delete your onion. Press Cancel to go back.\")) return false; "
  2683. + oldClick;
  2684. elesRemove[i].setAttribute("onclick", newClick);
  2685. elesRemove[i].setAttribute("title", "Do not remove your onion!");
  2686. elesRemove[i].style.color = "#777";
  2687. elesRemove[i].style.cursor = "not-allowed";
  2688. }
  2689. else
  2690. */
  2691. {
  2692. var eleComment = elesRemove[i].previousElementSibling.previousElementSibling;
  2693. if (eleComment)
  2694. {
  2695. if (eleComment.textContent.trim().indexOf("Comment:") == 0)
  2696. {
  2697. var newClick = "if (!confirm(\"Warning: You should not remove this suggestion. Press OK if you really want.\")) return false; "
  2698. + oldClick;
  2699. elesRemove[i].setAttribute("onclick", newClick);
  2700. elesRemove[i].setAttribute("title", "Your suggestion that has a comment!");
  2701. elesRemove[i].classList.add("stsh_grey");
  2702. elesRemove[i].classList.add("stsh_cursor_notallowed");
  2703. }
  2704. else
  2705. {
  2706. elesRemove[i].setAttribute("title", "Please remove this suggestion to save admin time.");
  2707. elesRemove[i].classList.add("stsh_green");
  2708. elesRemove[i].classList.add("stsh_border_green");
  2709. }
  2710. }
  2711. }
  2712. }
  2713. }
  2714. }
  2715. }
  2716. // Clean language markers that link to Steam
  2717. {
  2718. var rgxLang = /\?l=[a-z]+$/i;
  2719. var elesFriend = document.querySelectorAll(".friend_block_discussions");
  2720. for (var i = 0; i < elesFriend.length; i++)
  2721. {
  2722. var eleDiscuss = elesFriend[i].parentElement.nextElementSibling;
  2723. if (!eleDiscuss.querySelector("font[style='color:#EDB687;']"))
  2724. {
  2725. var elesA = eleDiscuss.querySelectorAll("a[href*='steam']");
  2726. for (var j = 0; j < elesA.length; j++)
  2727. {
  2728. var href = elesA[j].getAttribute("href");
  2729. if (rgxLang.test(href))
  2730. {
  2731. elesA[j].setAttribute("href", href.replace(rgxLang, ""));
  2732. }
  2733. }
  2734. }
  2735. }
  2736. }
  2737. // Auto paste last suggestion
  2738. {
  2739. if (!/edit/i.test(getQueryByName("action")))
  2740. {
  2741. //var eleTextOrg = document.querySelector(".stsh_text_org");
  2742. if (eleTextOrg)
  2743. {
  2744. var textOrg = trimSpace(eleTextOrg.innerHTML).toLowerCase();
  2745. if (textOrg == GM_getValue("textLastOrg", ""))
  2746. {
  2747. var eleTextCur = document.querySelector("#suggestion_value_new");
  2748. if (eleTextCur)
  2749. {
  2750. var textLastCur = GM_getValue("textLastCur", "");
  2751. if (textLastCur != "")
  2752. {
  2753. eleTextCur.value = textLastCur;
  2754. }
  2755. }
  2756. setTimeoutCustom(function()
  2757. {
  2758. var eleTextCur = document.querySelector("#suggestion_value_new");
  2759. if (eleTextCur)
  2760. {
  2761. var textLastCur = GM_getValue("textLastCur", "");
  2762. if (textLastCur != "")
  2763. {
  2764. eleTextCur.value = textLastCur;
  2765. }
  2766. }
  2767. }, 250);
  2768. }
  2769. }
  2770. }
  2771. var elesTextSubmit = document.querySelectorAll(".stsh_text_submit, #stsh_submit_suggestion_next");
  2772. for (var i = 0; i < elesTextSubmit.length; i++)
  2773. {
  2774. elesTextSubmit[i].addEventListener("click", function()
  2775. {
  2776. var eleTextOrg = document.querySelector(".stsh_text_org");
  2777. if (eleTextOrg)
  2778. {
  2779. var textOrg = trimSpace(eleTextOrg.innerHTML);
  2780. if (textOrg.length < 1000)
  2781. {
  2782. var eleTextCur = document.querySelector("#suggestion_value_new");
  2783. if (eleTextCur)
  2784. {
  2785. var textCur = eleTextCur.value;
  2786. GM_setValue("textLastOrg", textOrg.toLowerCase());
  2787. GM_setValue("textLastCur", textCur);
  2788. }
  2789. }
  2790. }
  2791. });
  2792. }
  2793. }
  2794. // Auto store last comment
  2795. {
  2796. //console.log("textLastOrg_Comment: " + GM_getValue("textLastOrg_Comment", ""));
  2797. //console.log("textLastCur_Comment: " + GM_getValue("textLastCur_Comment", ""));
  2798. function storeLastComment(eleTextComment, isRemoved)
  2799. {
  2800. if (eleTextComment)
  2801. {
  2802. var eleTextOrg = document.querySelector(".stsh_text_org");
  2803. if (eleTextOrg)
  2804. {
  2805. var textOrg = trimSpace(eleTextOrg.innerHTML).substr(0, 1000).toLowerCase();
  2806. if (isRemoved)
  2807. {
  2808. if (textOrg == GM_getValue("textLastOrg_Comment", ""))
  2809. {
  2810. // When remove comment, don't store if original text is the same
  2811. return;
  2812. }
  2813. }
  2814. var textCur = trimSpace(eleTextComment.value || eleTextComment.textContent);
  2815. if (textCur !== "outdated")
  2816. {
  2817. GM_setValue("textLastOrg_Comment", textOrg);
  2818. GM_setValue("textLastCur_Comment", textCur);
  2819. }
  2820. }
  2821. }
  2822. }
  2823. var elesTextRemoveComment = document.querySelectorAll(".stsh_text_removeComment");
  2824. for (var i = 0; i < elesTextRemoveComment.length; i++)
  2825. {
  2826. elesTextRemoveComment[i].addEventListener("click", function(ev)
  2827. {
  2828. var target = null;
  2829. if (ev.target.tagName === "FONT")
  2830. {
  2831. target = ev.target.parentElement;
  2832. }
  2833. else
  2834. {
  2835. target = ev.target;
  2836. }
  2837. var eleTextComment = target
  2838. .parentElement.parentElement.parentElement.parentElement
  2839. .querySelector(".stsh_text_comment");
  2840. storeLastComment(eleTextComment, true);
  2841. });
  2842. }
  2843. var elesSubmitComment = document.querySelectorAll(".stsh_submit_comment");
  2844. for (var i = 0; i < elesSubmitComment.length; i++)
  2845. {
  2846. elesSubmitComment[i].addEventListener("click", function(ev)
  2847. {
  2848. var eleTextComment = ev.target.previousElementSibling;
  2849. storeLastComment(eleTextComment, false);
  2850. });
  2851. }
  2852. }
  2853. // Mark showing
  2854. {
  2855. var eleStatus = parent.document.querySelector("#stsh_showing_random");
  2856. if (eleStatus)
  2857. {
  2858. eleStatus.dataset.random = randNum(100000, 999999);
  2859. }
  2860. }
  2861. // Delta
  2862. {
  2863. var eleFile = document.querySelector(".stsh_info_file");
  2864. if (eleFile)
  2865. {
  2866. if (eleFile.textContent.trim() === "steam/delta")
  2867. {
  2868. document.body.classList.add("stsh_delta");
  2869. }
  2870. }
  2871. }
  2872. // Clean link remove my comment
  2873. {
  2874. var elesRemoveMyComment = document.querySelectorAll(".suggestion_signature .lbAction[name^='myFrm'] a[onclick*='.submit()']");
  2875. for (var i = 0; i < elesRemoveMyComment.length; i++)
  2876. {
  2877. elesRemoveMyComment[i].removeAttribute("href");
  2878. elesRemoveMyComment[i].classList.add("stsh_text_removeMyComment");
  2879. }
  2880. }
  2881. // Hide cursor when typing
  2882. // Expand textarea when typing
  2883. {
  2884. var tmTextChange = 0;
  2885. function autoHideCursor(ele)
  2886. {
  2887. if (ele)
  2888. {
  2889. ele.addEventListener("input", function(ev)
  2890. {
  2891. var ele = ev.target;
  2892. ele.style.setProperty("cursor", "none", "important");
  2893. clearTimeout(tmTextChange);
  2894. tmTextChange = setTimeoutCustom(function(ele)
  2895. {
  2896. ele.style.setProperty("cursor", "auto", "important");
  2897. }, 3000, ele);
  2898. });
  2899. ele.addEventListener("mousemove", function(ev)
  2900. {
  2901. var ele = ev.target;
  2902. clearTimeout(tmTextChange);
  2903. ele.style.setProperty("cursor", "auto", "important");
  2904. });
  2905. }
  2906. }
  2907. function autoExpandEvent(ev)
  2908. {
  2909. var ele = ev.target;
  2910. var maxHeight = ele.param_MaxHeight;
  2911. var styleHeight = parseInt(ele.style.height)
  2912. || parseInt(window.getComputedStyle(ele).height)
  2913. || maxHeight;
  2914. var heightDiff = ele.scrollHeight - styleHeight;
  2915. //console.log("ele.scrollHeight:"+ele.scrollHeight+", styleHeight:"+styleHeight+", heightDiff:"+heightDiff);
  2916. // When press a button
  2917. // Chrome: heightDiff == 4
  2918. // Firefox: heightDiff == 0
  2919. if ((heightDiff > 4 || (heightDiff > 0 && heightDiff < 4))&& ele.scrollHeight < maxHeight)
  2920. {
  2921. ele.style.height = (ele.scrollHeight + 2) + "px";
  2922. }
  2923. else if (ele.scrollHeight > maxHeight)
  2924. {
  2925. ele.style.height = maxHeight + "px";
  2926. }
  2927. }
  2928. function autoExpandTextarea(ele, maxHeight)
  2929. {
  2930. if (ele)
  2931. {
  2932. ele.param_MaxHeight = maxHeight;
  2933. ele.addEventListener("input", autoExpandEvent);
  2934. ele.addEventListener("keyup", autoExpandEvent);
  2935. }
  2936. }
  2937. var elesTextarea = document.querySelectorAll("textarea");
  2938. for (var i = 0; i < elesTextarea.length; i++)
  2939. {
  2940. autoExpandTextarea(elesTextarea[i], 500);
  2941. autoHideCursor(elesTextarea[i]);
  2942. }
  2943. }
  2944. // Focus on mod action
  2945. {
  2946. var elesEdit = document.querySelectorAll("input[value='Edit']");
  2947. if (elesEdit.length > 2)
  2948. {
  2949. setTimeoutCustom(function()
  2950. {
  2951. if (/reconsider|approve|decline/.test(getQueryByName("action")))
  2952. {
  2953. scrollToElement(".suggestions_list", -200);
  2954. }
  2955. }, 200);
  2956. }
  2957. }
  2958. } // End suggestions.php
  2959.  
  2960. if (url.indexOf("translate.php") > -1)
  2961. {
  2962. var searchText = getQueryByName("search_input");
  2963. if (searchText != "")
  2964. {
  2965. document.title = searchText + " - " + document.title;
  2966. }
  2967. else
  2968. {
  2969. var fileID = getQueryByName("file_ID");
  2970. if (fileID != "")
  2971. {
  2972. var eleFile = document.querySelector("#leftAreaContainer label[for='chosenfile']");
  2973. if (eleFile)
  2974. {
  2975. var file = eleFile.textContent.trim();
  2976. if (file.indexOf("Limit search results to CURRENT FILE: ") == 0)
  2977. {
  2978. file = file.replace("Limit search results to CURRENT FILE: ", "");
  2979. var fileNew = file.split("#").reverse().join(" # ").trim();
  2980. document.title = fileNew + " - " + document.title;
  2981. }
  2982. }
  2983. }
  2984. else
  2985. {
  2986. var eleInput = document.querySelector("#search_input");
  2987. if (eleInput)
  2988. {
  2989. var valInput = eleInput.value.trim();
  2990. if (valInput.indexOf("SUGGESTIONS FROM: ") == 0)
  2991. {
  2992. document.title = valInput.replace("SUGGESTIONS FROM: ", "") + " - " + document.title;
  2993. }
  2994. }
  2995. }
  2996. }
  2997. var outer = document.getElementById("suggestions_box_outer");
  2998. if (outer)
  2999. {
  3000. outer.setAttribute("onclick","hideSuggestionsBox();");
  3001. }
  3002. var divBtn = document.createElement("div");
  3003. document.body.appendChild(divBtn);
  3004. divBtn.innerHTML = ' \
  3005. <div class="stsh_showing_group"> \
  3006. <span class="stsh_showing_header">Hide</span>\
  3007. <br/> &nbsp; <input id="stsh_showing_keyApp" value="App" class="stsh_btn_short" type="button" /> \
  3008. <input id="stsh_showing_keyGame" value="Game" class="stsh_btn_short" type="button" /> \
  3009. <br/> &nbsp; <input id="stsh_showing_keyFaq" value="FAQ" class="stsh_btn_short" type="button" /> \
  3010. <input id="stsh_showing_keySupport" value="Support" class="stsh_btn_short" type="button" /> \
  3011. <br/> &nbsp; <input id="stsh_showing_keyPromo" value="Promo" class="stsh_btn_short" type="button" /> \
  3012. <input id="stsh_showing_keyEmail" value="Email" class="stsh_btn_short" type="button" /> \
  3013. <br/> \
  3014. <br/> &nbsp; <input id="stsh_showing_strNotMatch" value="Hide not similar" class="stsh_btn_long" type="button" /> \
  3015. <br/> &nbsp; <input id="stsh_showing_strLong" value="Hide very long" class="stsh_btn_long" type="button" /> \
  3016. \
  3017. <br/> &nbsp; <span class="stsh_showing_header">Hide Suggestions</span>\
  3018. <br/> &nbsp; <input id="stsh_showing_notTranslated" value="Not Translated (0)" class="stsh_btn_long" type="button" /> \
  3019. <br/> &nbsp; <input id="stsh_showing_suggested" value="Suggested (0)" class="stsh_btn_long" type="button" /> \
  3020. <br/> &nbsp; <input id="stsh_showing_resuggested" value="Resuggested (0)" class="stsh_btn_long" type="button" /> \
  3021. <br/> &nbsp; <input id="stsh_showing_approved" value="Approved (0)" class="stsh_btn_long" type="button" /> \
  3022. <br/> &nbsp; <input id="stsh_showing_declined" value="Declined (0)" class="stsh_btn_long" type="button" /> \
  3023. <br/> &nbsp; <input id="stsh_showing_translated" value="Translated (0)" class="stsh_btn_long" type="button" /> \
  3024. \
  3025. <br/> &nbsp; <span class="stsh_showing_header">Sort by</span>\
  3026. <br/> &nbsp; <input id="stsh_sort_key" value="Key" class="stsh_btn_short" type="button" /> \
  3027. <input id="stsh_sort_string" value="String" class="stsh_btn_short" type="button" /> \
  3028. <br/> &nbsp; <input id="stsh_sort_word" value="Word" class="stsh_btn_short" type="button" /> \
  3029. <input id="stsh_sort_length" value="Length" class="stsh_btn_short" type="button" /> \
  3030. <br/> \
  3031. <br/> &nbsp; <input id="stsh_showing_refresh" value="Refresh" class="stsh_btn" type="button" onclick="hideSuggestionsBox(); return false;" /> \
  3032. <br/> &nbsp; <input id="stsh_showing_all" value="Show All" class="stsh_btn" type="button" /> \
  3033. </div> \
  3034. <div id="stsh_showing_current"></div> \
  3035. <div id="stsh_showing"></div> \
  3036. ';
  3037.  
  3038. // Count showing
  3039. function countShowing()
  3040. {
  3041. var trKeys = document.querySelectorAll("#keylist > table:nth-child(1) > tbody:nth-child(1) > tr");
  3042. var countAll = document.querySelectorAll("#keylist .copysmall").length;
  3043. var countShow = 0;
  3044. var countSuggest = 0;
  3045. var countResuggest = 0;
  3046. var countApprove = 0;
  3047. var countDecline = 0;
  3048. var countNotTranslated = 0;
  3049. var countTranslated = 0;
  3050. var txtApprove = "ready for Admin";
  3051. var txtDecline = "ready for removal";
  3052. var txtSuggest = "suggestion";
  3053. for (var i = 0; i < trKeys.length; i++)
  3054. {
  3055. if (!trKeys[i].classList.contains("stsh_hidden"))
  3056. {
  3057. var eleCounter = trKeys[i].querySelector("tr.copysmall > td:nth-child(3)");
  3058. if (eleCounter)
  3059. {
  3060. countShow++;
  3061. var txtCounter = eleCounter.textContent.trim();
  3062. if (txtCounter.indexOf(txtApprove) > -1)
  3063. {
  3064. countApprove++;
  3065. }
  3066. else if (txtCounter.indexOf(txtDecline) > -1)
  3067. {
  3068. countDecline++;
  3069. }
  3070. else if (txtCounter.indexOf(txtSuggest) > -1)
  3071. {
  3072. var eleNotTranslated = trKeys[i].querySelector("span.token_nottranslated");
  3073. if (eleNotTranslated)
  3074. {
  3075. countSuggest++;
  3076. }
  3077. else
  3078. {
  3079. countResuggest++;
  3080. }
  3081. }
  3082. else
  3083. {
  3084. var eleNotTranslated = trKeys[i].querySelector("span.token_nottranslated");
  3085. if (eleNotTranslated)
  3086. {
  3087. countNotTranslated++;
  3088. }
  3089. else
  3090. {
  3091. countTranslated++;
  3092. }
  3093. }
  3094. }
  3095. else
  3096. {
  3097. var eleTd = trKeys[i].querySelector("td");
  3098. if (eleTd)
  3099. {
  3100. if (eleTd.textContent.trim() == "")
  3101. {
  3102. trKeys[i].parentElement.removeChild(trKeys[i]);
  3103. }
  3104. }
  3105. }
  3106. }
  3107. }
  3108. var eleShowing = document.getElementById("stsh_showing");
  3109. if (eleShowing)
  3110. {
  3111. var newHtml = "Showing: <span class=\"stsh_showing_counter\">" + countShow + " of " + countAll + "</span>"
  3112. + "<!-- " + countNotTranslated + ", " + countSuggest + ", " + countResuggest
  3113. + ", " + countApprove + ", " + countDecline + ", " + countTranslated + " -->";
  3114. if (eleShowing.innerHTML != newHtml)
  3115. {
  3116. eleShowing.innerHTML = newHtml;
  3117.  
  3118. var elesBtnShowing = document.querySelectorAll("#stsh_showing_notTranslated, #stsh_showing_suggested, #stsh_showing_resuggested"
  3119. + ", #stsh_showing_approved, #stsh_showing_declined, #stsh_showing_translated");
  3120. if (elesBtnShowing.length == 6)
  3121. {
  3122. var counterArr = [countNotTranslated, countSuggest, countResuggest, countApprove, countDecline, countTranslated ];
  3123. var counterTextArr = ["Not Translated", "Suggested", "Resuggested"
  3124. , "Approved", "Declined", "Translated" ];
  3125.  
  3126. for (var i = 0; i < elesBtnShowing.length; i++)
  3127. {
  3128. elesBtnShowing[i].value = counterTextArr[i] + " ("+ counterArr[i] +")" ;
  3129. };
  3130. }
  3131. }
  3132. }
  3133. var eleShowingCur = document.getElementById("stsh_showing_current");
  3134. if (eleShowingCur)
  3135. {
  3136. var eleOuter = document.getElementById("suggestions_box_outer");
  3137. if (eleOuter)
  3138. {
  3139. if (eleOuter.style.display != "none")
  3140. {
  3141. if (eleShowingCur.style.display != "initial")
  3142. eleShowingCur.style.display = "initial";
  3143. var eleIframe = document.getElementById("suggestions_iframe");
  3144. if (eleIframe)
  3145. {
  3146. var iUrl = eleIframe.contentWindow.location.href;
  3147. var listId = parseInt(getQueryByName("list_id", iUrl)) || 0;
  3148. listId += 1;
  3149. var newHtml = "Current: <span class=\"stsh_showing_counter\">" + listId + " of " + countShow + "</span>";
  3150. if (eleShowingCur.innerHTML != newHtml)
  3151. {
  3152. eleShowingCur.innerHTML = newHtml;
  3153. }
  3154. }
  3155. }
  3156. else
  3157. {
  3158. if (eleShowingCur.style.display != "none")
  3159. {
  3160. eleShowingCur.style.display = "none";
  3161. eleShowingCur.innerHTML = "";
  3162. }
  3163. }
  3164. }
  3165. }
  3166. }
  3167. countShowing();
  3168. var obTargetCount = document.getElementById("keylist_container");
  3169. if (obTargetCount)
  3170. {
  3171. var tmObCount = -1;
  3172. var obMuCount = new MutationObserver(function(mutations)
  3173. {
  3174. mutations.forEach(function(mutation)
  3175. {
  3176. if (mutation.type !== "attributes"
  3177. || mutation.target.tagName === "TR")
  3178. {
  3179. clearTimeout(tmObCount);
  3180. tmObCount = setTimeoutCustom(function(mutation)
  3181. {
  3182. countShowing();
  3183. //console.log("countShowing: " + tmObCount);
  3184. }, 50, mutation);
  3185. }
  3186. });
  3187. });
  3188. var obConfigCount = { childList: true, subtree: true, attributes: true, attributeFilter: ["class"] };
  3189. obMuCount.observe(obTargetCount, obConfigCount);
  3190. }
  3191. {
  3192. var obMuCountRand = new MutationObserver(function(mutations)
  3193. {
  3194. mutations.forEach(function(mutation)
  3195. {
  3196. countShowing();
  3197. });
  3198. });
  3199. var eleCountRand = document.createElement("div");
  3200. eleCountRand.id = "stsh_showing_random";
  3201. eleCountRand.dataset.random = "0";
  3202. document.body.appendChild(eleCountRand);
  3203.  
  3204. var obConfigCountRand = { attributes: true, attributeFilter: ["data-random"] };
  3205. obMuCountRand.observe(eleCountRand, obConfigCountRand);
  3206. }
  3207. // End Count showing
  3208.  
  3209. // Line Counter
  3210. function addLineCounter()
  3211. {
  3212. var elesCounter = document.querySelectorAll(".stsh_lineCounter");
  3213. if (elesCounter.length > 0)
  3214. {
  3215. var j = 1;
  3216. for (var i = 0; i < elesCounter.length; i++)
  3217. {
  3218. if (!elesCounter[i].parentElement.parentElement.parentElement
  3219. .parentElement.classList.contains("stsh_hidden"))
  3220. {
  3221. if (elesCounter[i].textContent.trim() != j)
  3222. {
  3223. elesCounter[i].textContent = j;
  3224. }
  3225. j++;
  3226. }
  3227. }
  3228. }
  3229. else
  3230. {
  3231. var elesDiv = document.querySelectorAll("#keylist td:nth-child(1) > div");
  3232. for (var i = 0; i < elesDiv.length; i++)
  3233. {
  3234. var eleNew = document.createElement("span");
  3235. eleNew.classList.add("stsh_lineCounter_outer");
  3236. eleNew.innerHTML =
  3237. ' <span class="stsh_lineCounter"> '
  3238. + (i + 1)
  3239. + ' </span> ';
  3240. elesDiv[i].appendChild(eleNew);
  3241. }
  3242. }
  3243. }
  3244. addLineCounter();
  3245. var obTargetLine = document.getElementById("keylist_container");
  3246. if (obTargetLine)
  3247. {
  3248. var tmObLine = -1;
  3249. var obMuLine = new MutationObserver(function(mutations)
  3250. {
  3251. mutations.forEach(function(mutation)
  3252. {
  3253. if (mutation.type !== "attributes"
  3254. || mutation.target.tagName === "TR")
  3255. {
  3256. clearTimeout(tmObLine);
  3257. tmObLine = setTimeoutCustom(function(mutation)
  3258. {
  3259. addLineCounter();
  3260. //console.log("addLineCounter: " + tmObLine);
  3261. }, 50, mutation);
  3262. }
  3263. });
  3264. });
  3265. var obConfigLine = { childList: true, subtree: true, attributes: true, attributeFilter: ["class"] };
  3266. obMuLine.observe(obTargetLine, obConfigLine);
  3267. }
  3268. // End Line Counter
  3269. // Hide & sort suggestions
  3270. {
  3271. function hideSuggestions(mode)
  3272. {
  3273. // mode: 0-5 (0: "Not Translated", 1: "Suggested", 2: "Resuggested", 3: "Approved", 4: "Declined", 5: "Translated")
  3274.  
  3275. if (!isVisible()) return;
  3276. if (mode < 0 || mode > 5) return;
  3277.  
  3278. var display = "none";
  3279. var txtApprove = "ready for Admin";
  3280. var txtDecline = "ready for removal";
  3281. var txtSuggest = "suggestion";
  3282. var trKeys = document.querySelectorAll("#keylist > table:nth-child(1) > tbody:nth-child(1) > tr");
  3283. for (var i = 0; i < trKeys.length; i++)
  3284. {
  3285. if (!trKeys[i].classList.contains("stsh_hidden"))
  3286. {
  3287. var curMode = -1;
  3288.  
  3289. var eleCounter = trKeys[i].querySelector("tr.copysmall > td:nth-child(3)");
  3290. if (eleCounter)
  3291. {
  3292.  
  3293. var txtCounter = eleCounter.textContent.trim();
  3294. if (txtCounter.indexOf(txtApprove) > -1)
  3295. {
  3296. curMode = 3; // Approved
  3297. }
  3298. else if (txtCounter.indexOf(txtDecline) > -1)
  3299. {
  3300. curMode = 4; // Declined
  3301. }
  3302. else if (txtCounter.indexOf(txtSuggest) > -1)
  3303. {
  3304. var eleNotTranslated = trKeys[i].querySelector("span.token_nottranslated");
  3305. if (eleNotTranslated)
  3306. {
  3307. curMode = 1; // Suggested
  3308. }
  3309. else
  3310. {
  3311. curMode = 2; // Resuggested
  3312. }
  3313. }
  3314. else
  3315. {
  3316. var eleNotTranslated = trKeys[i].querySelector("span.token_nottranslated");
  3317. if (eleNotTranslated)
  3318. {
  3319. curMode = 0; // Not Translated
  3320. }
  3321. else
  3322. {
  3323. curMode = 5; // Translated
  3324. }
  3325. }
  3326. }
  3327.  
  3328. if (curMode == mode)
  3329. {
  3330. trKeys[i].classList.add("stsh_hidden");
  3331. }
  3332. }
  3333. }
  3334. }
  3335. function sortKey(mode)
  3336. {
  3337. /*
  3338. mode:
  3339. 0: key
  3340. 1: string
  3341. 2: word
  3342. 3: length
  3343. */
  3344. if (!isVisible()) return;
  3345. var keyArr = new Array();
  3346. var valArr = new Array();
  3347. var dot = "...";
  3348. var dotLengthMinus = 0 - dot.length;
  3349. var strNotTranslated = "NOT TRANSLATED";
  3350. var strTr = "";
  3351. 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)");
  3352. for (var i = 0; i < eleKeys.length; i++)
  3353. {
  3354. try
  3355. {
  3356. /*
  3357. key:
  3358. tr: is translated
  3359. sg: is suggested
  3360. dt: has dot
  3361. sb: spacebar count
  3362. sc: special char count
  3363. sp: has special char
  3364. ln: length
  3365. lt: length translated
  3366. st: spacebar count translated
  3367. */
  3368. var dot = "...";
  3369. var dotLengthMinus = 0 - dot.length;
  3370. var isDot = false;
  3371. var isSuggested = false;
  3372. var isTranslated = false;
  3373. var key = eleKeys[i].textContent.trim() + " ";
  3374. var str = "";
  3375. if (mode !== 0)
  3376. {
  3377. str = eleKeys[i].parentElement.nextSibling.nextSibling.firstElementChild.textContent.trim();
  3378. isDot = (str.substr(dotLengthMinus) === dot);
  3379. isSuggested = (eleKeys[i].nextElementSibling.nextElementSibling.textContent.trim() !== "");
  3380. strTr = eleKeys[i].parentElement.nextElementSibling.lastElementChild.textContent.trim();
  3381. isTranslated = (strTr !== strNotTranslated);
  3382. }
  3383. if (mode === 0)
  3384. {
  3385. // mode: key
  3386. if (key.indexOf("GLOSSARY") === 0)
  3387. {
  3388. key = "0" + key;
  3389. }
  3390. }
  3391. if (mode === 1)
  3392. {
  3393. // mode: string
  3394. key = (isTranslated ? "tr00_ " : "tr99_ ") + strTr + (isSuggested ? " _sg00" : " _sg99") + " ___ " + key;
  3395. key = str + " ___ " + key;
  3396. }
  3397. else if (mode === 2)
  3398. {
  3399. // mode: word
  3400. key = (isTranslated ? "tr00_" : "tr99_") + "st" + padZero(strTr.split(" ").length, 2) + "_"
  3401. + "lt" + padZero(strTr.length, 3) + " "
  3402. + strTr + (isSuggested ? " _sg00" : " _sg99") + " ___ " + key;
  3403. key = (isDot ? "dt99_" : "dt00_")
  3404. + "sb" + padZero(str.split(" ").length, 2) + "_sc" + padZero(str.split(/[^a-z0-9 ]/i).length, 2)
  3405. + " ___ " + str + " ___ " + key;
  3406. }
  3407. else if (mode === 3)
  3408. {
  3409. // length
  3410. key = (isTranslated ? "tr00_" : "tr99_") + "lt" + padZero(strTr.length, 3) + " "
  3411. + strTr + (isSuggested ? " _sg00" : " _sg99") + " ___ " + key;
  3412. key = (isDot ? "dt99_" : "dt00_")
  3413. + "sp" + (str.split(/[^a-z0-9]/i).length > 1 ? "99_" : "00_")
  3414. + "ln" + padZero(str.length, 3)
  3415. + " ___ " + str + " ___ " + key;
  3416. }
  3417. key = key.toLowerCase();
  3418. keyArr.push(key);
  3419. var eleParent = eleKeys[i].parentElement.parentElement.parentElement
  3420. .parentElement.parentElement.parentElement;
  3421. //eleParent.dataset.stshKey = key;
  3422. //console.log("Key: " + key);
  3423. valArr[key] = eleParent.outerHTML.trim();
  3424. }
  3425. catch (ex)
  3426. {
  3427. console.error("sortKey", ex.message);
  3428. }
  3429. }
  3430. var keyArrTmp = keyArr.slice();
  3431. keyArr.sort();
  3432. var isSame = true;
  3433. for (var i = 0; i < keyArr.length; i++)
  3434. {
  3435. if (keyArr[i] != keyArrTmp[i])
  3436. {
  3437. isSame = false;
  3438. }
  3439. }
  3440. if (!isSame)
  3441. {
  3442. var eleTable = document.querySelector("#keylist > table:nth-child(1) > tbody:nth-child(1)");
  3443. if (eleTable)
  3444. {
  3445. var newInner = "";
  3446. for (var i = 0; i < keyArr.length; i++)
  3447. {
  3448. newInner += valArr[keyArr[i]];
  3449. }
  3450. eleTable.innerHTML = newInner;
  3451. }
  3452. }
  3453. }
  3454.  
  3455. var itvTime = 300;
  3456. var itvIdHider = [0, 0, 0, 0, 0, 0];
  3457. var itvIdSortKey = 0;
  3458. var itvIdHideKeyApp = 0;
  3459. var itvIdHideKeyGame = 0;
  3460. var itvIdHideKeyFaq = 0;
  3461. var itvIdHideKeySupport = 0;
  3462. var itvIdHideKeyPromo = 0;
  3463. var itvIdHideKeyEmail = 0;
  3464. var itvIdHideStrNotMatch = 0;
  3465. var itvIdHideStrLong = 0;
  3466.  
  3467. var eleBtnShowAll = document.querySelector("#stsh_showing_all");
  3468. if (eleBtnShowAll)
  3469. {
  3470. eleBtnShowAll.addEventListener("click", function()
  3471. {
  3472. var elesBtnShowing = document.querySelectorAll("#stsh_showing_notTranslated, #stsh_showing_suggested"
  3473. + ", #stsh_showing_resuggested, #stsh_showing_approved"
  3474. + ", #stsh_showing_declined, #stsh_showing_translated");
  3475. for (var i = 0; i < elesBtnShowing.length; i++)
  3476. {
  3477. clearInterval(itvIdHider[i]);
  3478. clearInterval(itvIdHideKeyApp);
  3479. clearInterval(itvIdHideKeyGame);
  3480. clearInterval(itvIdHideKeyFaq);
  3481. clearInterval(itvIdHideKeySupport);
  3482. clearInterval(itvIdHideKeyPromo);
  3483. clearInterval(itvIdHideKeyEmail);
  3484. clearInterval(itvIdHideStrNotMatch);
  3485. clearInterval(itvIdHideStrLong);
  3486. setVisibleKey("", true);
  3487. elesBtnShowing[i].removeAttribute("disabled");
  3488. }
  3489. clearInterval(itvIdSortKey);
  3490. countShowing();
  3491. });
  3492. }
  3493.  
  3494. var elesBtnShowing = document.querySelectorAll("#stsh_showing_notTranslated, #stsh_showing_suggested, #stsh_showing_resuggested"
  3495. + ", #stsh_showing_approved, #stsh_showing_declined, #stsh_showing_translated");
  3496. for (var i = 0; i < elesBtnShowing.length; i++)
  3497. {
  3498. elesBtnShowing[i].param = i;
  3499. elesBtnShowing[i].addEventListener("click", function(ev)
  3500. {
  3501. var mode = ev.target.param;
  3502.  
  3503. clearInterval(itvIdHider[mode]);
  3504. itvIdHider[mode] = setIntervalCustom(function(mode)
  3505. {
  3506. hideSuggestions(mode);
  3507. }, itvTime, mode);
  3508.  
  3509. hideSuggestions(mode);
  3510. elesBtnShowing[mode].setAttribute("disabled", "disabled");
  3511. });
  3512. }
  3513.  
  3514. var elesBtnSort = document.querySelectorAll("#stsh_sort_key, #stsh_sort_string"
  3515. + ", #stsh_sort_word, #stsh_sort_length");
  3516. for (var i = 0; i < elesBtnSort.length; i++)
  3517. {
  3518. elesBtnSort[i].param = i;
  3519. elesBtnSort[i].addEventListener("click", function(ev)
  3520. {
  3521. var mode = ev.target.param;
  3522.  
  3523. clearInterval(itvIdSortKey);
  3524. itvIdSortKey = setIntervalCustom(function(mode)
  3525. {
  3526. sortKey(mode);
  3527. }, itvTime, mode);
  3528.  
  3529. sortKey(mode);
  3530. });
  3531. }
  3532.  
  3533. function setVisibleKey(startKey, visible)
  3534. {
  3535. if (!isVisible()) return;
  3536. startKey = startKey.toLowerCase();
  3537. var display = visible != true ? "none" : "";
  3538. 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)");
  3539. for (var i = 0; i < eleKeys.length; i++)
  3540. {
  3541. try
  3542. {
  3543. if (eleKeys[i].textContent.trim().toLowerCase().indexOf(startKey) > -1)
  3544. {
  3545. var eleTarget = eleKeys[i].parentElement.parentElement.parentElement.parentElement.parentElement.parentElement;
  3546. if (visible && eleTarget.classList.contains("stsh_hidden"))
  3547. {
  3548. eleTarget.classList.remove("stsh_hidden");
  3549. }
  3550. else if (!visible && !eleTarget.classList.contains("stsh_hidden"))
  3551. {
  3552. eleTarget.classList.add("stsh_hidden");
  3553. }
  3554. }
  3555. }
  3556. catch (ex)
  3557. {
  3558. console.error("setVisibleKey", ex.message);
  3559. }
  3560. }
  3561. }
  3562.  
  3563. function hideKeyGame()
  3564. {
  3565. setVisibleKey("GAMES/", false);
  3566. setVisibleKey("TF_", false);
  3567. }
  3568.  
  3569. function hideKeyApp()
  3570. {
  3571. setVisibleKey("# storefront_english_apps.txt #", false);
  3572. setVisibleKey("# storefront_english_main.txt # #app_", false);
  3573. setVisibleKey("# community_english.txt # SharedFiles_App_", false);
  3574. setVisibleKey("# appmgmt_english.txt #", false);
  3575. setVisibleKey("STEAM/VR", false);
  3576. }
  3577.  
  3578. function hideKeyFaq()
  3579. {
  3580. setVisibleKey("# support_faq_english.txt #", false);
  3581. }
  3582.  
  3583. function hideKeySupport()
  3584. {
  3585. setVisibleKey("# supportui_english.txt #", false);
  3586. setVisibleKey("# help_english.txt #", false);
  3587. }
  3588.  
  3589. function hideKeyPromo()
  3590. {
  3591. setVisibleKey("#promo", false);
  3592. setVisibleKey("#hardware", false);
  3593. setVisibleKey("ControllerBinding", false);
  3594. setVisibleKey("Library_Controller", false);
  3595. }
  3596.  
  3597. function hideKeyEmail()
  3598. {
  3599. setVisibleKey("#email", false);
  3600. }
  3601. function hideKeyAppInterval()
  3602. {
  3603. clearInterval(itvIdHideKeyApp);
  3604. itvIdHideKeyApp = setIntervalCustom(hideKeyApp, itvTime);
  3605. }
  3606. function hideKeyGameInterval()
  3607. {
  3608. clearInterval(itvIdHideKeyGame);
  3609. itvIdHideKeyGame = setIntervalCustom(hideKeyGame, itvTime);
  3610. }
  3611. function hideKeyFaqInterval()
  3612. {
  3613. clearInterval(itvIdHideKeyFaq);
  3614. itvIdHideKeyFaq = setIntervalCustom(hideKeyFaq, itvTime);
  3615. }
  3616. function hideKeySupportInterval()
  3617. {
  3618. clearInterval(itvIdHideKeySupport);
  3619. itvIdHideKeySupport = setIntervalCustom(hideKeySupport, itvTime);
  3620. }
  3621. function hideKeyPromoInterval()
  3622. {
  3623. clearInterval(itvIdHideKeyPromo);
  3624. itvIdHideKeyPromo = setIntervalCustom(hideKeyPromo, itvTime);
  3625. }
  3626. function hideKeyEmailInterval()
  3627. {
  3628. clearInterval(itvIdHideKeyEmail);
  3629. itvIdHideKeyEmail = setIntervalCustom(hideKeyEmail, itvTime);
  3630. }
  3631. function hideStrNotMatch()
  3632. {
  3633. if (!isVisible()) return;
  3634. var searchStr = decodeURIComponent(getQueryByName("search_input")).replace(/\\+/g," ").trim();
  3635. searchStr = searchStr.toLowerCase();
  3636. 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)");
  3637. for (var i = 0; i < eleStrs.length; i++)
  3638. {
  3639. try
  3640. {
  3641. var valStr = eleStrs[i].children[0].textContent.trim().toLowerCase();
  3642. var valTrn = eleStrs[i].children[2].textContent.trim().toLowerCase();
  3643. if (valStr != searchStr && valTrn != searchStr)
  3644. {
  3645. var eleTarget = eleStrs[i].parentElement.parentElement.parentElement.parentElement.parentElement;
  3646. if (!eleTarget.classList.contains("stsh_hidden"))
  3647. {
  3648. eleTarget.classList.add("stsh_hidden");
  3649. }
  3650. }
  3651. }
  3652. catch (ex)
  3653. {
  3654. console.error("hideStrNotMatch", ex.message);
  3655. }
  3656. }
  3657. }
  3658. function hideStrNotMatchInterval()
  3659. {
  3660. clearInterval(itvIdHideStrNotMatch);
  3661. itvIdHideStrNotMatch = setIntervalCustom(hideStrNotMatch, itvTime);
  3662. }
  3663. function hideStrLong()
  3664. {
  3665. if (!isVisible()) return;
  3666. var dot = "...";
  3667. var dotLengthMinus = 0 - dot.length;
  3668. 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)");
  3669. for (var i = 0; i < eleStrs.length; i++)
  3670. {
  3671. try
  3672. {
  3673. var valStr = eleStrs[i].textContent.trim();
  3674. if (valStr.substr(dotLengthMinus) == dot)
  3675. {
  3676. var eleTarget = eleStrs[i].parentElement.parentElement.parentElement.parentElement.parentElement.parentElement;
  3677. if (!eleTarget.classList.contains("stsh_hidden"))
  3678. {
  3679. eleTarget.classList.add("stsh_hidden");
  3680. }
  3681. }
  3682. }
  3683. catch (ex)
  3684. {
  3685. console.error("hideStrLong", ex.message);
  3686. }
  3687. }
  3688. }
  3689. function hideStrLongInterval()
  3690. {
  3691. clearInterval(itvIdHideStrLong);
  3692. itvIdHideStrLong = setIntervalCustom(hideStrLong, itvTime);
  3693. }
  3694.  
  3695. var eleBtnHideKeyApp = document.querySelector("#stsh_showing_keyApp");
  3696. if (eleBtnHideKeyApp)
  3697. {
  3698. eleBtnHideKeyApp.addEventListener("click", hideKeyAppInterval);
  3699. }
  3700.  
  3701. var eleBtnHideKeyGame = document.querySelector("#stsh_showing_keyGame");
  3702. if (eleBtnHideKeyGame)
  3703. {
  3704. eleBtnHideKeyGame.addEventListener("click", hideKeyGameInterval);
  3705. }
  3706.  
  3707. var eleBtnHideKeyFaq = document.querySelector("#stsh_showing_keyFaq");
  3708. if (eleBtnHideKeyFaq)
  3709. {
  3710. eleBtnHideKeyFaq.addEventListener("click", hideKeyFaqInterval);
  3711. }
  3712.  
  3713. var eleBtnHideKeySupport = document.querySelector("#stsh_showing_keySupport");
  3714. if (eleBtnHideKeySupport)
  3715. {
  3716. eleBtnHideKeySupport.addEventListener("click", hideKeySupportInterval);
  3717. }
  3718.  
  3719. var eleBtnHideKeyPromo = document.querySelector("#stsh_showing_keyPromo");
  3720. if (eleBtnHideKeyPromo)
  3721. {
  3722. eleBtnHideKeyPromo.addEventListener("click", hideKeyPromoInterval);
  3723. }
  3724.  
  3725. var eleBtnHideKeyEmail = document.querySelector("#stsh_showing_keyEmail");
  3726. if (eleBtnHideKeyEmail)
  3727. {
  3728. eleBtnHideKeyEmail.addEventListener("click", hideKeyEmailInterval);
  3729. }
  3730.  
  3731. var eleBtnHideStrNotMatch = document.querySelector("#stsh_showing_strNotMatch");
  3732. if (eleBtnHideStrNotMatch)
  3733. {
  3734. eleBtnHideStrNotMatch.addEventListener("click", hideStrNotMatchInterval);
  3735. }
  3736.  
  3737. var eleBtnHideStrLong = document.querySelector("#stsh_showing_strLong");
  3738. if (eleBtnHideStrLong)
  3739. {
  3740. eleBtnHideStrLong.addEventListener("click", hideStrLongInterval);
  3741. }
  3742.  
  3743. } // End Hide & sort suggestions
  3744.  
  3745. resizeSuggestionBox();
  3746. // Add Frame button when iframe load failed
  3747. {
  3748. var ifrm = document.querySelector("#suggestions_iframe");
  3749. if (ifrm)
  3750. {
  3751. var obIfrm = new MutationObserver(function(mutations)
  3752. {
  3753. mutations.forEach(function(mutation)
  3754. {
  3755. var divFrame = document.querySelector("#stsh_frame");
  3756. if (!divFrame)
  3757. {
  3758. var divOuter = document.querySelector("#suggestions_box_outer");
  3759. if (divOuter)
  3760. {
  3761. divFrame = document.createElement("div");
  3762. divFrame.id = "stsh_frame";
  3763. divOuter.appendChild(divFrame);
  3764. }
  3765. }
  3766. if (divFrame)
  3767. {
  3768. var ifrm = document.querySelector("#suggestions_iframe");
  3769. if (ifrm)
  3770. {
  3771. var src = ifrm.getAttribute("src");
  3772. var token = getQueryByName("token_key", src);
  3773. divFrame.innerHTML = '<br/><br/> \
  3774. <div id="stsh_frame_sub"> \
  3775. Token: <span class="stsh_blue">' + token + '</span> \
  3776. <br/><br/> \
  3777. <a class="stsh_a_button" target="_blank" \
  3778. href="' + src + '">Frame</a> \
  3779. <br/><br/> \
  3780. This frame may be blocked by ad blocker software. \
  3781. <br/> \
  3782. Please whitelist http://translation.steampowered.com \
  3783. to prevent this missing frame. \
  3784. </div>';
  3785. }
  3786. }
  3787. });
  3788. });
  3789.  
  3790. var configObIfrm = { attributes: true, attributeFilter: ["src"] };
  3791. obIfrm.observe(ifrm, configObIfrm);
  3792. }
  3793. }
  3794. // Open frame if only one string
  3795. {
  3796. setTimeoutCustom(function()
  3797. {
  3798. var elesCopy = document.querySelectorAll("#keylist .copysmall");
  3799. if (elesCopy.length == 1)
  3800. {
  3801. var eleDiv = elesCopy[0].parentElement.parentElement.parentElement;
  3802. if (eleDiv.tagName == "DIV")
  3803. {
  3804. if (!isVisible())
  3805. {
  3806. eleDiv.click();
  3807. }
  3808. }
  3809. }
  3810. }, 1000);
  3811. }
  3812. // Clean timestamp
  3813. {
  3814. var eleInputTime = document.querySelector("input[name='t']");
  3815. if (eleInputTime)
  3816. {
  3817. eleInputTime.parentElement.removeChild(eleInputTime);
  3818. }
  3819. }
  3820. } // End translate.php
  3821.  
  3822. if (url.indexOf("user_activity.php") > -1)
  3823. {
  3824. var user = "";
  3825. var eleAvatar = document.querySelector(".friend_block_avatar > a[href^='https://steamcommunity.com']");
  3826. if (eleAvatar)
  3827. {
  3828. eleAvatar.href = eleAvatar.href.replace("https://steamcommunity.com", "http://steamcommunity.com");
  3829. if (eleAvatar.href.indexOf("http://steamcommunity.com/profiles/") == 0)
  3830. {
  3831. user = eleAvatar.href.replace("http://steamcommunity.com/profiles/", "");
  3832. }
  3833. var name = eleAvatar.firstElementChild.getAttribute("title");
  3834. if (name == "")
  3835. {
  3836. name = user;
  3837. }
  3838. document.title = name + " - " + document.title;
  3839. }
  3840.  
  3841. var stsh_activityAddLink_start = new Date();
  3842. var stsh_activityAddLink_itv = setIntervalCustom(function(user)
  3843. {
  3844. var stsh_activityAddLink_isEnd = false;
  3845. var stsh_activityAddLink_cur = new Date();
  3846. var h3s = document.querySelectorAll("#leftAreaContainer h3");
  3847. if (h3s.length == 2)
  3848. {
  3849. var td = h3s[1].parentElement;
  3850. var matchArr = td.innerHTML.match(/<\/h3>.+<br>/i);
  3851. if (matchArr)
  3852. {
  3853. var name = matchArr[0].replace("</h3>-","").replace("-<br>","").replace("<br>","").trim();
  3854. if (name == "")
  3855. {
  3856. name = user;
  3857. }
  3858. if (name == "")
  3859. {
  3860. name = "Steam";
  3861. }
  3862. var tagNew = "";
  3863. if (user == "")
  3864. {
  3865. tagNew = "</h3><a id='stsh_sectionId' class='stsh_blue' target='_blank' href='http://steamcommunity.com/my'>" + name + "</a>"
  3866. + ", <a class='stsh_green' target='_blank' href='http://translation.steampowered.com/WhereIsEsty.php'>Esty</a><br><br>";
  3867. }
  3868. else
  3869. {
  3870. tagNew = "</h3><a id='stsh_sectionId' class='stsh_blue' target='_blank' href='http://steamcommunity.com/profiles/"
  3871. + user + "'>" + name + "</a>"
  3872. + ", <a class='stsh_green' target='_blank' href='http://translation.steampowered.com/WhereIsEsty.php?collectionof="
  3873. + user + "'>Esty</a>"
  3874. /*
  3875. // Typonion
  3876. + ", <a class='stsh_green' target='_blank' href='http://translation.steampowered.com/translate.php?user="
  3877. + user + "&onionhunter=1&liststatus=1'>Onion</a>
  3878. */
  3879. + " <br><br> ";
  3880. }
  3881. td.innerHTML = td.innerHTML.replace(/<\/h3>.+<br>/i, tagNew);
  3882. stsh_activityAddLink_isEnd = true;
  3883. }
  3884. if (stsh_activityAddLink_isEnd || stsh_activityAddLink_cur - stsh_activityAddLink_start > 10000)
  3885. {
  3886. clearInterval(stsh_activityAddLink_itv);
  3887. }
  3888. }
  3889. }, 300, user);
  3890. var countWord = "";
  3891. var countSugg = "";
  3892. var inputDials = document.querySelectorAll("#leftAreaContainer input.dial");
  3893. if (inputDials.length == 2)
  3894. {
  3895. countWord = inputDials[0].getAttribute("title").replace("words", "").trim();
  3896. countSugg = inputDials[1].getAttribute("title").replace("suggestions", "").trim();
  3897. }
  3898. var tdCount = document.querySelector("#leftAreaContainer td[align='left']");
  3899. if (tdCount)
  3900. {
  3901. tdCount.innerHTML = '<div style="width: 100px; display: inline-block; text-align: center;">Word: '
  3902. + countWord + '</div> <div style="width: 100px; display: inline-block; text-align: center; margin-left: 13px;">Suggestion: '
  3903. + countSugg + '</div>';
  3904. }
  3905. var sug = document.body.textContent;
  3906. var regComment = /VIEW COMMENT/g;
  3907. var regSuggest = /VIEW SUGGESTION/g;
  3908. var strComment = "...RECEIVED A MODERATOR COMMENT";
  3909. var strPending = "...ARE PENDING";
  3910. var strApproved = "...WERE APPROVED";
  3911. var strDeclined = "...WERE DECLINED";
  3912. var strApplied = "...HAVE BEEN APPLIED WITHIN THE LAST 14 DAYS";
  3913. var strRemoved = "...HAVE BEEN REMOVED WITHIN THE LAST 14 DAYS";
  3914. var startComment = sug.indexOf(strComment);
  3915. var startPending = sug.indexOf(strPending);
  3916. var startApproved = sug.indexOf(strApproved);
  3917. var startDeclined = sug.indexOf(strDeclined);
  3918. var startApplied = sug.indexOf(strApplied);
  3919. var startRemoved = sug.indexOf(strRemoved);
  3920. var sugComment = sug.substring(startComment,startPending);
  3921. var sugPending = sug.substring(startPending,startApproved);
  3922. var sugApproved = sug.substring(startApproved,startDeclined);
  3923. var sugDeclined = sug.substring(startDeclined,startApplied);
  3924. var sugApplied = sug.substring(startApplied,startRemoved);
  3925. var sugRemoved = sug.substring(startRemoved);
  3926. var countComment = (sugComment.match(regComment) || []).length;
  3927. var countPending = (sugPending.match(regSuggest) || []).length;
  3928. var countApproved = (sugApproved.match(regSuggest) || []).length;
  3929. var countDeclined = (sugDeclined.match(regSuggest) || []).length;
  3930. var countApplied = (sugApplied.match(regSuggest) || []).length;
  3931. var countRemoved = (sugRemoved.match(regSuggest) || []).length;
  3932. var divBtn = document.createElement("div");
  3933. document.body.appendChild(divBtn);
  3934. divBtn.innerHTML = ' \
  3935. <div style="position: fixed; z-index: 3; right: 12px; top: 84px; line-height: 24px; text-align: right;"> \
  3936. &nbsp; <input id="stsh_btnToProgress" value="To Progress" class="stsh_btn_long" type="button" \
  3937. onclick="scrollToId(\'stsh_sectionId\', -50); return false;" /><br/> \
  3938. \
  3939. &nbsp; <span class="stsh_scroll_header">Scroll To</span>\
  3940. <li class="stsh_suggestion_btn stsh_suggestion stsh_suggestion_comment"><input value="Comment (' + countComment + ')" \
  3941. class="stsh_btn_long" type="button" onclick="scrollToId(\'stsh_sectionComment\'); return false;" ></li> \
  3942. <li class="stsh_suggestion_btn stsh_suggestion stsh_suggestion_pending"><input value="Pending (' + countPending + ')" \
  3943. class="stsh_btn_long" type="button" onclick="scrollToId(\'stsh_sectionPending\'); return false;" ></li> \
  3944. <li class="stsh_suggestion_btn stsh_suggestion stsh_suggestion_approved"><input value="Approved (' + countApproved + ')" \
  3945. class="stsh_btn_long" type="button" onclick="scrollToId(\'stsh_sectionApproved\'); return false;" ></li> \
  3946. <li class="stsh_suggestion_btn stsh_suggestion stsh_suggestion_declined"><input value="Declined (' + countDeclined + ')" \
  3947. class="stsh_btn_long" type="button" onclick="scrollToId(\'stsh_sectionDeclined\'); return false;" ></li> \
  3948. <li class="stsh_suggestion_btn stsh_suggestion stsh_suggestion_applied"><input value="Applied (' + countApplied + ')" \
  3949. class="stsh_btn_long" type="button" onclick="scrollToId(\'stsh_sectionApplied\'); return false;" ></li> \
  3950. <li class="stsh_suggestion_btn stsh_suggestion stsh_suggestion_removed"><input value="Removed (' + countRemoved + ')" \
  3951. class="stsh_btn_long" type="button" onclick="scrollToId(\'stsh_sectionRemoved\'); return false;" ></li> \
  3952. <br/> \
  3953. &nbsp; <input value="Hide Suggestions" class="stsh_btn_long" type="button" onclick="hideSuggestion(); return false;" /><br/> \
  3954. &nbsp; <input value="Show Suggestions" class="stsh_btn_long" type="button" onclick="showSuggestion(); return false;" /><br/> \
  3955. <br/> \
  3956. &nbsp; <input value="Refresh" class="stsh_btn_long" type="button" onclick="window.location = window.location.href; return false;" /><br/> \
  3957. </div> \
  3958. ';
  3959.  
  3960. var divContainer = document.querySelector("#leftAreaContainer");
  3961. if (divContainer)
  3962. {
  3963. var inner = divContainer.innerHTML;
  3964. var htmlPending = /\.\.\.ARE \<a [^\<]+\>PENDING\<\/a\>/i.exec(inner);
  3965. var htmlApproved = /\.\.\.WERE \<a [^\<]+\>APPROVED\<\/a\>/i.exec(inner);
  3966. var htmlDeclined = /\.\.\.WERE \<a [^\<]+\>DECLINED\<\/a\>/i.exec(inner);
  3967. divContainer.innerHTML = inner
  3968. .replace("...RECEIVED A MODERATOR COMMENT",
  3969. "<span id='stsh_sectionComment' class='stsh_suggestion_header'>...RECEIVED A MODERATOR COMMENT ("
  3970. + countComment + ")</span>")
  3971. .replace(htmlPending,
  3972. "<span id='stsh_sectionPending' class='stsh_suggestion_header'>" + htmlPending + " ("
  3973. + countPending + ")</span>")
  3974. .replace(htmlApproved,
  3975. "<span id='stsh_sectionApproved' class='stsh_suggestion_header'>" + htmlApproved + " ("
  3976. + countApproved + ")</span>")
  3977. .replace(htmlDeclined,
  3978. "<span id='stsh_sectionDeclined' class='stsh_suggestion_header'>" + htmlDeclined + " ("
  3979. + countDeclined + ")</span>")
  3980. .replace("...HAVE BEEN APPLIED WITHIN THE LAST 14 DAYS",
  3981. "<span id='stsh_sectionApplied' class='stsh_suggestion_header'>...HAVE BEEN APPLIED WITHIN THE LAST 14 DAYS ("
  3982. + countApplied + ")</span>")
  3983. .replace("...HAVE BEEN REMOVED WITHIN THE LAST 14 DAYS",
  3984. "<span id='stsh_sectionRemoved' class='stsh_suggestion_header'>...HAVE BEEN REMOVED WITHIN THE LAST 14 DAYS ("
  3985. + countRemoved + ")</span>");
  3986. }
  3987. var eleHours = document.querySelector("#hours");
  3988. if (eleHours)
  3989. {
  3990. var eleBtn = document.querySelector("#stsh_btnToProgress");
  3991. if (eleBtn)
  3992. {
  3993. var ele = document.createElement("input");
  3994. ele.classList.add("stsh_btn_long");
  3995. ele.setAttribute("value", "To Hours");
  3996. ele.setAttribute("type", "button");
  3997. ele.setAttribute("onclick", "scrollToElement(\"input[name*='[remarks]']\", -48); return false;");
  3998. insertAfterElement(ele, eleBtn);
  3999. ele = document.createTextNode(" \u00A0 ");
  4000. insertAfterElement(ele, eleBtn);
  4001. ele = document.createElement("br");
  4002. insertAfterElement(ele, eleBtn);
  4003. }
  4004. }
  4005. var cans = document.querySelectorAll("canvas");
  4006. for (var i = 0; i < cans.length; i++)
  4007. {
  4008. cans[i].parentElement.removeChild(cans[i]);
  4009. }
  4010. var aKeys = document.querySelectorAll("#leftAreaContainer li > a:nth-child(1)");
  4011. for (var i = 0; i < aKeys.length; i++)
  4012. {
  4013. var key = aKeys[i].textContent;
  4014. var keyArr = key.substr(21).trim().split(" >> ");
  4015. keyArr[0] = "<span style='color: #FFF !important;'>" + keyArr[0] + "</span>";
  4016. var keyNew = key.substr(0,21) + keyArr.join(" >> ") + "";
  4017. aKeys[i].innerHTML = keyNew;
  4018. }
  4019. var sugModeComment = 0;
  4020. var sugModePending = 1;
  4021. var sugModeApproved = 2;
  4022. var sugModeDeclined = 3;
  4023. var sugModeApplied = 4;
  4024. var sugModeRemoved = 5;
  4025. var sugMode = sugModeComment;
  4026. var eleSugFirst = document.querySelector("#leftAreaContainer > a[href^='translate.php?search_input=']"
  4027. + ", #leftAreaContainer > form > a[href^='translate.php?search_input=']");
  4028. if (eleSugFirst)
  4029. {
  4030. var eleSugHeadPrev = eleSugFirst.previousElementSibling.previousElementSibling;
  4031. if (eleSugHeadPrev.id == "stsh_sectionRemoved")
  4032. {
  4033. sugMode = sugModeRemoved;
  4034. }
  4035. else if (eleSugHeadPrev.id == "stsh_sectionApplied")
  4036. {
  4037. sugMode = sugModeApplied;
  4038. }
  4039. else if (eleSugHeadPrev.id == "stsh_sectionDeclined")
  4040. {
  4041. sugMode = sugModeDeclined;
  4042. }
  4043. else if (eleSugHeadPrev.id == "stsh_sectionApproved")
  4044. {
  4045. sugMode = sugModeApproved;
  4046. }
  4047. else if (eleSugHeadPrev.id == "stsh_sectionPending")
  4048. {
  4049. sugMode = sugModePending;
  4050. }
  4051. var eleSugNext = eleSugFirst;
  4052. while (eleSugNext)
  4053. {
  4054. if (eleSugNext.tagName == "A")
  4055. {
  4056. var attrHref = eleSugNext.getAttribute("href");
  4057. if (attrHref && attrHref.indexOf("translate.php?search_input=") == 0)
  4058. {
  4059. eleSugNext.classList.add("stsh_suggestion");
  4060. if (sugMode == sugModeComment)
  4061. {
  4062. eleSugNext.classList.add("stsh_suggestion_comment");
  4063. }
  4064. else if (sugMode == sugModePending)
  4065. {
  4066. eleSugNext.classList.add("stsh_suggestion_pending");
  4067. }
  4068. else if (sugMode == sugModeApproved)
  4069. {
  4070. eleSugNext.classList.add("stsh_suggestion_approved");
  4071. }
  4072. else if (sugMode == sugModeDeclined)
  4073. {
  4074. eleSugNext.classList.add("stsh_suggestion_declined");
  4075. }
  4076. else if (sugMode == sugModeApplied)
  4077. {
  4078. eleSugNext.classList.add("stsh_suggestion_applied");
  4079. }
  4080. else if (sugMode == sugModeRemoved)
  4081. {
  4082. eleSugNext.classList.add("stsh_suggestion_removed");
  4083. }
  4084. }
  4085. }
  4086. else if (eleSugNext.tagName == "SPAN" && eleSugNext.classList.contains("stsh_suggestion_header"))
  4087. {
  4088. if (eleSugNext.id == "stsh_sectionRemoved")
  4089. {
  4090. sugMode = sugModeRemoved;
  4091. }
  4092. else if (eleSugNext.id == "stsh_sectionApplied")
  4093. {
  4094. sugMode = sugModeApplied;
  4095. }
  4096. else if (eleSugNext.id == "stsh_sectionDeclined")
  4097. {
  4098. sugMode = sugModeDeclined;
  4099. }
  4100. else if (eleSugNext.id == "stsh_sectionApproved")
  4101. {
  4102. sugMode = sugModeApproved;
  4103. }
  4104. else if (eleSugNext.id == "stsh_sectionPending")
  4105. {
  4106. sugMode = sugModePending;
  4107. }
  4108. }
  4109. eleSugNext = eleSugNext.nextElementSibling;
  4110. }
  4111. }
  4112. // Change language & correct url
  4113. {
  4114. var aProgresses = document.querySelectorAll("div > .friend_block_avatar a[onmouseout]");
  4115. for (var i = 0; i < aProgresses.length; i++)
  4116. {
  4117. var langCur = getQueryByName("lang", aProgresses[i].href);
  4118. if (langCur == "")
  4119. {
  4120. aProgresses[i].href = aProgresses[i].href + lang;
  4121. }
  4122. else
  4123. {
  4124. if (langCur != lang)
  4125. {
  4126. var langQuery = (url.indexOf("?") > -1) ? "&lang=" : "?lang=";
  4127. window.location = url + langQuery + langCur;
  4128. }
  4129. }
  4130. var aContent = aProgresses[i].textContent.trim();
  4131. if (aContent.indexOf("SUGGESTIONS") > -1)
  4132. {
  4133. aProgresses[i].href = aProgresses[i].href + "&listsort=5&liststatus=1&paginationrows=1000";
  4134. }
  4135. else if (aContent.indexOf("REVIEWS") > -1)
  4136. {
  4137. aProgresses[i].href = aProgresses[i].href + "&listsort=5&liststatus=3&paginationrows=1000";
  4138. }
  4139. }
  4140. }
  4141. // Hours
  4142. if (document.querySelector("#hours"))
  4143. {
  4144. function calculateHours()
  4145. {
  4146. var rgxDate = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/;
  4147. var rgxTime = /^(\d{1,2}:\d{2}(:\d{2})?|\d{1,2}\.\d{2})$/;
  4148. var eleFrom = document.querySelector("#stsh_hoursCalc_from");
  4149. var eleTo = document.querySelector("#stsh_hoursCalc_to");
  4150. var eleRes = document.querySelector("#stsh_hoursCalc_result");
  4151. if (eleFrom && eleTo && eleRes)
  4152. {
  4153. var rawFrom = eleFrom.value.trim();
  4154. var rawTo = eleTo.value.trim();
  4155. var valFrom = 0;
  4156. var valTo = 0;
  4157. if (rgxDate.test(rawFrom))
  4158. {
  4159. rawFrom = rawFrom.substr(11);
  4160. }
  4161. if (rgxTime.test(rawFrom))
  4162. {
  4163. var arrTime = rawFrom.split(":");
  4164. if (arrTime.length == 1)
  4165. {
  4166. arrTime = rawFrom.split(".");
  4167. }
  4168. valFrom = parseInt(arrTime[1]) + (parseInt(arrTime[0]) * 60);
  4169. }
  4170. if (rgxDate.test(rawTo))
  4171. {
  4172. rawTo = rawTo.substr(11);
  4173. }
  4174. if (rgxTime.test(rawTo))
  4175. {
  4176. var arrTime = rawTo.split(":");
  4177. if (arrTime.length == 1)
  4178. {
  4179. arrTime = rawTo.split(".");
  4180. }
  4181. valTo = parseInt(arrTime[1]) + (parseInt(arrTime[0]) * 60);
  4182. }
  4183. var valDiff = Math.abs(valTo - valFrom);
  4184. var valHr = parseInt(valDiff / 60);
  4185. var valMn = valDiff % 60;
  4186. eleRes.textContent = padZero(valHr, 2) + ":" + padZero(valMn, 2);
  4187. }
  4188. }
  4189. var curDate = new Date();
  4190. curDate.setTime(curDate.getTime() - (1000 * 60 * 60 * 8));
  4191. if (isDstUsa(curDate.getUTCFullYear(), curDate.getUTCMonth() + 1, curDate.getUTCDate(), curDate.getUTCHours()))
  4192. {
  4193. curDate.setTime(curDate.getTime() + (1000 * 60 * 60 * 1));
  4194. }
  4195. var curDateStr = curDate.toISOString().substr(0, 10);
  4196. // Add hours calculator
  4197. {
  4198. var eleFinalize = document.querySelector("#hours input[name='Finalize']");
  4199. if (eleFinalize)
  4200. {
  4201. var eleFinalizeParent = eleFinalize.parentElement;
  4202. eleFinalizeParent.setAttribute("colspan", "2");
  4203. eleFinalizeParent.style.verticalAlign = "top";
  4204. var elePad = document.createElement("td");
  4205. insertBeforeElement(elePad, eleFinalizeParent);
  4206. var eleCalc = document.createElement("td");
  4207. eleCalc.classList.add("stsh_hoursCalc");
  4208. insertBeforeElement(eleCalc, eleFinalizeParent);
  4209. if (eleCalc.parentElement.previousElementSibling.querySelector("input[type='radio']"))
  4210. {
  4211. eleCalc.appendChild(document.createElement("br"));
  4212. }
  4213. var ele = document.createElement("b");
  4214. ele.textContent = " Hours Calculator (Estimated) ";
  4215. eleCalc.appendChild(ele);
  4216. eleCalc.appendChild(document.createElement("br"));
  4217. var ele = document.createElement("span");
  4218. ele.innerHTML = " Enter date or time to calculate range (calculate only hours and minutes). "
  4219. + "<br/>You can enter date \"2016-01-01 08:05:00\" or time \"8:05\" or time \"8.05\".";
  4220. ele.setAttribute("style", "display: inline-block; padding-bottom: 4px;");
  4221. eleCalc.appendChild(ele);
  4222. eleCalc.appendChild(document.createElement("br"));
  4223. var ele = document.createElement("span");
  4224. ele.textContent = " From: ";
  4225. eleCalc.appendChild(ele);
  4226. var ele = document.createElement("input");
  4227. ele.id = "stsh_hoursCalc_from"
  4228. ele.setAttribute("type", "text");
  4229. ele.setAttribute("onkeypress", "return event.keyCode != 13;");
  4230. ele.setAttribute("autocomplete", "off");
  4231. ele.addEventListener("keyup", function()
  4232. {
  4233. calculateHours();
  4234. });
  4235. eleCalc.appendChild(ele);
  4236. var ele = document.createElement("span");
  4237. ele.innerHTML = "&nbsp;&nbsp; To: ";
  4238. eleCalc.appendChild(ele);
  4239. var ele = document.createElement("input");
  4240. ele.id = "stsh_hoursCalc_to"
  4241. ele.setAttribute("type", "text");
  4242. ele.setAttribute("onkeypress", "return event.keyCode != 13;");
  4243. ele.setAttribute("autocomplete", "off");
  4244. ele.addEventListener("keyup", function()
  4245. {
  4246. calculateHours();
  4247. });
  4248. eleCalc.appendChild(ele);
  4249. var ele = document.createElement("span");
  4250. ele.innerHTML = "&nbsp;&nbsp; Result: ";
  4251. eleCalc.appendChild(ele);
  4252. var ele = document.createElement("b");
  4253. ele.id = "stsh_hoursCalc_result"
  4254. ele.textContent = " 00:00 ";
  4255. eleCalc.appendChild(ele);
  4256. }
  4257. }
  4258. // Hilight current date
  4259. {
  4260. var elesTd = document.querySelectorAll("#hours > table > tbody > tr > td:nth-child(1)");
  4261. for (var i = 0; i < elesTd.length; i++)
  4262. {
  4263. if (elesTd[i].textContent.indexOf(curDateStr) > -1)
  4264. {
  4265. elesTd[i].parentElement.id = "stsh_hours_curDate";
  4266. elesTd[i].parentElement.classList.add("stsh_hours_curDate");
  4267. break;
  4268. }
  4269. }
  4270. }
  4271. // Auto calculate hours in current date
  4272. {
  4273. var timePendingFirst = "";
  4274. var timePendingLast = "";
  4275. var elesPending = document.querySelectorAll("#mainbody .stsh_suggestion_pending");
  4276. for (var i = 0; i < elesPending.length; i++)
  4277. {
  4278. var content = elesPending[i].textContent.trim().substr(0, 19);
  4279. if (content.substr(0, 10) === curDateStr)
  4280. {
  4281. timePendingFirst = content.substr(11, 5);
  4282. if (timePendingLast === "")
  4283. {
  4284. timePendingLast = timePendingFirst;
  4285. }
  4286. }
  4287. else
  4288. {
  4289. break;
  4290. }
  4291. }
  4292. var timeApprovedFirst = "";
  4293. var timeApprovedLast = "";
  4294. var elesApproved = document.querySelectorAll("#mainbody .stsh_suggestion_approved");
  4295. for (var i = 0; i < elesApproved.length; i++)
  4296. {
  4297. var content = elesApproved[i].textContent.trim().substr(0, 19);
  4298. if (content.substr(0, 10) === curDateStr)
  4299. {
  4300. timeApprovedFirst = content.substr(11, 5);
  4301. if (timeApprovedLast === "")
  4302. {
  4303. timeApprovedLast = timeApprovedFirst;
  4304. }
  4305. }
  4306. else
  4307. {
  4308. break;
  4309. }
  4310. }
  4311. if (timePendingFirst === "")
  4312. {
  4313. timePendingFirst = timeApprovedFirst;
  4314. }
  4315. if (timeApprovedFirst === "")
  4316. {
  4317. timeApprovedFirst = timePendingFirst;
  4318. }
  4319. if (timePendingLast === "")
  4320. {
  4321. timePendingLast = timeApprovedLast;
  4322. }
  4323. if (timeApprovedLast === "")
  4324. {
  4325. timeApprovedLast = timePendingLast;
  4326. }
  4327. var timeFirst = timeApprovedFirst < timePendingFirst ? timeApprovedFirst : timePendingFirst;
  4328. var timeLast = timeApprovedLast > timePendingLast ? timeApprovedLast : timePendingLast;
  4329. if (timeFirst != "")
  4330. {
  4331. var eleFrom = document.querySelector("#stsh_hoursCalc_from");
  4332. if (eleFrom)
  4333. {
  4334. eleFrom.value = timeFirst;
  4335. }
  4336. var eleTo = document.querySelector("#stsh_hoursCalc_to");
  4337. if (eleTo)
  4338. {
  4339. eleTo.value = timeLast;
  4340. }
  4341. calculateHours();
  4342. }
  4343. }
  4344. }
  4345. // Hide wallet in other user pages
  4346. {
  4347. var eleASug = document.querySelector(".friend_block_avatar > a[href^='http://translation.steampowered.com/translate.php'");
  4348. if (!eleASug || eleASug.textContent.trim() !== "YOUR SUGGESTIONS")
  4349. {
  4350. var elesAWallet = document.querySelectorAll("a[id^='walletkeys']");
  4351. for (var i = 0; i < elesAWallet.length; i++)
  4352. {
  4353. var eleCur = elesAWallet[i];
  4354. for (var j = 0; j < 5; j++)
  4355. {
  4356. eleCur.classList.add("stsh_hidden");
  4357. eleCur = eleCur.nextElementSibling;
  4358. }
  4359. }
  4360. }
  4361. }
  4362. } // End user_activity.php
  4363. if (/\/rally[0-9]{0,4}/.test(url))
  4364. {
  4365. resizeSuggestionBox();
  4366. var outer = document.getElementById("suggestions_box_outer");
  4367. if (outer)
  4368. {
  4369. outer.setAttribute("onclick","hideSuggestionsBox();");
  4370. }
  4371. // Set cur lang to first
  4372. {
  4373. var first = document.querySelector(".gradienttable tr:nth-child(6)");
  4374. if (first)
  4375. {
  4376. var cur = null;
  4377. var tdLangs = document.querySelectorAll(".gradienttable tr > td:nth-child(1)");
  4378. for (var i = 0; i < tdLangs.length; i++)
  4379. {
  4380. if (lang === tdLangs[i].textContent.trim().toLowerCase())
  4381. {
  4382. cur = tdLangs[i].parentElement;
  4383. break;
  4384. }
  4385. }
  4386. if (cur)
  4387. {
  4388. cur.classList.add("stsh_curLang");
  4389. first.parentElement.insertBefore(cur, first);
  4390. }
  4391. }
  4392. }
  4393. // Change row per page
  4394. {
  4395. var eleAs = document.querySelectorAll(".gradienttable tr:nth-child(6) a[href^='translate.php?']");
  4396. for (var i = 0; i < eleAs.length; i++)
  4397. {
  4398. eleAs[i].href = eleAs[i].href + "&paginationrows=1000";
  4399. }
  4400. }
  4401. var inputClose = document.querySelector("td:nth-child(3) > input:nth-child(1)");
  4402. if (inputClose)
  4403. {
  4404. inputClose.value = "Close (Esc)";
  4405. }
  4406. } // End rally.php
  4407. if (/\/rally_results_?[0-9]{0,4}/.test(url))
  4408. {
  4409. var h3 = document.querySelector("table.curved h3");
  4410. if (h3)
  4411. {
  4412. document.title = h3.textContent.trim();
  4413. }
  4414. var eleTable = document.querySelector("body > div:nth-child(1) > table:nth-child(1)");
  4415. if (eleTable)
  4416. {
  4417. eleTable.style.width = "";
  4418. }
  4419. var inputClose = document.querySelector("td:nth-child(3) > input:nth-child(1)");
  4420. if (inputClose)
  4421. {
  4422. inputClose.value = "Close (Esc)";
  4423. inputClose.focus();
  4424. }
  4425. // Add frame and background button
  4426. {
  4427. var eleTdFirst = document.querySelector("td:nth-child(1)");
  4428. if (eleTdFirst)
  4429. {
  4430. var eleTdFrame = document.createElement("td");
  4431. eleTdFrame.setAttribute("align", "right");
  4432. eleTdFrame.innerHTML = ' <a class="stsh_a_button" target="_blank" '
  4433. + ' href="' + url + '">Frame</a> ';
  4434. insertBeforeElement(eleTdFrame, eleTdFirst);
  4435. var img = document.body.style.backgroundImage;
  4436. if (img.indexOf("url(\"") === 0)
  4437. {
  4438. img = img.replace("url(\"", "").replace("\")", "");
  4439. var eleTdImage = document.createElement("td");
  4440. eleTdImage.setAttribute("align", "right");
  4441. eleTdImage.innerHTML = ' <a class="stsh_a_button" target="_blank" '
  4442. + ' href="' + img + '">View Background</a> ';
  4443. insertAfterElement(eleTdImage, eleTdFrame);
  4444. }
  4445. }
  4446. }
  4447. var inputPrev = document.querySelector("input[value^='Prev']");
  4448. if (inputPrev)
  4449. {
  4450. addKeyCtrl(document, inputPrev, 219, "["); // [
  4451. addKeyCtrl(document, inputPrev, "BracketLeft", ""); // [
  4452. disableAfterClick(inputPrev);
  4453. }
  4454. var inputNext = document.querySelector("input[value^='Next']");
  4455. if (inputNext)
  4456. {
  4457. addKeyCtrl(document, inputNext, 221, "]"); // ]
  4458. addKeyCtrl(document, inputNext, "BracketRight", ""); // ]
  4459. disableAfterClick(inputNext);
  4460. }
  4461. // Hilight cur lang
  4462. {
  4463. var elesLang = document.querySelectorAll("table.curved > tbody:nth-child(1) > tr:nth-child(1) > td:nth-child(3) > h2:nth-child(1)");
  4464. for (var i = 0; i < elesLang.length; i++)
  4465. {
  4466. if (lang == elesLang[i].textContent.trim().toLowerCase())
  4467. {
  4468. var eleParent = elesLang[i].parentElement.parentElement.parentElement.parentElement;
  4469. //eleParent.style.backgroundColor = "#474D1A";
  4470. eleParent.classList.add("stsh_curLang");
  4471. eleParent.setAttribute("bgcolor", "#474D1A");
  4472. eleParent.setAttribute("onmouseout", "this.bgColor='#474D1A'");
  4473. eleParent.setAttribute("onmouseover", "this.bgColor='#76802B'");
  4474. break;
  4475. }
  4476. }
  4477. }
  4478. } // End rally_results.php
  4479. if (/\/rallyreplay_?[0-9]{0,4}/.test(url))
  4480. {
  4481. // Set cur lang to first
  4482. {
  4483. var elesFrame = document.querySelectorAll("#leftAreaContainer div[id^='frame']");
  4484. for (var i = 0; i < elesFrame.length; i++)
  4485. {
  4486. var first = elesFrame[i].querySelector(".gradienttable tr:nth-child(6)");
  4487. if (first)
  4488. {
  4489. var cur = null;
  4490. var tdLangs = elesFrame[i].querySelectorAll(".gradienttable tr > td:nth-child(1)");
  4491. for (var j = 0; j < tdLangs.length; j++)
  4492. {
  4493. if (lang === tdLangs[j].textContent.trim().toLowerCase())
  4494. {
  4495. cur = tdLangs[j].parentElement;
  4496. break;
  4497. }
  4498. }
  4499. if (cur)
  4500. {
  4501. cur.classList.add("stsh_curLang");
  4502. first.parentElement.insertBefore(cur, first);
  4503. }
  4504. }
  4505. }
  4506. }
  4507. var eleBtn = document.querySelector("input[value='FASTEST']");
  4508. if (eleBtn)
  4509. {
  4510. var ele = document.createElement("input");
  4511. ele.setAttribute("type", "button");
  4512. ele.setAttribute("value", "RESTART");
  4513. ele.setAttribute("style", "padding: 0; border: none; background: none;");
  4514. ele.setAttribute("onclick", "indexReplay = 0; elsFrame.eq(indexReplay).fadeOut(0, function() \
  4515. { indexReplay = (indexReplay + 1) % lenFrame; elsFrame.eq(indexReplay).fadeIn(0); })");
  4516. insertAfterElement(ele, eleBtn);
  4517. insertAfterElement(document.createTextNode(" | "), eleBtn);
  4518. }
  4519. } // End rallyreplay.php
  4520. if (url.indexOf("/WhereIsEsty.php") > -1)
  4521. {
  4522. resizeSuggestionBox();
  4523. var outer = document.getElementById("suggestions_box_outer");
  4524. if (outer)
  4525. {
  4526. outer.setAttribute("onclick","hideSuggestionsBox();");
  4527. }
  4528. var divContainer = document.querySelector("#pageContainer");
  4529. if (divContainer)
  4530. {
  4531. var ele = document.createElement("div");
  4532. ele.id = "logout";
  4533. ele.innerHTML = ' <a class="stsh_a_button" target="_blank" '
  4534. + ' href="/home.php">Home</a> ';
  4535. divContainer.appendChild(ele);
  4536. }
  4537.  
  4538. var divContent = document.querySelector("#leftAreaContainer > div");
  4539. if (divContent)
  4540. {
  4541. var countSnap = document.querySelectorAll("div.box").length;
  4542. var user = "";
  4543. var name = "";
  4544.  
  4545. var eleImg = document.querySelector("#leftAreaContainer > div > div > a > img ");
  4546. if (eleImg)
  4547. {
  4548. name = eleImg.getAttribute("title");
  4549. user = eleImg.parentElement.getAttribute("href").replace("https://steamcommunity.com/profiles/", "");
  4550. }
  4551. var ele = document.createElement("div");
  4552. ele.setAttribute("class", "stsh_snapshot");
  4553. ele.innerHTML = "<a class='stsh_blue' target='_blank' href='http://translation.steampowered.com/user_activity.php?user="
  4554. + user + "'>" + name + "</a>"
  4555. + "<br>Snapshot: " + countSnap;
  4556.  
  4557. divContent.appendChild(ele);
  4558. }
  4559. } // End WhereIsEsty.php
  4560. if (url.indexOf("/stickerbox.php") > -1)
  4561. {
  4562. document.querySelector("textarea[name='add_comment']").focus();
  4563. var inputPrev = document.querySelector("img[src*='z0lEQVRIx5WWaWxVRRTH'");
  4564. if (inputPrev)
  4565. {
  4566. addKeyCtrl(document, inputPrev, 219, ""); // [
  4567. addKeyCtrl(document, inputPrev, "BracketLeft", ""); // [
  4568. disableAfterClick(inputPrev);
  4569. }
  4570. var inputNext = document.querySelector("img[src*='40lEQVRIx5WWe0xXZRjH'");
  4571. if (inputNext)
  4572. {
  4573. addKeyCtrl(document, inputNext, 221, ""); // ]
  4574. addKeyCtrl(document, inputNext, "BracketRight", ""); // ]
  4575. disableAfterClick(inputNext);
  4576. }
  4577. } // End stickerbox.php
  4578. if (/\/(home\.php|index\.php)/i.test(url))
  4579. {
  4580. // Set cur lang to first
  4581. {
  4582. var first = null;
  4583. var cur = null;
  4584. var curLang = lang.substring(0, 4);
  4585. if (curLang == "schi")
  4586. curLang = "sim.";
  4587. else if (curLang == "tchi")
  4588. curLang = "tra.";
  4589. var eleLangs = document.querySelectorAll("#overall .progress");
  4590. if (eleLangs.length > 0)
  4591. {
  4592. first = eleLangs[0];
  4593. for (var i = 0; i < eleLangs.length; i++)
  4594. {
  4595. if (curLang === eleLangs[i].textContent.trim().substring(0, 4).toLowerCase())
  4596. {
  4597. cur = eleLangs[i];
  4598. break;
  4599. }
  4600. }
  4601. if (cur)
  4602. {
  4603. var curSib1 = cur.nextSibling;
  4604. var curSib2 = curSib1.nextSibling;
  4605. var curSib3 = curSib2.nextSibling;
  4606. var curSib4 = curSib3.nextSibling;
  4607. var curSib5 = curSib4.nextSibling;
  4608. var curSib6 = curSib5.nextSibling;
  4609. insertBeforeElement(cur, first);
  4610. insertAfterElement(curSib6, cur);
  4611. insertAfterElement(curSib5, cur);
  4612. insertAfterElement(curSib4, cur);
  4613. insertAfterElement(curSib3, cur);
  4614. insertAfterElement(curSib2, cur);
  4615. insertAfterElement(curSib1, cur);
  4616. }
  4617. }
  4618. }
  4619. if (document.querySelector("#logout"))
  4620. {
  4621. var tmplHome = ' \
  4622. <div class="stsh_home_group"> \
  4623. <span class="stsh_home_header">Shortcuts</span>\
  4624. <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; \
  4625. <br/> &nbsp; <a class="stsh_a_button stsh_btn_med" target="_blank" href="/glossary.php">Glossary</a> &nbsp; \
  4626. \
  4627. <br/> <span class="stsh_home_header">Rally</span>\
  4628. <br/> &nbsp; <a class="stsh_a_button stsh_btn_med" target="_blank" href="/rally.php">Rally 2016</a> &nbsp; \
  4629. <br/> &nbsp; <a class="stsh_a_button stsh_btn_med" target="_blank" href="/rally2015.php">Rally 2015</a> &nbsp; \
  4630. <br/> &nbsp; <a class="stsh_a_button stsh_btn_med" target="_blank" href="/rally2014.php">Rally 2014</a> &nbsp; \
  4631. <br/> &nbsp; <a class="stsh_a_button stsh_btn_med" target="_blank" href="/rally2013.php">Rally 2013</a> &nbsp; \
  4632. \
  4633. <br/> <span class="stsh_home_header">Events</span>\
  4634. <br/> &nbsp; <a class="stsh_a_button stsh_btn_med" target="_blank" href="/rallyreplay.php">Rally Replay</a> &nbsp; \
  4635. <br/> &nbsp; <a class="stsh_a_button stsh_btn_med" target="_blank" href="/onionolooorm.php">Typonion</a> &nbsp; \
  4636. <br/> &nbsp; <a class="stsh_a_button stsh_btn_med" target="_blank" href="/dstbattle.php">DST Battle</a> &nbsp; \
  4637. <br/> &nbsp; <a class="stsh_a_button stsh_btn_med" target="_blank" href="/dota2.php">DOTA 2</a> &nbsp; \
  4638. <br/> \
  4639. </div> \
  4640. ';
  4641. var curDate = new Date();
  4642. curDate.setTime(curDate.getTime() - (1000 * 60 * 60 * 8));
  4643. if (isDstUsa(curDate.getUTCFullYear(), curDate.getUTCMonth() + 1, curDate.getUTCDate(), curDate.getUTCHours()))
  4644. {
  4645. curDate.setTime(curDate.getTime() + (1000 * 60 * 60 * 1));
  4646. }
  4647. tmplHome = tmplHome.replace("%DATE%", curDate.toISOString().substr(0, 10));
  4648. var eleNew = document.createElement("div");
  4649. eleNew.innerHTML = tmplHome;
  4650. document.body.appendChild(eleNew);
  4651. }
  4652. // Fix STS JS error
  4653. {
  4654. var eleTimer = document.querySelector("#timer");
  4655. if (!eleTimer)
  4656. {
  4657. var ele = document.createElement("div");
  4658. ele.id = "timer";
  4659. ele.classList.add("stsh_hidden");
  4660. document.body.appendChild(ele);
  4661. }
  4662. }
  4663. } // End home.php
  4664. if (url.indexOf("/glossary.php") > -1)
  4665. {
  4666. // Add shortcuts
  4667. {
  4668. var contentGlos = ' \
  4669. <div class="stsh_home_group"> \
  4670. <span class="stsh_home_header">Shortcuts</span>\
  4671. <br/> &nbsp; <a class="stsh_a_button stsh_btn_med" target="_blank" \
  4672. href="/translate.php?chosenfile=1&listfilter=1&listsort=3&paginationrows=1000&branch_ID=49&file_ID=226"> \
  4673. Glossary</a> &nbsp; \
  4674. <br/> &nbsp; <a class="stsh_a_button stsh_btn_med" target="_blank" \
  4675. href="/translate.php?chosenfile=1&listfilter=1&listsort=3&paginationrows=1000&branch_ID=49&file_ID=232"> \
  4676. Phrases</a> &nbsp; \
  4677. <br/> \
  4678. </div> \
  4679. ';
  4680. var eleNew = document.createElement("div");
  4681. eleNew.innerHTML = contentGlos;
  4682. document.body.appendChild(eleNew);
  4683. }
  4684. // Improve glossary links
  4685. {
  4686. var elesLink = document.querySelectorAll("#votes_container > .lbAction a[href^='./translate.php?search_input=']");
  4687. for (var i = 0; i < elesLink.length; i++)
  4688. {
  4689. elesLink[i].href = elesLink[i].href.replace("keyonly=0", "keyonly=2")
  4690. .replace("listsort=0", "listsort=4")
  4691. .replace("paginationrows=50", "paginationrows=1000");
  4692. }
  4693. }
  4694. } // End glossary.php
  4695. if (url.indexOf("/dstbattle.php") > -1)
  4696. {
  4697. // Hilight cur lang
  4698. {
  4699. var cur = null;
  4700. var elesLang = document.querySelectorAll(".gradienttable > tbody:nth-child(1) > tr > th:nth-child(1)");
  4701. for (var i = 1; i < elesLang.length; i++)
  4702. {
  4703. if (lang === elesLang[i].textContent.trim().replace(/[0-9]+\. /, "").toLowerCase())
  4704. {
  4705. cur = elesLang[i].parentElement;
  4706. break;
  4707. }
  4708. }
  4709. if (cur)
  4710. {
  4711. cur.classList.add("stsh_dst_curLang");
  4712. }
  4713. }
  4714. } // End dstbattle.php
  4715. if (url.indexOf("/statistics.php") > -1)
  4716. {
  4717. setTimeoutCustom(function()
  4718. {
  4719. var qBranch = getQueryByName("branch_ID");
  4720. var qFile = getQueryByName("file_ID");
  4721. if (qBranch === "" && qFile === "")
  4722. {
  4723. var keyIdArr = new Array();
  4724. var valDataArr = new Array();
  4725. var keyBrArr = new Array();
  4726. var valBrArr = new Array();
  4727. var keyTrArr = new Array();
  4728. var valTrArr = new Array();
  4729. var keyApArr = new Array();
  4730. var valApArr = new Array();
  4731. var eleHead = document.querySelector("#overall");
  4732. if (eleHead)
  4733. {
  4734. function getProgress(content)
  4735. {
  4736. var rgxNum = /[0-9]+/g;
  4737. var data = "";
  4738. if (content.indexOf("<15") > -1)
  4739. {
  4740. data = "014"
  4741. }
  4742. else if (content.indexOf("100") < 0)
  4743. {
  4744. data = "0" + (content.match(rgxNum) || ["00"])[0];
  4745. }
  4746. else
  4747. {
  4748. data = "100";
  4749. }
  4750. return data;
  4751. }
  4752. var dataId = -1;
  4753. var dataBr = "";
  4754. var dataTr = "";
  4755. var dataAp = "";
  4756. var eleProgress = document.createElement("div");
  4757. while (eleHead.firstChild)
  4758. {
  4759. var child = eleHead.firstChild;
  4760. if (child.nodeName !== "#text")
  4761. {
  4762. if (child.id === "" && child.classList.contains("progress"))
  4763. {
  4764. dataId++;
  4765. eleProgress = document.createElement("div");
  4766. eleProgress.classList.add("stsh_stat_progress");
  4767. dataBr = child.textContent.trim();
  4768. if (dataBr.indexOf("glossary") === 0)
  4769. {
  4770. dataBr = "0" + dataBr;
  4771. }
  4772. eleProgress.setAttribute("data-br", dataBr);
  4773. eleProgress.setAttribute("data-id", dataId);
  4774. keyIdArr.push(dataId);
  4775. valDataArr[dataId] = eleProgress;
  4776. }
  4777. else if (child.classList.contains("graphtranslatedstats"))
  4778. {
  4779. dataTr = getProgress(child.textContent);
  4780. eleProgress.setAttribute("data-tr", dataTr);
  4781. }
  4782. else if (child.classList.contains("graphapprovedstats"))
  4783. {
  4784. dataAp = getProgress(child.textContent);
  4785. eleProgress.setAttribute("data-ap", dataAp);
  4786. //var dataId = eleProgress.dataset.id;
  4787. //var dataTr = eleProgress.dataset.tr;
  4788. //var dataBr = eleProgress.dataset.br;
  4789. var dataTrApBr = dataTr + "_" + dataAp + "_" + dataBr;
  4790. var dataApTrBr = dataAp + "_" + dataTr + "_" + dataBr;
  4791. //eleProgress.setAttribute("data-trapbr", dataTrApBr);
  4792. //eleProgress.setAttribute("data-aptrbr", dataApTrBr);
  4793. keyBrArr.push(dataBr);
  4794. valBrArr[dataBr] = dataId;
  4795. keyTrArr.push(dataTrApBr);
  4796. valTrArr[dataTrApBr] = dataId;
  4797. keyApArr.push(dataApTrBr);
  4798. valApArr[dataApTrBr] = dataId;
  4799. }
  4800. }
  4801. eleProgress.appendChild(child);
  4802. }
  4803. var i = keyIdArr.length - 1;
  4804. if (i > -1)
  4805. {
  4806. eleHead.appendChild(valDataArr[keyIdArr[i]]);
  4807. }
  4808. for (i--; i > -1; i--)
  4809. {
  4810. insertBeforeElement(valDataArr[keyIdArr[i]], eleHead.firstElementChild);
  4811. }
  4812. keyBrArr.sort();
  4813. keyTrArr.sort().reverse();
  4814. keyApArr.sort().reverse();
  4815. }
  4816. var eleDiv = document.createElement("div");
  4817. document.body.appendChild(eleDiv);
  4818. eleDiv.innerHTML = ' \
  4819. <div class="stsh_showing_group"> \
  4820. <span class="stsh_showing_header">Hide</span>\
  4821. <br/> &nbsp; <input id="stsh_stat_hideGame" value="Game" class="stsh_btn_short" type="button" /> \
  4822. <input id="stsh_stat_hideSteam" value="Steam" class="stsh_btn_short" type="button" /> \
  4823. <br/> &nbsp; <input id="stsh_stat_hideApproved" value="Approved" class="stsh_btn_long" type="button" /> \
  4824. <br/> &nbsp; <input id="stsh_stat_hideCompleted" value="Completed" class="stsh_btn_long" type="button" /> \
  4825. \
  4826. <br/> &nbsp; <span class="stsh_showing_header">Sort by</span>\
  4827. <br/> &nbsp; <input id="stsh_stat_sortBr" value="Branch" class="stsh_btn_long" type="button" /> \
  4828. <br/> &nbsp; <input id="stsh_stat_sortTr" value="Translated" class="stsh_btn_long" type="button" /> \
  4829. <br/> &nbsp; <input id="stsh_stat_sortAp" value="Approved" class="stsh_btn_long" type="button" /> \
  4830. <br/> \
  4831. <br/> &nbsp; <input id="stsh_stat_showAll" value="Show All" class="stsh_btn_long" type="button" /> \
  4832. </div> \
  4833. ';
  4834.  
  4835. var eleHideGame = document.querySelector("#stsh_stat_hideGame");
  4836. eleHideGame.addEventListener("click", function()
  4837. {
  4838. var elesProgress = document.querySelectorAll(".stsh_stat_progress:not(.stsh_hidden)");
  4839. for (var i = 0; i < elesProgress.length; i++)
  4840. {
  4841. if (elesProgress[i].dataset.br.indexOf("games/") === 0)
  4842. {
  4843. elesProgress[i].classList.add("stsh_hidden");
  4844. }
  4845. }
  4846. });
  4847. var eleHideSteam = document.querySelector("#stsh_stat_hideSteam");
  4848. eleHideSteam.addEventListener("click", function()
  4849. {
  4850. var elesProgress = document.querySelectorAll(".stsh_stat_progress:not(.stsh_hidden)");
  4851. for (var i = 0; i < elesProgress.length; i++)
  4852. {
  4853. if (elesProgress[i].dataset.br.indexOf("steam") === 0)
  4854. {
  4855. elesProgress[i].classList.add("stsh_hidden");
  4856. }
  4857. }
  4858. });
  4859. var eleHideApproved = document.querySelector("#stsh_stat_hideApproved");
  4860. eleHideApproved.addEventListener("click", function()
  4861. {
  4862. var elesProgress = document.querySelectorAll(".stsh_stat_progress:not(.stsh_hidden)");
  4863. for (var i = 0; i < elesProgress.length; i++)
  4864. {
  4865. if (elesProgress[i].dataset.tr === elesProgress[i].dataset.ap)
  4866. {
  4867. elesProgress[i].classList.add("stsh_hidden");
  4868. }
  4869. }
  4870. });
  4871. var eleHideCompleted = document.querySelector("#stsh_stat_hideCompleted");
  4872. eleHideCompleted.addEventListener("click", function()
  4873. {
  4874. var elesProgress = document.querySelectorAll(".stsh_stat_progress:not(.stsh_hidden)");
  4875. for (var i = 0; i < elesProgress.length; i++)
  4876. {
  4877. if (elesProgress[i].dataset.tr === "100" && elesProgress[i].dataset.ap === "100")
  4878. {
  4879. elesProgress[i].classList.add("stsh_hidden");
  4880. }
  4881. }
  4882. });
  4883. var eleShowAll = document.querySelector("#stsh_stat_showAll");
  4884. eleShowAll.addEventListener("click", function()
  4885. {
  4886. var eleHead = document.querySelector("#overall");
  4887. while (eleHead.firstChild)
  4888. {
  4889. var child = eleHead.firstChild;
  4890. if (child.classList && child.classList.contains("stsh_hidden"))
  4891. {
  4892. child.classList.remove("stsh_hidden");
  4893. }
  4894. eleHead.removeChild(eleHead.firstChild);
  4895. }
  4896. var i = keyIdArr.length - 1;
  4897. if (i > -1)
  4898. {
  4899. eleHead.appendChild(valDataArr[keyIdArr[i]]);
  4900. }
  4901. for (i--; i > -1; i--)
  4902. {
  4903. insertBeforeElement(valDataArr[keyIdArr[i]], eleHead.firstElementChild);
  4904. }
  4905. });
  4906. var eleSortBr = document.querySelector("#stsh_stat_sortBr");
  4907. eleSortBr.addEventListener("click", function()
  4908. {
  4909. var eleHead = document.querySelector("#overall");
  4910. if (eleHead)
  4911. {
  4912. while (eleHead.firstChild)
  4913. {
  4914. eleHead.removeChild(eleHead.firstChild);
  4915. }
  4916. var i = keyBrArr.length - 1;
  4917. if (i > -1)
  4918. {
  4919. eleHead.appendChild(valDataArr[valBrArr[keyBrArr[i]]]);
  4920. }
  4921. for (i--; i > -1; i--)
  4922. {
  4923. insertBeforeElement(valDataArr[valBrArr[keyBrArr[i]]], eleHead.firstElementChild);
  4924. }
  4925. }
  4926. });
  4927. var eleSortTr = document.querySelector("#stsh_stat_sortTr");
  4928. eleSortTr.addEventListener("click", function()
  4929. {
  4930. var eleHead = document.querySelector("#overall");
  4931. if (eleHead)
  4932. {
  4933. while (eleHead.firstChild)
  4934. {
  4935. eleHead.removeChild(eleHead.firstChild);
  4936. }
  4937. var i = keyTrArr.length - 1;
  4938. if (i > -1)
  4939. {
  4940. eleHead.appendChild(valDataArr[valTrArr[keyTrArr[i]]]);
  4941. }
  4942. for (i--; i > -1; i--)
  4943. {
  4944. insertBeforeElement(valDataArr[valTrArr[keyTrArr[i]]], eleHead.firstElementChild);
  4945. }
  4946. }
  4947. });
  4948. var eleSortAp = document.querySelector("#stsh_stat_sortAp");
  4949. eleSortAp.addEventListener("click", function()
  4950. {
  4951. var eleHead = document.querySelector("#overall");
  4952. if (eleHead)
  4953. {
  4954. while (eleHead.firstChild)
  4955. {
  4956. eleHead.removeChild(eleHead.firstChild);
  4957. }
  4958. var i = keyApArr.length - 1;
  4959. if (i > -1)
  4960. {
  4961. eleHead.appendChild(valDataArr[valApArr[keyApArr[i]]]);
  4962. }
  4963. for (i--; i > -1; i--)
  4964. {
  4965. insertBeforeElement(valDataArr[valApArr[keyApArr[i]]], eleHead.firstElementChild);
  4966. }
  4967. }
  4968. });
  4969. }
  4970. }, 100);
  4971. } // End statistics.php
  4972. if (url.indexOf("index.php") > -1 || url === "http://translation.steampowered.com/" || url === "https://translation.steampowered.com/")
  4973. {
  4974. var eleDes = document.querySelector("#verify-form > form");
  4975. if (eleDes)
  4976. {
  4977. var eleSpan = document.createElement("span");
  4978. eleSpan.classList.add("stsh_autoLoginOption");
  4979.  
  4980. var eleInput = document.createElement("input");
  4981. eleInput.id = "stsh_autoLogin";
  4982. eleInput.setAttribute("type", "checkbox");
  4983. eleInput.setAttribute("value", "auto");
  4984. function autoLogin()
  4985. {
  4986. var eleImage = document.querySelector("#verify-form > form > input[class='image']");
  4987. if (eleImage)
  4988. {
  4989. setTimeoutCustom(function()
  4990. {
  4991. var eleInput = document.querySelector("#stsh_autoLogin");
  4992. if (eleInput && eleInput.checked)
  4993. {
  4994. eleImage.click();
  4995. }
  4996. }, 3000);
  4997. }
  4998. }
  4999. if (GM_getValue("autoLogin", 0) == "true")
  5000. {
  5001. eleInput.checked = true;
  5002. autoLogin();
  5003. }
  5004.  
  5005. eleInput.addEventListener("click", function (e)
  5006. {
  5007. var ele = e.target;
  5008. if (ele.checked)
  5009. {
  5010. GM_setValue("autoLogin", "true");
  5011. autoLogin();
  5012. }
  5013. else
  5014. {
  5015. GM_setValue("autoLogin", "false");
  5016. }
  5017. });
  5018.  
  5019. var eleLabel = document.createElement("label");
  5020. eleLabel.setAttribute("for", "stsh_autoLogin");
  5021. eleLabel.textContent = " Auto Login";
  5022.  
  5023. eleSpan.appendChild(eleInput);
  5024. eleSpan.appendChild(eleLabel);
  5025. eleDes.appendChild(eleSpan);
  5026. }
  5027. } // End index.php
  5028. if (url.indexOf("try_auth.php") > -1)
  5029. {
  5030. setTimeoutCustom(function()
  5031. {
  5032. document.forms[0].submit();
  5033. }, 3000);
  5034. } // End try_auth.php
  5035. window.addEventListener("beforeunload", function (e)
  5036. {
  5037. clearTimeoutAll();
  5038. clearIntervalAll();
  5039. });
  5040. } // End Main
  5041.  
  5042. function client()
  5043. {
  5044. var clientScript = ' \
  5045. \
  5046. \
  5047. var timeoutList = new Array(); \
  5048. var intervalList = new Array(); \
  5049. \
  5050. function setTimeoutCustom(func, tm, params) \
  5051. { \
  5052. var id = setTimeout(func, tm, params); \
  5053. timeoutList.push(id); \
  5054. return id; \
  5055. } \
  5056. \
  5057. function clearTimeoutAll() \
  5058. { \
  5059. for (var i = 0; i < timeoutList.length; i++) \
  5060. { \
  5061. clearTimeout(timeoutList[i]); \
  5062. } \
  5063. } \
  5064. \
  5065. function setIntervalCustom(func, tm, params) \
  5066. { \
  5067. var id = setInterval(func, tm, params); \
  5068. intervalList.push(id); \
  5069. return id; \
  5070. } \
  5071. \
  5072. function clearIntervalAll() \
  5073. { \
  5074. for (var i = 0; i < intervalList.length; i++) \
  5075. { \
  5076. clearInterval(intervalList[i]); \
  5077. } \
  5078. } \
  5079. \
  5080. function scrollToId(id, offset) \
  5081. { \
  5082. scrollToElement("#" + id, offset); \
  5083. } \
  5084. \
  5085. function scrollToElement(selector, offset) \
  5086. { \
  5087. if (typeof offset === "undefined") \
  5088. { \
  5089. offset = -20; \
  5090. } \
  5091. \
  5092. var ele = document.querySelector(selector); \
  5093. if (ele) \
  5094. { \
  5095. ele.scrollIntoView(true); \
  5096. window.scrollBy(0, offset); \
  5097. } \
  5098. } \
  5099. \
  5100. function setVisibleSuggestion(visible) \
  5101. { \
  5102. var display = visible !== true ? "none" : ""; \
  5103. var eles = document.querySelectorAll(".copy"); \
  5104. for (var i = 0; i < eles.length; i++) \
  5105. { \
  5106. if (eles[i].id && eles[i].id.indexOf("showwalletkeys") < 0 \
  5107. && eles[i].id !== "abuse_report" \
  5108. && eles[i].id !== "moderator_announcement") \
  5109. { \
  5110. if (eles[i].style.display !== display) \
  5111. { \
  5112. eles[i].style.display = display; \
  5113. } \
  5114. } \
  5115. } \
  5116. } \
  5117. \
  5118. function showSuggestion() \
  5119. { \
  5120. setVisibleSuggestion(true); \
  5121. } \
  5122. \
  5123. function hideSuggestion() \
  5124. { \
  5125. setVisibleSuggestion(false); \
  5126. } \
  5127. \
  5128. function pressHideSuggestion() \
  5129. { \
  5130. document.addEventListener("keydown", function(e) { \
  5131. if (e.keyCode == 27) { \
  5132. if (parent) \
  5133. { \
  5134. parent.hideSuggestionsBox(); \
  5135. } \
  5136. else \
  5137. { \
  5138. hideSuggestionsBox(); \
  5139. } \
  5140. } \
  5141. return false; \
  5142. }); \
  5143. } \
  5144. pressHideSuggestion(); \
  5145. \
  5146. function clickToSelect(ele) \
  5147. { \
  5148. var range = document.createRange(); \
  5149. range.setStartBefore(ele.firstChild); \
  5150. range.setEndAfter(ele.lastChild); \
  5151. var sel = window.getSelection(); \
  5152. sel.removeAllRanges(); \
  5153. sel.addRange(range); \
  5154. } \
  5155. \
  5156. \
  5157. function syncUrlArray() \
  5158. { \
  5159. var strStart = "showSuggestionsBox( \'"; \
  5160. var strEnd = "\' ); return false;"; \
  5161. var strCur = "&list_id="; \
  5162. var strAll = "&endnext="; \
  5163. var regPos = /&list_id=\\d+&endnext=\\d+/g; \
  5164. var isEdit = false; \
  5165. var eleDivs = []; \
  5166. var urls = []; \
  5167. \
  5168. var pattUrlTimestamp2 = /\\&t=[0-9]{6,}/g; \
  5169. var pattUrlTimestamp4 = /\\&[0-9]{6,}\\&/g; \
  5170. \
  5171. var trKeys = document.querySelectorAll("#keylist > table:nth-child(1) > tbody:nth-child(1) > tr"); \
  5172. for (var i = 0; i < trKeys.length; i++) \
  5173. { \
  5174. if (!trKeys[i].classList.contains("stsh_hidden")) \
  5175. { \
  5176. var eleDiv = trKeys[i].childNodes[0].childNodes[0]; \
  5177. if (typeof eleDiv.getAttribute !== "undefined" \
  5178. && eleDiv.getAttribute("onclick")) \
  5179. { \
  5180. eleDivs.push(eleDiv); \
  5181. } \
  5182. } \
  5183. } \
  5184. \
  5185. for (var i = 0, l = eleDivs.length; i < l; i++) \
  5186. { \
  5187. var evOld = eleDivs[i].getAttribute("onclick"); \
  5188. if (evOld) \
  5189. { \
  5190. var url = evOld.replace(strStart,"").replace(strEnd,"").replace(regPos,""); \
  5191. url = url + strCur + i + strAll + l; \
  5192. \
  5193. if (pattUrlTimestamp2.test(url)) \
  5194. { \
  5195. url = url.replace(pattUrlTimestamp2,""); \
  5196. } \
  5197. if (pattUrlTimestamp4.test(url)) \
  5198. { \
  5199. url = url.replace(pattUrlTimestamp4,"&"); \
  5200. } \
  5201. \
  5202. urls.push(url); \
  5203. \
  5204. var evNew = strStart + url + strEnd; \
  5205. if (evOld != evNew) \
  5206. { \
  5207. eleDivs[i].setAttribute("onclick", evNew); \
  5208. isEdit = true; \
  5209. } \
  5210. } \
  5211. } \
  5212. \
  5213. if (isEdit || typeof URLarray === "undefined" || URLarray.length !== urls.length) \
  5214. { \
  5215. URLarray = urls; \
  5216. } \
  5217. } \
  5218. \
  5219. function setFrameColor(color) \
  5220. { \
  5221. var frame = document.querySelector("div#suggestions_box iframe"); \
  5222. if (frame) \
  5223. { \
  5224. if (frame.style.backgroundColor != color) \
  5225. { \
  5226. frame.style.setProperty("background-color", color, "important"); \
  5227. } \
  5228. } \
  5229. } \
  5230. \
  5231. function padZero(num, size) \
  5232. { \
  5233. return (1e15+num+"").slice(-size); \
  5234. } \
  5235. \
  5236. function doInstant() \
  5237. { \
  5238. var url = document.documentURI; \
  5239. if (url.indexOf("user_activity.php") > -1) \
  5240. { \
  5241. if (typeof $ !== "undefined") \
  5242. { \
  5243. $(".dial").css("display", "none"); \
  5244. } \
  5245. setTimeoutCustom(function() \
  5246. { \
  5247. if (typeof $ !== "undefined") \
  5248. { \
  5249. /* Restore drawing progress */ \
  5250. $(".dial").css("display", ""); \
  5251. $(".dial").knob( \
  5252. { \
  5253. "draw": function() \
  5254. { \
  5255. $(this.i).val(this.cv + "%"); \
  5256. } \
  5257. }); \
  5258. } \
  5259. }, 500); \
  5260. \
  5261. showSuggestion(); \
  5262. \
  5263. /* Fix STS JS error */ \
  5264. setTimeoutCustom(function() \
  5265. { \
  5266. if (typeof hide_list === "undefined") \
  5267. { \
  5268. hide_list = function() { console.log("hide_list"); }; \
  5269. } \
  5270. }, 1000); \
  5271. } \
  5272. else if (url.indexOf("translate.php") > -1) \
  5273. { \
  5274. getsuggestionURL = function(urlno) \
  5275. { \
  5276. /* Overwrite STS to remove timestamp */ \
  5277. return URLarray[urlno]; \
  5278. }; \
  5279. \
  5280. var target = document.getElementById("keylist_container"); \
  5281. if (target) \
  5282. { \
  5283. var tmObSync = -1; \
  5284. var observer = new MutationObserver(function(mutations) \
  5285. { \
  5286. mutations.forEach(function(mutation) \
  5287. { \
  5288. if (mutation.type !== "attributes" \
  5289. || mutation.target.tagName === "TR") \
  5290. { \
  5291. clearTimeout(tmObSync); \
  5292. tmObSync = setTimeoutCustom(function() \
  5293. { \
  5294. syncUrlArray(); \
  5295. /*console.log("syncUrlArray: " + tmObSync);*/ \
  5296. }, 50); \
  5297. } \
  5298. }); \
  5299. }); \
  5300. \
  5301. var config = { childList: true, subtree: true, attributes: true, attributeFilter: ["class"] }; \
  5302. observer.observe(target, config); \
  5303. } \
  5304. \
  5305. /* Fix STS JS error */ \
  5306. setTimeoutCustom(function() \
  5307. { \
  5308. if (typeof getendnext === "undefined") \
  5309. { \
  5310. getendnext = function() { console.log("getendnext"); return ""; }; \
  5311. } \
  5312. }, 1000); \
  5313. } \
  5314. else if (url.indexOf("suggestions.php") > -1) \
  5315. { \
  5316. if (parent !== window) \
  5317. { \
  5318. var main = document.querySelector("#suggestionmain"); \
  5319. if (main) \
  5320. { \
  5321. var styleCp = window.getComputedStyle(main); \
  5322. if (styleCp) \
  5323. { \
  5324. var color = styleCp.backgroundColor; \
  5325. parent.setFrameColor(color); \
  5326. } \
  5327. } \
  5328. } \
  5329. } \
  5330. \
  5331. window.addEventListener("beforeunload", function (e) \
  5332. { \
  5333. clearTimeoutAll(); \
  5334. clearIntervalAll(); \
  5335. }); \
  5336. \
  5337. } \
  5338. doInstant(); \
  5339. \
  5340. ';
  5341.  
  5342. var eleClientScript = document.createElement("script");
  5343. eleClientScript.innerHTML = clientScript;
  5344. document.head.appendChild(eleClientScript);
  5345. } // End client
  5346.  
  5347. attachOnReady(initStyle);
  5348. attachOnReady(client);
  5349. attachOnReady(main);
  5350.  
  5351.  
  5352. })();
  5353.  
  5354. // End