- // ==UserScript==
- // @name STS Helper
- // @namespace iFantz7E.StsHelper
- // @version 1.76
- // @description In Steam Translation Server, add many features to make translate easier.
- // @match *://translation.steampowered.com/*
- // @icon http://translation.steampowered.com/public/favicon.ico
- // @run-at document-start
- // @grant GM_getValue
- // @grant GM_setValue
- // @grant GM_addStyle
- // @copyright 2014, 7-elephant
- // ==/UserScript==
-
- // http://userscripts.org/scripts/show/325610
- // https://greasyfork.org/scripts/2250-sts-helper/
-
- GM_addStyle(
- " #logout { position: fixed; z-index: 1001; right: 12px; top: 10px; line-height: 24px; text-align: right; } "
- + "input[type='button'], input[type='submit'] { cursor: pointer; } "
- + "input[type='button']:disabled { cursor: default; color: #777; } "
- + "#suggestionmain { overflow-x: hidden; } "
- + "#suggestionmain > div:nth-child(4) > form:nth-child(2) > div:nth-child(1) "
- + " { text-align: left; } "
- + ".lbAction > div > input[value^='SUBMIT'] "
- + " { width: 97%; height: 30px; } "
- + "form.lbAction:nth-child(1) > div:nth-child(2) > input:nth-child(1) "
- + " { width: 90%; margin-top: 5px; } "
- + "div.suggestion form.lbAction textarea"
- + " { width: 700px !important; min-height: 50px; } "
- + ".progress td { vertical-align: top; } "
- + "div#suggestions_nav { z-index: 3; position: absolute; width: 525px; left: 463px; top: 4px; text-align: right; line-height: 24px; } "
- + "#suggestionmain .smallcopy { width: 855px; min-height: 70px; max-height: 70px; overflow: hidden; } "
- + "#suggestionmain .progress { margin-top: -12px; } "
- + "#leftAreaContainer > table > tbody:nth-child(1) > tr > td:nth-child(1) { vertical-align: top; } "
- + "#leftAreaContainer > table, #leftAreaContainer > table th, #leftAreaContainer > table td "
- + " { border: 1px solid #333; border-collapse: collapse; padding: 4px; } "
- + "#suggestions_box { margin-top: 1px !important; } "
- + "#suggestions_iframe { min-height: 100px !important; } "
- + "#keylist td:nth-child(1) > div { background-image: none !important; min-height: 43px; } "
- + "#keylist tr:nth-child(2n) > td:nth-child(1) > div { background-color: #060606 !important; } "
- + "#keylist tr:nth-child(2n) > td:nth-child(1) > div:hover { background-color: #0D0D0D !important; } "
- + "#keylist td:nth-child(1) > div:hover "
- + " { background-repeat: no-repeat; background-position: center; background-color: #0D0D0D !important; "
- + " background-image: url('./public/images/row_over.gif') !important; "
- + " } "
- + ".progress h1 { display: inline-block; width: 484px; } "
- + "div#suggestions_box iframe { background-color: #111 !important; } "
- + ".suggestions_list { border-right: 0px none !important; } "
- + ".suggestion { resize: both; overflow: hidden; border-right: 1px solid #505050; } "
- + ".suggestion_signature { font-family: Verdana; } "
- + ".suggestion_signature input[value~='APPROVE'], .suggestion_signature input[value~='Next'] { color: #A4B23C } "
- + ".suggestion_signature input[value~='DECLINE'], .suggestion_signature input[value~='Next']:nth-child(5) { color: #F22 } "
- + ".suggestion_signature input[disabled='disabled'] { color: #777 !important; } "
- + ".lbAction input[value~='COMMENT'] { vertical-align: top; margin-top: 1px; height: 52px; } "
- + ".lbAction input[value~='DISCUSS'] { vertical-align: top; margin-top: 1px; height: 36px; } "
- + "#votes_container a[title='not translated'] { background-color: #333; } "
- + ".stsh_btn { width: 90px; } "
- + ".stsh_btn_med { min-width: 112px; } "
- + ".stsh_btn_long { min-width: 136px; } "
- + ".stsh_btn_short { min-width: 66px; } "
- + ".stsh_btn_right { position: relative; float: right; } "
- + ".stsh_suggestion_header { color: #A4B23C; } "
- + ".stsh_suggestion_comment:before { background-color: #CF8B37 !important; } "
- + ".stsh_suggestion_pending:before { background-color: #FFF !important; } "
- + ".stsh_suggestion_approved:before { background-color: #A4B23C !important; } "
- + ".stsh_suggestion_declined:before { background-color: red !important; } "
- + ".stsh_suggestion_applied:before { background-color: #2EBCEB !important; } "
- + ".stsh_suggestion_removed:before { background-color: #555 !important; } "
- + ".stsh_suggestion { list-style: none; } "
- + ".stsh_suggestion:before "
- + " { content: ''; display: inline-block; position: relative; height: 6px; width: 6px; "
- + " border-radius: 3px; background-clip: padding-box; margin-right: -6px; top: -1px; left: -12px; background-color: green; }"
- + "#stsh_frame { text-align: center; } "
- + ".stsh_blue { color: #2ebceb; } "
- + ".stsh_green { color: #a4b23c; } "
- + ".stsh_red { color: #F00; } "
- + ".stsh_white { color: #fff; } "
- + ".stsh_orange { color: #CF8B37; } "
- + ".stsh_pink { color: pink; } "
- + "#stsh_showing { color: #CCDAD6; position: fixed; z-index: 1001; right: 12px; bottom: 12px; text-align: right; line-height: 14px;} "
- + "#stsh_showing_current { color: #CCDAD6; position: fixed; z-index: 1001; right: 12px; bottom: 28px; text-align: right; line-height: 14px;} "
- + ".stsh_showing_counter { display: inline-block; min-width: 60px; text-align: center; } "
- + ".stsh_showing_header { color: #CCDAD6; display: inline-block; width: 135px; text-align: center; padding-top: 10px; } "
- + ".stsh_showing_group { position: fixed; z-index: 3; right: 10px; top: 74px; line-height: 24px; text-align: right; } "
- + ".stsh_home_header { color: #CCDAD6; display: inline-block; padding-top: 10px; } "
- + ".stsh_home_group { position: fixed; z-index: 3; right: 0px; top: 74px; line-height: 24px; text-align: center; width: 164px; } "
- + ".stsh_scroll_header { color: #CCDAD6; display: inline-block; width: 130px; text-align: center; padding-top: 10px; } "
- + "#stsh_specialEvent { position: absolute; z-index: 2; right: 164px; top: 11px; } "
- + ".stsh_snapshot { position: absolute; top: 320px; left: 790px; width: 140px; text-align: center; color: #FFF; } "
- + ".stsh_submit_comment_header { vertical-align: top; } "
- + ".stsh_submit_comment { vertical-align: top; display: inline-block } "
- + ".stsh_insert_space { margin: 10px; } "
- + "#stsh_autoApprove { vertical-align: -2px; margin-left: 15px; margin-right: 1px; } "
- + ".stsh_unselectable { -webkit-user-select: none; -moz-user-select: none; user-select: none; } "
- + ".stsh_a_button "
- + " { background-color: #1D1D1D; font-family: tahoma,arial,helvetica,trebuchet ms,sans-serif; "
- + " color: #E1E1E1; font-size: 13px; border: 1px solid #777; padding: 1px 9px; } "
- + ".stsh_a_button:link, .stsh_a_button:hover, .stsh_a_button:active, .stsh_a_button:visited { color: #E1E1E1; text-decoration: none; } "
- + ".stsh_a_button.stsh_btn { display: inline-block; padding: 0px; height: 19px; line-height: 19px; width: 88px; } "
- + ".stsh_a_button.stsh_btn_med { display: inline-block; padding: 0px; height: 19px; line-height: 19px; min-width: 110px; } "
- + ".stsh_a_button.stsh_btn_long { display: inline-block; padding: 0px; height: 19px; line-height: 19px; min-width: 134px; } "
- + ".stsh_lineCounter_outer { position: relative; } "
- + ".stsh_lineCounter "
- + " { position: absolute; width: 30px; left: -35px; top: -28px; line-height: 28px; text-align: right; "
- + " color: #ACACAC; font-size: 9px; } "
- + ".stsh_glossary_term { min-width: 50px; display: inline-block; } "
- + ".stsh_glossary_header, .stsh_glossary_header td { color: #DDD; } "
- + ".stsh_glossary_header *, .stsh_glossary_header td * { color: #858585; } "
- + ".stsh_time_convert { cursor: pointer; } "
- + ".stsh_comment_img "
- + " { display: block; cursor: zoom-in; cursor: -webkit-zoom-in; cursor: -moz-zoom-in; "
- + " max-width: 400px; margin-top: 5px; margin-bottom: 20px; } "
- );
-
- function attachOnLoad(callback)
- {
- window.addEventListener("load", function (e)
- {
- callback();
- });
- }
-
- function attachOnReady(callback)
- {
- document.addEventListener("DOMContentLoaded", function (e)
- {
- callback();
- });
- }
-
- function insertBeforeElement(newNode, referenceNode)
- {
- referenceNode.parentNode.insertBefore(newNode, referenceNode);
- }
-
- function insertAfterElement(newNode, referenceNode)
- {
- referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
- }
-
- function addKeyCtrl(ele, input, keyCode, keyName)
- {
- if (ele != null && input != null)
- {
- //if (input.getAttribute("disabled") == null)
- // return;
-
- if (keyName != null && keyName != "")
- {
- input.value += " (Ctrl+" + keyName + ")";
- }
-
- ele.addEventListener("keydown", function (e)
- {
- if (e.ctrlKey)
- {
- var isSameKey = false;
- if (Number.isInteger(keyCode))
- {
- isSameKey = (e.keyCode == keyCode);
- }
- else
- {
- isSameKey = (e.code != undefined && e.code == keyCode)
- }
-
- if (isSameKey)
- {
- input.focus();
- input.click();
- return false;
- }
- }
- }, true);
- }
- }
-
- function addKeyAlt(ele, input, keyCode, keyName)
- {
- if (ele != null && input != null)
- {
- if (keyName != null && keyName != "")
- {
- input.value += " (Alt+" + keyName + ")";
- }
-
- ele.addEventListener("keydown", function (e)
- {
- if (e.altKey)
- {
- var isSameKey = false;
- if (Number.isInteger(keyCode))
- {
- isSameKey = (e.keyCode == keyCode);
- }
- else
- {
- isSameKey = (e.code != undefined && e.code == keyCode)
- }
-
- if (isSameKey)
- {
- input.focus();
- input.click();
- return false;
- }
- }
- }, true);
- }
- }
-
- function addKeyCtrlEnter(form, input)
- {
- addKeyCtrl(form, input, 13, "Enter")
- }
-
- function disableAfterClick(ele)
- {
- ele.addEventListener("click", function (e)
- {
- var ele = e.target;
- var tagName = ele.tagName.toLowerCase();
- if (tagName == "input")
- {
- // don't change color after disable
- ele.style.setProperty("color"
- , window.getComputedStyle(ele).color, "important");
- ele.disabled = true;
- }
- else if (tagName == "img")
- {
- ele.removeAttribute("onclick");
- }
- }, true);
- }
-
- function resizeSuggestionBox()
- {
- var script = document.createElement('script');
- script.innerHTML = " \
- var stsh_showSuggestionsBox_start = new Date(); \
- var stsh_showSuggestionsBox_itv = setIntervalCustom(function() \
- { \
- var stsh_showSuggestionsBox_isEnd = false; \
- var stsh_showSuggestionsBox_cur = new Date(); \
- if (typeof showSuggestionsBox != 'undefined') \
- { \
- showSuggestionsBox = function(url) \
- { \
- g_suggestionsBoxIsOpen = true; \
- $('suggestions_box_outer').appear( \
- { \
- duration : 0.1 \
- } \
- ); \
- $('suggestions_iframe').setAttribute('src', url); \
- if (!Prototype.Browser.IE) \
- { \
- $('suggestions_iframe').focus(); \
- } \
- $('suggestions_iframe').style.height = (document.viewport.getHeight() * 0.99) + 'px'; \
- return false; \
- }; \
- stsh_showSuggestionsBox_isEnd = true; \
- } \
- if (stsh_showSuggestionsBox_isEnd || stsh_showSuggestionsBox_cur - stsh_showSuggestionsBox_start > 10000) \
- { \
- clearInterval(stsh_showSuggestionsBox_itv); \
- } \
- }, 300); \
- ";
-
- document.head.appendChild(script);
-
- window.addEventListener("resize", function()
- {
- var iframe = document.querySelector("#suggestions_iframe");
- iframe.style.height = (window.innerHeight * 0.99) + "px";
- });
- }
-
- function getQueryByName(name, url)
- {
- if (url == null)
- url = location.search;
- name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
- var regex = new RegExp("[\\?&]" + name + "=([^&#]*)");
- var results = regex.exec(url);
- var retVal = "";
- if (results != null)
- {
- retVal = results[1].replace(/\+/g, " ");
- try
- {
- retVal = decodeURIComponent(retVal);
- }
- catch (ex)
- {
- }
- }
- return retVal;
- }
-
- function padZero(num, size)
- {
- return (1e15+num+"").slice(-size);
- }
-
- function checkSpecialCharMatched(str1, str2)
- {
- // return (status, numSp1, numSp2)
- // status: 0:Match, 1:NotMatch, 2:NotEqual
-
- var sp1 = "";
- var sp2 = "";
- var sp3 = "";
- var sp4 = "";
- var sp5 = "";
- var sp6 = "";
- var sp7 = "";
- var sp8 = "";
-
- var strOut1 = "";
- var strOut2 = "";
-
- if (str1 != null && str2 != null)
- {
- for (var i = 0; i < str1.length; i++)
- {
- if (str1[i] == sp1 || str1[i] == sp2 || str1[i] == sp3 || str1[i] == sp4
- || str1[i] == sp5 || str1[i] == sp6 || str1[i] == sp7 || str1[i] == sp8)
- {
- strOut1 += str1[i];
- }
- }
- for (var i = 0; i < str2.length; i++)
- {
- if (str2[i] == sp1 || str2[i] == sp2 || str2[i] == sp3 || str2[i] == sp4
- || str2[i] == sp5 || str2[i] == sp6 || str2[i] == sp7 || str2[i] == sp8)
- {
- strOut2 += str2[i];
- }
- }
- }
-
- var retVal = 0;
-
- if (strOut1 == strOut2)
- retVal = 0;
- else if (strOut1.length == strOut2.length)
- retVal = 1;
- else
- retVal = 2;
-
- return new Array(retVal, strOut1.length, strOut2.length);
- }
-
- if (!String.prototype.endsWith)
- {
- String.prototype.endsWith = function(searchString, position)
- {
- var subjectString = this.toString();
- if (typeof position !== 'number' || !isFinite(position)
- || Math.floor(position) !== position || position > subjectString.length)
- {
- position = subjectString.length;
- }
- position -= searchString.length;
- var lastIndex = subjectString.indexOf(searchString, position);
- return lastIndex !== -1 && lastIndex === position;
- };
- }
-
- function reload()
- {
- window.location = window.location.href;
- }
-
- function getCookie(c_name) {
- var c_value = document.cookie;
- var c_start = c_value.indexOf(" " + c_name + "=");
- if (c_start == -1) {
- c_start = c_value.indexOf(c_name + "=");
- }
- if (c_start == -1) {
- c_value = null;
- }
- else {
- c_start = c_value.indexOf("=", c_start) + 1;
- var c_end = c_value.indexOf(";", c_start);
- if (c_end == -1) {
- c_end = c_value.length;
- }
- c_value = unescape(c_value.substring(c_start, c_end));
- }
- return c_value;
- }
-
- var isVisible = (function()
- {
- var stateKey;
- var eventKey;
- var keys =
- {
- hidden: "visibilitychange",
- webkitHidden: "webkitvisibilitychange",
- mozHidden: "mozvisibilitychange",
- msHidden: "msvisibilitychange"
- };
- for (stateKey in keys)
- {
- if (stateKey in document)
- {
- eventKey = keys[stateKey];
- break;
- }
- }
- return function(c)
- {
- if (c)
- {
- document.addEventListener(eventKey, c);
- }
- return !document[stateKey];
- }
- })();
-
- function isDstUsa(year, month, day, hour)
- {
- // 2016, 3, 1, 15 == 1 Mar 2016 15:00
-
- var isDst = false;
- try
- {
- var y = parseInt(year);
- var m = parseInt(month);
- var d = parseInt(day);
- var h = parseInt(hour);
-
- function checkDstUsa(dayMar, dayNov, m, d, h)
- {
- var isDst = false;
- if ((m == 3 && d >= dayMar) || (m > 3 && m < 11) || (m == 11 && d <= dayNov))
- isDst = true;
- if ((m == 3 && d == dayMar && h < 2) || (m == 11 && d == dayNov && h >= 2))
- isDst = false;
- return isDst;
- }
-
- if (y == 2007 || y == 2012 || y == 2018 || y == 2029)
- {
- isDst = checkDstUsa(11, 4, m, d, h);
- }
- else if (y == 2013 || y == 2019 || y == 2024)
- {
- isDst = checkDstUsa(10, 3, m, d, h);
- }
- else if (y == 2008 || y == 2014 || y == 2025)
- {
- isDst = checkDstUsa(9, 2, m, d, h);
- }
- else if (y == 2009 || y == 2015 || y == 2020 || y == 2026)
- {
- isDst = checkDstUsa(8, 1, m, d, h);
- }
- else if (y == 2010 || y == 2021 || y == 2027)
- {
- isDst = checkDstUsa(14, 7, m, d, h);
- }
- else if (y == 2011 || y == 2016 || y == 2022)
- {
- isDst = checkDstUsa(13, 6, m, d, h);
- }
- else if (y == 2017 || y == 2023 || y == 2028)
- {
- isDst = checkDstUsa(12, 5, m, d, h);
- }
-
- }
- catch (ex)
- {
- }
- return isDst;
- }
-
- function getUnixTimestamp()
- {
- return parseInt((new Date()) / 1000);
- }
-
- var timeoutList = new Array();
- var intervalList = new Array();
-
- function setTimeoutCustom(func, tm, params)
- {
- var id = setTimeout(func, tm, params);
- timeoutList.push(id);
- return id;
- }
-
- function clearTimeoutAll()
- {
- for (var i = 0; i < timeoutList.length; i++)
- {
- clearTimeout(timeoutList[i]);
- }
- }
-
- function setIntervalCustom(func, tm, params)
- {
- var id = setInterval(func, tm, params);
- intervalList.push(id);
- return id;
- }
-
- function clearIntervalAll()
- {
- for (var i = 0; i < intervalList.length; i++)
- {
- clearInterval(intervalList[i]);
- }
- }
-
- function main()
- {
- var url = document.documentURI;
- var lang = getCookie("Language");
-
- // Auto refresh when error
- {
- var h1 = document.querySelector("#leftAreaContainer > h1, body > h1");
- if (h1 != null)
- {
- var text = h1.textContent.trim();
- if (text == "Steam Translation Server - Maintenance Warning"
- || text == "Forbidden")
- {
- console.log("stsh: refresh");
- setTimeoutCustom(reload, 60000);
- return;
- }
- }
- }
-
- // Clean links
- {
- var pattT1 = /\?t=[0-9]{6,}\&/g;
- var pattT2 = /\&t=[0-9]{6,}/g;
- var pattT3 = /\?t=[0-9]{6,}/g;
-
- var as = document.querySelectorAll("a");
- for (var i = 0; i < as.length; i++)
- {
- var href = as[i].href;
- if (pattT1.test(href))
- {
- as[i].href = href.replace(pattT1,"?");
- }
- else if (pattT2.test(href))
- {
- as[i].href = href.replace(pattT2,"");
- }
- else if (pattT3.test(href))
- {
- as[i].href = href.replace(pattT3,"");
- }
- }
- }
-
- var eleLogout = document.querySelector("#logout");
- if (eleLogout != null)
- {
- var logoutHtml = ' <a class="stsh_a_button" target="_blank" '
- + ' href="/user_activity.php">My Profile</a> '
- + ' <input name="login_button" value="Logout?" type="submit" onmouseup="return confirm(\'Logout?\');" /> ';
-
- eleLogout.innerHTML = logoutHtml;
- }
-
- // Special event button
- {
- var eleLogoff = document.querySelector("#logoff");
- if (eleLogoff != null)
- {
- var d = new Date();
- if ((d.getUTCMonth() > 8) || (d.getUTCMonth() == 8 && d.getUTCDate() >= 25) || (d.getUTCMonth() == 0 && d.getUTCDate() <= 1))
- {
- var divSpecial = document.createElement("div");
- divSpecial.id = "stsh_specialEvent";
- divSpecial.innerHTML = ' <a class="stsh_a_button" target="_blank" '
- + ' href="/rally.php">Year-End Rally</a> ';
- eleLogoff.appendChild(divSpecial);
- }
- }
- }
-
- if (url.indexOf("Us_And_Them.php") > -1)
- {
- var container = "\"";
- var tdEng = document.querySelector("#leftAreaContainer > table > tbody:nth-child(1) > tr:nth-child(1) > td:nth-child(2)");
- if (tdEng != null)
- {
- tdEng.innerHTML = container + tdEng.innerHTML + container;
- }
-
- var h1 = document.querySelector("#leftAreaContainer > h1:nth-child(2)");
- if (h1 != null)
- {
- var header = h1.textContent.trim();
- var key = header.split(" ")[0];
- h1.innerHTML = header.replace(key, "<a href='http://translation.steampowered.com/translate.php?keyonly=1&search_input="
- + encodeURIComponent(key) + "' >" + key + "</a>");
- document.title = key + " - " + document.title;
- }
-
- } // End Us_And_Them.php
-
- if (url.indexOf("suggestions.php") > -1)
- {
- var ele = document.querySelector("#suggestion_value_new");
- if (ele != null)
- {
- ele.style.width = "960px";
- ele.style.height = "64px";
- ele.style.marginLeft = "3px";
- }
-
- var inputClose = document.querySelector("#suggestions_nav > input[value^='Close']");
- if (inputClose != null)
- {
- inputClose.value = "Close (Esc)";
- }
-
- // Move region
- {
- var td = document.querySelector(".progress tr:last-child > td:nth-child(3)");
- if (td != null && td.textContent.trim() == "")
- {
- function moveSuggestionBox()
- {
- var td = document.querySelector(".progress tr:last-child > td:nth-child(3)");
- if (td != null && td.textContent.trim() == "")
- {
- td.innerHTML = "";
- var eleTarget = document.querySelector("#suggestionmain > div:nth-child(4) > .lbAction");
- if (eleTarget != null)
- {
- td.appendChild(eleTarget);
- td.style.padding = "0px";
-
- var textarea = document.querySelector("#suggestion_value_new");
- if (textarea != null)
- {
- textarea.style.width = "98%";
- textarea.style.marginLeft = "0px";
- textarea.style.height = (textarea.scrollHeight + 20) + "px";
- textarea.focus();
- }
- }
- }
- }
-
- function moveSuggestionList()
- {
- var td = document.querySelector(".progress tr:last-child > td:nth-child(3)");
- if (td != null && td.textContent.trim() == "")
- {
- td.innerHTML = "";
- var eleTarget = document.querySelector(".suggestion");
- if (eleTarget != null)
- {
- td.appendChild(eleTarget);
- td.style.padding = "0px";
-
- eleTarget.style.marginTop = "-2px";
- eleTarget.style.paddingTop = "0px";
- eleTarget.style.borderBottomWidth = "0px";
- eleTarget.style.borderRightWidth = "0px";
- eleTarget.style.resize = "none";
-
- var eleAutoApprove = document.querySelector("#stsh_autoApprove");
- if (eleAutoApprove != null)
- {
- eleAutoApprove.style.display = "none";
- }
-
- var eleAutoApproveLabel = document.querySelector(".stsh_autoApprove_label");
- if (eleAutoApproveLabel != null)
- {
- eleAutoApproveLabel.style.display = "none";
- }
- }
- }
- }
-
- var eleMoveBox = document.createElement("input");
- eleMoveBox.id = "stsh_moveSuggestionBox";
- eleMoveBox.setAttribute("value", "Move Box Here");
- eleMoveBox.setAttribute("type", "button");
- eleMoveBox.style.marginRight = "5px";
-
- eleMoveBox.addEventListener("click", function(e)
- {
- moveSuggestionBox();
- });
-
- td.appendChild(eleMoveBox);
-
- var eleMoveList = document.createElement("input");
- eleMoveList.id = "stsh_moveSuggestionList";
- eleMoveList.setAttribute("value", "Move Suggestion Here");
- eleMoveList.setAttribute("type", "button");
- eleMoveList.style.marginRight = "5px";
-
- eleMoveList.addEventListener("click", function(e)
- {
- moveSuggestionList();
- });
-
- td.appendChild(eleMoveList);
- }
- }
-
- var textarea = document.querySelector("#suggestion_value_new");
- if (textarea != null)
- {
- textarea.focus();
- textarea.style.height = (textarea.scrollHeight + 20) + "px";
-
- if (textarea.scrollHeight > 200 && document.querySelector(".suggestion") != null)
- {
- textarea.scrollIntoView();
- }
- }
-
- var br = document.querySelector("form.lbAction:nth-child(2) > div:nth-child(2) > br:nth-child(1)");
- if (br != null)
- {
- br.parentElement.removeChild(br);
- }
-
- var key = "";
-
- var divNav = document.querySelector("div#suggestions_nav");
- if (divNav != null)
- {
- var insert = "";
- var spliter = "_";
- var regApp = /[0-9]{2,}/;
-
- var aKey = document.querySelector(".smallcopy > font:nth-child(2) > a:nth-child(1)");
- if (aKey != null)
- {
- insert += ' <br/> ';
- key = encodeURIComponent(aKey.textContent.trim());
-
- if (key == "token-key")
- {
- aKey = document.querySelector(".smallcopy > a:nth-child(3)");
- if (aKey != null)
- {
- key = encodeURIComponent(aKey.textContent.trim());
- }
- }
-
- if (key != "")
- {
- document.title = key + " - " + document.title;
-
- if (key.split(spliter).length > 1)
- {
- if (key.indexOf("%23") == 0)
- {
- var firstSpliter = key.indexOf(spliter);
- var keySharp = key.substring(0, firstSpliter);
- insert += ' <a class="stsh_a_button" target="_blank" '
- + ' href="/translate.php?keyonly=1&paginationrows=1000&search_input='
- + keySharp + '">Search by Hashtag</a> ';
- }
-
- var lastSpliter = key.lastIndexOf(spliter);
- var keyGroup = key.substring(0, lastSpliter);
- insert += ' <a class="stsh_a_button" target="_blank" '
- + ' href="/translate.php?keyonly=1&paginationrows=1000&search_input='
- + keyGroup + '">Search by Group</a> ';
- }
- insert += ' <a class="stsh_a_button" target="_blank" '
- + ' href="/translate.php?keyonly=1&search_input='
- + key + '">Search by Key</a> ';
- }
- }
-
- var tdText = document.querySelector(".progress tr:last-child > td:nth-child(1)");
- if (tdText != null)
- {
- var text = encodeURIComponent(tdText.textContent.trim()).replace(/(%20|%09)/g,"+")
- .replace(/'/g,"\\'").replace("%0A","+").replace(/\++/g,"+").substr(0, 80);
-
- if (text.length >= 80)
- {
- text = text.substr(0,text.lastIndexOf("+"));
- }
-
- if (text != "")
- {
- insert += ' <br/> <a class="stsh_a_button" target="_blank" '
- + ' href="/translate.php?keyonly=2&paginationrows=1000&search_input='
- + text + '">Search by String</a> ';
- }
- else
- {
- if (textarea != null)
- {
- var eleSubmit = document.querySelector(".lbAction input[type='submit'][accesskey='s']");
- if (eleSubmit != null)
- {
- var eleNew = document.createElement("input");
- eleNew.classList.add("stsh_insert_space");
- eleNew.setAttribute("type", "button");
- eleNew.setAttribute("value", "Insert Space (Alt+0160)");
- insertBeforeElement(eleNew, eleSubmit.parentElement.firstChild);
-
- eleNew.addEventListener("click", function(e)
- {
- var textarea = document.querySelector("#suggestion_value_new");
- if (textarea != null)
- {
- textarea.value = String.fromCharCode(160);
- textarea.focus();
- }
- });
- }
- }
- }
- }
-
- var app = regApp.exec(key.replace("%23",""));
- if (key.indexOf("faq") < 0 && app != null)
- {
- insert += ' <br/> ';
-
- if (key.indexOf("SharedFiles_App_") == 0)
- {
- insert += ' <a class="stsh_a_button" target="_blank" '
- + ' href="http://steamcommunity.com/workshop/browse?appid='
- + app + '">View Workshop</a> ';
- }
-
- insert += ' <a class="stsh_a_button" target="_blank" '
- + ' href="http://steamcommunity.com/app/'
- + app + '">View Community</a> '
-
- insert += ' <a class="stsh_a_button" target="_blank" '
- + ' href="http://store.steampowered.com/app/'
- + app + '">View App</a> ';
- }
-
- var src = document.documentURI;
- var insertBefore = ' <input value="Refresh" '
- + ' onclick="window.location = window.location.href; return false;" type="button"> '
- + ' <a class="stsh_a_button" target="_blank" '
- + ' href="' + src + '">Frame</a> ';
-
- var innerNew = divNav.innerHTML
- .replace('<input value="Previous',' <input value="Prev')
- .replace('<input value="Close',' <input value="Close');
-
- divNav.innerHTML = insertBefore + innerNew + insert;
-
- }
-
- // Regroup glossary and auto replace matched string
- if (false)
- {
- // old feature
-
- setTimeoutCustom(function()
- {
- var br = "<br>";
- var brSpace = " <br> ";
- var tag = "<a";
- var colon = ">: ";
- var comma = ",";
- var bracket = " (";
- var isEdit = false;
-
- var p = null;
-
- var aGls = document.querySelectorAll("a[href='glossary.php']");
- for (var i = 0; i < aGls.length; i++)
- {
- if (aGls[i].textContent.trim() == "GLOSSARY FEATURE")
- {
- p = aGls[i].parentElement;
- break;
- }
- }
-
- if (p != null)
- {
- var glosOuters = [];
- var glosInnerStart = 0;
- var countGl = 0;
- var glossaries = p.innerHTML.split(br);
- if (glossaries.length > 2)
- {
- glosOuters = [p];
- glosInnerStart = 2;
- }
- else
- {
- glosOuters = p.nextSibling.querySelectorAll("td");
- glosInnerStart = 0;
- }
-
- var rgxKey = />[^><]+</;
- var rgxKeyClean = /[><]+/g;
- var rgxKeyPunct = /[\(\)\[\]\:\!]/g;
- var rgxContentClean = /<[^<]*>/g;
- var textOrg = "";
- var textEng = "";
- var isTextReplaced = false;
- var isOutdated = false;
-
- var eleBtnResummit = document.querySelector("input[type='submit'][value^='RESUBMIT']");
- if (eleBtnResummit != null)
- {
- isTextReplaced = true;
- }
- else
- {
- var eleTextOrg = document.querySelector("#suggestion_value_new");
- if (eleTextOrg != null)
- {
- textOrg = eleTextOrg.value.trim().toLowerCase();
- }
- if (textOrg == "")
- {
- isTextReplaced = true;
- }
- }
-
- if (!isTextReplaced)
- {
- var eleTrs = document.querySelectorAll(".progress tr");
- isOutdated = (eleTrs.length >= 3);
- if (isOutdated)
- {
- textEng = eleTrs[eleTrs.length - 1].firstElementChild.textContent.trim().toLowerCase();
- }
- }
-
- for (var i = 0; i < glosOuters.length; i++)
- {
- var glosOuter = glosOuters[i];
-
- var glosInners = glosOuter.innerHTML.split(br);
-
- isEdit = false;
-
- for (var j = glosInnerStart; j < glosInners.length; j++)
- {
- var glossary = glosInners[j].trim();
- if (glossary.length > 0 && glossary.indexOf(tag) == 0)
- {
- var colonIndex = glossary.indexOf(colon);
- var contentHead = glossary.substr(0, colonIndex + 3);
- var contentAll = glossary.substr(colonIndex + 3);
- var contentWords = contentAll.split(comma);
- var contentFirst = contentWords[0].trim();
-
- for (var k = 0; k < contentWords.length; k++)
- {
- var contentNew = contentWords[k].trim();
- var contentSub = null;
-
- var bracketPos = contentNew.indexOf(" (");
- if (bracketPos > -1)
- {
- contentSub = contentNew.substr(bracketPos);
- contentNew = contentNew.substr(0, bracketPos);
- }
-
- contentNew = " <span id='stsh_gls_" + countGl
- + "' onclick='clickToSelect(this)'>"
- + contentNew + "</span>";
- //+ "<span style='color: white; cursor: pointer;'>^</span>";
-
- if (contentSub != null)
- {
- contentNew += "<span "
- + "onclick='clickToSelect(this.previousElementSibling)'>"
- + contentSub + "</span>";
- }
-
- contentWords[k] = contentNew;
- countGl++;
- }
-
- if (!isTextReplaced)
- {
- var keys = contentHead.match(rgxKey);
- if (keys != null && keys.length > 0)
- {
- var key = keys[0].replace(rgxKeyClean, "").trim().toLowerCase();
- var contentClean = contentFirst.replace(rgxContentClean, "");
- var contentLower = contentClean.toLowerCase();
- var textCur = "";
- if (key == textOrg.replace(rgxKeyPunct, ""))
- {
- textCur = textOrg;
- }
- else if (key == textEng.replace(rgxKeyPunct, ""))
- {
- textCur = textEng;
- }
-
- if (textCur != "" && key != contentLower)
- {
- var rgxReplace = new RegExp(key, "i");
- eleTextOrg.value = textCur.replace(rgxReplace, contentClean);
- isTextReplaced = true;
- }
- }
- }
-
- glosInners[j] = contentHead + contentWords.join(comma);
- isEdit = true;
- }
- }
- if (isEdit)
- {
- glosOuter.innerHTML = glosInners.join(brSpace);
- }
- }
- }
- }, 200);
- }
-
- // Restyle glossary
- {
- var eleP = null;
-
- var elesA = document.querySelectorAll("a[href='glossary.php']");
- for (var i = 0; i < elesA.length; i++)
- {
- if (elesA[i].textContent.trim() == "GLOSSARY FEATURE")
- {
- eleP = elesA[i].parentElement;
- break;
- }
- }
-
- if (eleP != null)
- {
- var nodeText = eleP.firstElementChild.nextSibling;
- if (nodeText.nodeType == document.TEXT_NODE)
- {
- var ele = document.createElement("span");
- ele.textContent = nodeText.textContent;
-
- nodeText.parentElement.removeChild(nodeText);
-
- insertAfterElement(ele, eleP.firstElementChild);
- }
-
- var eleHead;
-
- if (eleP.nextElementSibling.tagName == "TABLE")
- {
- eleHead = eleP.nextElementSibling;
- }
- else
- {
- eleHead = eleP;
- }
-
- eleHead.classList.add("stsh_glossary_header");
-
- var elesTerm = eleHead.querySelectorAll("a[href^='http://translation.steampowered.com/translate.php?search_input=']");
- for (var i = 0; i < elesTerm.length; i++)
- {
- elesTerm[i].classList.add("stsh_glossary_term");
- }
- }
- }
-
- // Auto link http
- // Format comment
- {
- var countSugStatus = document.querySelectorAll(
- ".suggestions_list span[class^='suggestion_status_']").length;
-
- var regUrl = /http[^ "]+/ig;
- var hostUrl = "http://translation.steampowered.com/";
- var hostReplace = "/";
- var eleComments = document.querySelectorAll(""
- + ".suggestion_signature > i:nth-child(3), "
- + ".suggestion_signature div:nth-child(1) > i:nth-child(4), "
- + ".suggestion_signature div:nth-child(1) > i:nth-child(6), "
- + ".row0 > td:nth-child(2), .row1 > td:nth-child(2), .row2 > td:nth-child(2), "
- + ".row-1 > td:nth-child(2) ");
- for (var i = 0; i < eleComments.length; i++)
- {
- var comment = eleComments[i].innerHTML + " ";
- if (comment.indexOf("<a") == -1)
- {
- var commentUrls = comment.match(regUrl) || [];
- for (var j = 0; j < commentUrls.length; j++)
- {
- var urlDecode = commentUrls[j];
- try
- {
- urlDecode = decodeURIComponent(commentUrls[j]);
-
- if (countSugStatus == 0 && urlDecode.indexOf(hostUrl) == 0)
- {
- var query = getQueryByName("search_input", urlDecode.replace("&", "&"));
-
- if (query != "")
- {
- urlDecode = query;
- }
- else
- {
- urlDecode = urlDecode.replace(hostUrl, hostReplace);
- }
- }
- }
- catch (ex)
- {
- }
- var commentUrl = commentUrls[j] + " ";
- comment = comment.replace(commentUrl,"<a target='_blank' href='"
- + commentUrls[j] + "' >" + urlDecode + "</a> ");
- }
- }
-
- comment = comment.trim();
-
- if (comment.indexOf("Comment:") == 0)
- {
- eleComments[i].classList.add("stsh_submit_comment_header");
- comment = comment
- .replace("Comment:", "Comment: <span class='stsh_submit_comment'>")
- .replace(/\/ /g, "<span class='stsh_white'>/</span> ")
- .replace(/ \//g, " <span class='stsh_white'>/</span>")
- .replace(/\-\>\;/g, "<span class='stsh_white'>-></span>")
- .replace(/\,/g, "<span class='stsh_white'>,</span>")
- + "</span>";
- }
-
- eleComments[i].innerHTML = comment;
-
- var eleAs = eleComments[i].querySelectorAll("a");
- for (var j = 0; j < eleAs.length; j++)
- {
- var href = eleAs[j].getAttribute("href");
- if (href.indexOf("#") > -1)
- {
- eleAs[j].setAttribute("href", href.replace(/\#/g,"%23"));
- }
- }
-
-
- //if (comment.indexOf("Comment:") != 0)
- {
- // Discussion comment
-
- var elesA = eleComments[i].querySelectorAll("a");
- for (var j = 0; j < elesA.length; j++)
- {
- var href = elesA[j].getAttribute("href");
- if (href.endsWith(".jpg") || href.endsWith(".png") || href.endsWith(".gif"))
- {
- if (elesA[j].querySelectorAll("img").length == 0)
- {
- var ele = document.createElement("img");
- ele.classList.add("stsh_comment_img");
- ele.setAttribute("src", href);
- ele.setAttribute("title", href);
- ele.setAttribute("onclick", " if (this.style.minWidth != '850px') "
- + " { this.style.minWidth = '850px'; } "
- + " else { this.style.minWidth = '400px'; } ");
-
- insertAfterElement(ele, elesA[j]);
- }
- }
- }
- }
- }
- }
-
- var divIntro = document.querySelector("#suggestionmain > div.smallcopy");
- if (divIntro != null)
- {
- var qBranch = getQueryByName("branch");
-
- var htmlToken = "You are editing";
- var htmlTokenReplace = "";
-
- var htmlToken2 = "token-key";
- var htmlToken2Replace = "Token-key";
-
- var htmlFile = "of file";
- var htmlFileReplace = '<br>File: <font class="stsh_blue" onclick="clickToSelect(this)">' + qBranch + '</font> >> ';
-
- var htmlSugg = 'You have <font style="';
- var htmlSuggReplace = 'You have <font title="Enter and submit new suggestions below. Do not alter HTML tags or variables." style="cursor: pointer; ';
-
- var htmlIntro = "Enter and submit new suggestions below. Do not alter HTML tags or variables.";
- var htmlIntroReplace = ' <a href="mailto:translationserver@valvesoftware.com" '
- + 'title="Please report truncated tokens to translationserver@valvesoftware.com">'
- + '<font style="color:white;">Report Tokens</font></a>';
-
- var htmlContact = '<br>Please report truncated tokens to: <a href="mailto:translationserver@valvesoftware.com"><font style="color:white;">translationserver@valvesoftware.com</font></a>';
- var htmlContactReplace = '';
-
- if (key != "")
- {
- htmlIntroReplace += ' <br>Share: <font class="stsh_green" style="font-size: 0.8em;" onclick="clickToSelect(this)">'
- + 'http://translation.steampowered.com/translate.php?search_input=' + key
- + "</font> <br>";
- }
-
- var isComplete = (divIntro.innerHTML.indexOf(htmlContact) > -1);
-
- divIntro.innerHTML = divIntro.innerHTML
- .replace(htmlToken, htmlTokenReplace)
- .replace(htmlToken2, htmlToken2Replace)
- .replace(htmlFile, htmlFileReplace)
- .replace(htmlSugg, htmlSuggReplace)
- .replace(htmlIntro, htmlIntroReplace)
- .replace(htmlContact, htmlContactReplace)
- .trim();
-
- if (!isComplete)
- {
- var stsh_introReplace_start = new Date();
- var stsh_introReplace_itv = setIntervalCustom(function(params)
- {
- var divIntro = params[0];
- var htmlContact = params[1];
- var htmlContactReplace = params[2];
-
- var stsh_introReplace_isEnd = false;
- var stsh_introReplace_cur = new Date();
-
- if (divIntro.innerHTML.indexOf(htmlContact) > -1)
- {
- divIntro.innerHTML = divIntro.innerHTML
- .replace(htmlContact, htmlContactReplace);
-
- stsh_introReplace_isEnd = true;
- }
-
- if (stsh_introReplace_isEnd || stsh_introReplace_cur - stsh_introReplace_start > 10000)
- {
- clearInterval(stsh_introReplace_itv);
- }
- }, 100, [divIntro, htmlContact, htmlContactReplace]);
- }
- }
-
- var formComments = document.querySelectorAll(".lbAction");
- for (var i = 0; i < formComments.length; i++)
- {
- var formComment = formComments[i];
- var inputComment = formComment.querySelector("input[type=submit]");
- if (inputComment != null)
- {
- addKeyCtrlEnter(formComment, inputComment);
- }
- }
-
- var inputApprove = document.querySelector(".suggestion_signature input[value~='APPROVE']");
- if (inputApprove != null)
- {
- addKeyAlt(document, inputApprove, 219, "["); // [
- addKeyAlt(document, inputApprove, "BracketLeft", ""); // [
- //addKeyAlt(document, inputApprove, 0, ""); // [
- //addKeyAlt(document, inputApprove, 53, ""); // [
- addKeyAlt(document, inputApprove, 79, ""); // O
- addKeyAlt(document, inputApprove, 65, ""); // A
- }
-
- var inputApproveNext = document.querySelector(".suggestion_signature input[value~='Next']");
- if (inputApproveNext != null)
- {
- inputApproveNext.value = "Next";
- addKeyAlt(document, inputApproveNext, 221, "]"); // ]
- addKeyAlt(document, inputApproveNext, "BracketRight", ""); // ]
- //addKeyAlt(document, inputApproveNext, 188, ""); // ]
- //addKeyAlt(document, inputApproveNext, 173, ""); // ]
- //addKeyAlt(document, inputApproveNext, 169, ""); // ]
- addKeyAlt(document, inputApproveNext, 80, ""); // P
- addKeyAlt(document, inputApproveNext, 83, ""); // S
- addKeyCtrl(document, inputApproveNext, 45, ""); // INS
-
- disableAfterClick(inputApproveNext);
-
- if (inputApproveNext.disabled && inputApprove != null)
- {
- addKeyAlt(document, inputApprove, 221, ""); // ]
- addKeyAlt(document, inputApprove, "BracketRight", ""); // ]
- //addKeyAlt(document, inputApprove, 188, ""); // ]
- //addKeyAlt(document, inputApprove, 173, ""); // ]
- //addKeyAlt(document, inputApprove, 169, ""); // ]
- addKeyAlt(document, inputApprove, 80, ""); // P
- addKeyAlt(document, inputApprove, 83, ""); // S
- addKeyCtrl(document, inputApprove, 45, ""); // INS
- }
- }
-
- var inputDecline = document.querySelector(".suggestion_signature input[value~='DECLINE']");
- if (inputDecline != null)
- {
- addKeyCtrl(document, inputDecline, 46, ""); // DEL
- }
-
- var inputDeclineNext = document.querySelector(".suggestion_signature input[value~='Next']:nth-child(5)");
- if (inputDeclineNext != null)
- {
- inputDeclineNext.value = "Next";
- }
-
- var inputPrev = document.querySelector("#suggestions_nav > input[value^='Prev']");
- if (inputPrev != null)
- {
- addKeyCtrl(document, inputPrev, 219, "["); // [
- addKeyCtrl(document, inputPrev, "BracketLeft", ""); // [
- //addKeyCtrl(document, inputPrev, 0, ""); // [
- //addKeyCtrl(document, inputPrev, 53, ""); // [
-
- disableAfterClick(inputPrev);
- }
-
- var inputNext = document.querySelector("#suggestions_nav > input[value~='Next']");
- if (inputNext != null)
- {
- addKeyCtrl(document, inputNext, 221, "]"); // ]
- addKeyCtrl(document, inputNext, "BracketRight", ""); // ]
- //addKeyCtrl(document, inputNext, 188, ""); // ]
- //addKeyCtrl(document, inputNext, 173, ""); // ]
- //addKeyCtrl(document, inputNext, 169, ""); // ]
-
- disableAfterClick(inputNext);
- }
-
- // Check special chars
- {
- var h1s = document.querySelectorAll(".progress h1");
- if (h1s.length == 2)
- {
- var h1Org = h1s[0];
- var h1Trn = h1s[1];
-
- var tdOrg = document.querySelector(".progress tr:last-child > td:nth-child(1)");
- var tdTrn = document.querySelector(".progress tr:last-child > td:nth-child(3)");
-
- if (tdOrg != null && tdTrn != null)
- {
- var strOrg = tdOrg.textContent.trim();
- var strTrn = tdTrn.textContent.trim();
-
- var statusTrnArr = checkSpecialCharMatched(strOrg, strTrn);
- var statusTrnMatched = statusTrnArr[0];
- var spOrg = statusTrnArr[1];
- var spTrn = statusTrnArr[2];
-
- if (spOrg > 0)
- {
- var spanSpOrg = document.createElement("span");
- spanSpOrg.id = "stsh_spanSpOrg";
- spanSpOrg.classList.add("stsh_blue");
- spanSpOrg.innerHTML = " SpecialChar: " + spOrg;
- h1Org.parentElement.appendChild(spanSpOrg);
-
- // Check chars in translated
- if (strTrn != "")
- {
- var spanSpTrn = document.createElement("span");
- spanSpTrn.id = "stsh_spanSpTrn";
-
- if (statusTrnMatched == 0)
- {
- spanSpTrn.classList.add("stsh_green");
- }
- else
- {
- spanSpTrn.classList.add("stsh_red");
- }
-
- var outputTrn = " SpecialChar: " + spTrn;
- if (statusTrnMatched == 0)
- {
- outputTrn += " (Matched)";
- }
- else if (statusTrnMatched == 1)
- {
- outputTrn += " (Order not matched)";
- }
- else
- {
- outputTrn += " (Not matched)";
- }
-
- spanSpTrn.innerHTML = outputTrn;
- h1Trn.parentElement.appendChild(spanSpTrn);
- }
-
- // Check chars in suggested
- var divSugs = document.querySelectorAll(".suggestion_text");
- for (var i = 0; i < divSugs.length; i++)
- {
- var divSug = divSugs[i];
- var strSug = divSug.textContent.trim();
-
- var statusSugArr = checkSpecialCharMatched(strOrg, strSug);
- var statusSugMatched = statusSugArr[0];
- var spSug = statusSugArr[2];
-
-
- var spanSpSug = document.createElement("span");
- spanSpSug.classList.add("stsh_spanSpSug");
-
- if (statusSugMatched == 0)
- {
- spanSpSug.classList.add("stsh_green");
- }
- else
- {
- spanSpSug.classList.add("stsh_red");
- }
-
- var outputSug = " SpecialChar: " + spSug;
- if (statusSugMatched == 0)
- {
- outputSug += " (Matched)";
- }
- else if (statusSugMatched == 1)
- {
- outputSug += " (Order not matched)";
- }
- else
- {
- outputSug += " (Not matched)";
- }
- outputSug += " <br/><br/> ";
-
- spanSpSug.innerHTML = outputSug;
-
- divSug.insertBefore(spanSpSug, divSug.firstChild);
- }
-
- }
- }
- }
-
- }
-
- // Trim string in same token
- {
- var p = document.querySelector("#suggestionmain > div:nth-child(5) > p:nth-child(4)");
- if (p != null)
- {
- for (var i = 0; i < p.childNodes.length; i++)
- {
- child = p.childNodes[i];
- if (child.nodeName == "#text")
- {
- child.nodeValue = child.nodeValue.trim();
- }
- }
- }
- }
-
- // Display newlines
- {
- var tdOrg = document.querySelector(".progress tr:last-child > td:nth-child(1)");
- var tdTrn = document.querySelector(".progress tr:last-child > td:nth-child(3)");
-
- if (tdOrg != null && tdTrn != null)
- {
-
- var htmlOrg = tdOrg.innerHTML.trim();
- var htmlTrn = tdTrn.innerHTML.trim();
-
- if ((htmlOrg.indexOf("\n") > -1 || htmlOrg.indexOf("\\n") > -1
- || htmlTrn.indexOf("\n") > -1 || htmlTrn.indexOf("\\n") > -1)
- /*&& htmlOrg.indexOf("<br") < 0
- && htmlOrg.indexOf("<p") < 0 && htmlOrg.indexOf("<div") < 0 && htmlOrg.indexOf("<li") < 0*/)
- {
- var h2SugHeader = document.querySelector("#suggestionmain > div > h2");
- if (h2SugHeader != null)
- {
- var btn = document.createElement("input");
- btn.setAttribute("class", "stsh_btn_right");
- btn.setAttribute("type", "button");
- btn.setAttribute("value", "Display Newlines");
-
- function displayNewlines(ele)
- {
- if (ele != null)
- {
- ele.innerHTML = ele.innerHTML.trim().replace(/\n/g,"\n<br>").replace(/\\n/g," \\n<br>");
- }
- }
-
- btn.addEventListener("click", function(e)
- {
- e.target.disabled = true;
-
- var tdOrg = document.querySelector(".progress tr:last-child > td:nth-child(1)");
- var tdTrn = document.querySelector(".progress tr:last-child > td:nth-child(3)");
- displayNewlines(tdOrg);
- displayNewlines(tdTrn);
-
- var divSugs = document.querySelectorAll(".suggestion_text");
- for (var i = 0; i < divSugs.length; i++)
- {
- var divSug = divSugs[i];
- displayNewlines(divSug);
- }
-
- var textarea = document.querySelector("#suggestion_value_new");
- if (textarea != null)
- {
- textarea.focus();
- }
- });
-
- h2SugHeader.appendChild(btn);
- }
- }
- }
- }
-
- // Open comment when decline
- {
- var countComment = 0;
- var elesComment = [];
-
- var countSug = document.querySelectorAll(".suggestions_list .suggestion").length;
- var countSugDeclined = document.querySelectorAll(
- ".suggestions_list span[class='suggestion_status_declined']").length;
-
- if (countSug == countSugDeclined)
- {
- var elesSugA = document.querySelectorAll(".suggestions_list span[class^='suggestion_status_'] a");
- for (var i = 0; i < elesSugA.length; i++)
- {
- var eleComment = elesSugA[i].parentElement.parentElement.nextSibling;
- if (eleComment.nodeName == "DIV" && eleComment.classList.contains("copy"))
- {
- if (elesSugA[i].parentElement.classList.contains("suggestion_status_declined"))
- {
- countComment++;
- elesComment.push(eleComment);
- }
- }
- }
-
- if (countComment == elesSugA.length)
- {
- var isFocus = false;
- for (var i = 0; i < elesComment.length; i++)
- {
- elesComment[i].style.display = "block";
- if (!isFocus)
- {
- var eleTxt = elesComment[i].querySelector("textarea[name='suggestion_comment']");
- if (eleTxt != null)
- {
- eleTxt.focus();
-
- var eleSugOuter = elesComment[i].parentElement.parentElement.parentElement.parentElement;
- if (eleSugOuter.classList.contains("suggestion"))
- {
- var eleOnion = eleSugOuter.querySelector(".suggestion_text font[style='color:#01ec00;']");
- if (eleOnion != null)
- {
- eleTxt.value = "onion";
- }
- }
-
- var eleSugComment = elesComment[i].parentElement
- .parentElement.parentElement.querySelector(".stsh_submit_comment font");
- if (eleSugComment != null && eleSugComment.textContent.trim() ==
- "ATTENTION - English string was updated. This suggestion might be outdated.")
- {
- eleTxt.value = "outdated";
- }
-
- isFocus = true;
- }
- }
- }
- }
- }
- }
-
- // Convert time
- {
- var rgxTime = /\d{2}-\d{2}-\d{4}, \d{2}:\d{2} [AP]M/;
- var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
-
- var eleFriends = document.querySelectorAll(".friend_block_avatar, .friend_block_discussions");
- for (var i = 0; i < eleFriends.length; i++)
- {
- var nodes = [];
-
- if (eleFriends[i].classList.contains("friend_block_avatar"))
- {
- nodes = eleFriends[i].childNodes;
- }
- else if (eleFriends[i].classList.contains("friend_block_discussions"))
- {
- nodes = eleFriends[i].parentElement.nextElementSibling.childNodes[2].childNodes;
- }
-
- for (var j = 0; j < nodes.length; j++)
- {
- var nodeVal = nodes[j].nodeValue;
- if (nodeVal != null)
- {
- var dateTimes = rgxTime.exec(nodeVal);
- if (dateTimes != null)
- {
- var dateTime = dateTimes[0];
- var month = dateTime.substr(0, 2);
- var day = dateTime.substr(3, 2);
- var year = dateTime.substr(6, 4);
- var hour = dateTime.substr(12, 2);
- var minute = dateTime.substr(15, 2);
- var period = dateTime.substr(18, 2);
- if (period == "AM")
- {
- if (hour == "12")
- {
- hour = "00"
- }
- }
- else if (period == "PM")
- {
- hour = parseInt(hour) + 12;
- if (hour == 24)
- {
- hour = 12;
- }
- }
-
- var dateTimeStd = year + "-" + month + "-" + day;
-
- if (isDstUsa(year, month, day, hour))
- {
- dateTimeStd += "T" + hour + ":" + minute + ":00-0700";
- }
- else
- {
- dateTimeStd += "T" + hour + ":" + minute + ":00-0800";
- }
-
- var dateStd = new Date(dateTimeStd);
- if (dateStd.toLocaleString() != "Invalid Date")
- {
- var gmt = dateStd.getTimezoneOffset() / 60 * -1;
- var gmtStr = " GMT";
- if (gmt > 0)
- {
- gmtStr += "+" + gmt;
- }
- else if (gmt < 0)
- {
- gmtStr += "" + gmt;
- }
- var dateNew = dateStd.getDate()
- + " " + months[dateStd.getMonth()]
- + " " + dateStd.getFullYear()
- + ", " + padZero(dateStd.getHours(), 2)
- + ":" + padZero(dateStd.getMinutes(), 2)
- + gmtStr;
-
- //console.log("Time: " + dateTimeStd);
- //console.log("Time: " + dateTime + " -> " + dateNew);
-
- //var dateNew2 = dateStd.toLocaleString() + gmtStr;
- //console.log("Time: " + dateTime + " -> " + dateNew2);
-
- var nodeValBegin = nodeVal.substr(0, nodeVal.indexOf(dateTime));
- var nodeValEnd = nodeVal.substr(nodeVal.indexOf(dateTime) + dateTime.length);
-
- nodes[j].nodeValue = nodeValBegin;
-
- var ele = document.createElement("span");
- ele.classList.add("stsh_time_convert");
- ele.setAttribute("title", dateTime);
- ele.textContent = dateNew;
- insertAfterElement(ele, nodes[j]);
-
- if (nodeValEnd != "")
- {
- insertAfterElement(document.createTextNode(nodeValEnd), ele);
- }
- }
- else
- {
- console.log("Invalid Date: " + dateTimeStd);
- }
- }
- }
- }
- }
-
- }
-
- // Add Steam profile links
- {
- var eleSpans = document.querySelectorAll("span[title='Send this user a private message']");
- for (var i = 0; i < eleSpans.length; i++)
- {
- var href = eleSpans[i].parentElement.firstElementChild.getAttribute("href");
- if (href != null && href.indexOf("user_activity.php?user=") == 0)
- {
- var profile = href.replace("user_activity.php?user=", "");
- var ele = document.createElement("a");
- ele.classList.add("stsh_steamProfile");
- ele.setAttribute("target", "_blank");
- ele.setAttribute("title", "View Steam profile");
- ele.setAttribute("href", "http://steamcommunity.com/profiles/" + profile);
- ele.textContent = " Steam ";
-
- insertBeforeElement(ele, eleSpans[i]);
- }
- }
- }
-
- // Add auto approve
- {
- if (inputApprove != null)
- {
- var eleInput = document.createElement("input");
- eleInput.id = "stsh_autoApprove";
- eleInput.setAttribute("type", "checkbox");
- eleInput.setAttribute("value", "auto");
- eleInput.textContent = "";
-
- var eleLabel = document.createElement("label");
- eleLabel.classList.add("stsh_autoApprove_label");
- eleLabel.classList.add("stsh_unselectable");
- eleLabel.setAttribute("for", "stsh_autoApprove");
- eleLabel.setAttribute("title", "Please use with care!");
- eleLabel.textContent = " Auto Approve Next ";
-
- inputApprove.parentElement.appendChild(eleInput);
- inputApprove.parentElement.appendChild(eleLabel);
-
- function autoApprove()
- {
- var tm = 2000;
- console.log("AutoApprove: Next in " + tm + "ms");
- setTimeoutCustom(function ()
- {
- var eleCheck = document.querySelector("#stsh_autoApprove");
- if (eleCheck != null && eleCheck.checked)
- {
- var isClicked = false;
-
- var ele = document.querySelector(".suggestion_signature input[value~='Next']");
-
- if (ele != null && !ele.disabled && isVisible())
- {
- var isOutdated = false;
- var eleSugComment = ele.parentElement
- .parentElement.parentElement.querySelector(".stsh_submit_comment font");
- if (eleSugComment != null && eleSugComment.textContent.trim() ==
- "ATTENTION - English string was updated. This suggestion might be outdated.")
- {
- isOutdated = true;
- }
-
- if (!isOutdated)
- {
- isClicked = true;
- GM_setValue("timeAutoApproveLast", getUnixTimestamp());
- ele.click();
- }
- }
-
- if (!isClicked)
- {
- eleCheck.checked = false;
- GM_setValue("isAutoApprove", "false");
- }
- }
- }, tm);
- }
-
- var tmDiff = getUnixTimestamp() - GM_getValue("timeAutoApproveLast", 0);
- if (tmDiff > 10)
- {
- // > 10s
- eleInput.checked = false;
- GM_setValue("isAutoApprove", "false");
- }
-
- if (window.parent != window)
- {
- var eleOuter = window.parent.document.querySelector("#suggestions_box_outer");
- if (eleOuter != null)
- {
- if (eleOuter.style.display == "none")
- {
- // Closed iFrame
- eleInput.checked = false;
- GM_setValue("isAutoApprove", "false");
- }
- }
- }
-
- if (GM_getValue("isAutoApprove", 0) == "true")
- {
- eleInput.checked = true;
- autoApprove();
- }
-
- eleInput.addEventListener("click", function (e)
- {
- var ele = e.target;
- if (ele.checked)
- {
- GM_setValue("isAutoApprove", "true");
- autoApprove();
- }
- else
- {
- GM_setValue("isAutoApprove", "false");
- }
- });
- }
- }
-
- // Warn when remove
- {
- var elesRemove = document.querySelectorAll(".suggestion_signature input[value='REMOVE']");
- for (var i = 0; i < elesRemove.length; i++)
- {
- var oldClick = elesRemove[i].getAttribute("onclick");
- if (oldClick != null && oldClick.indexOf("location.href") == 0)
- {
- var eleSug = elesRemove[i].parentElement.parentElement.parentElement.parentElement;
- if (eleSug.classList.contains("suggestion"))
- {
- var eleOnion = eleSug.querySelector(".suggestion_text font[style='color:#01ec00;']");
- if (eleOnion != null)
- {
- var newClick = "if (!confirm(\"Warning: You will delete your onion. Press Cancel to go back.\")) return false; "
- + oldClick;
- elesRemove[i].setAttribute("onclick", newClick);
- elesRemove[i].setAttribute("title", "Do not remove your onion!");
- elesRemove[i].style.color = "#777";
- elesRemove[i].style.cursor = "not-allowed";
- }
- else
- {
- var eleComment = elesRemove[i].previousElementSibling.previousElementSibling;
- if (eleComment != null)
- {
- if (eleComment.textContent.trim().indexOf("Comment:") == 0)
- {
- var newClick = "if (!confirm(\"Warning: You should not remove this suggestion. Press OK if you really want.\")) return false; "
- + oldClick;
- elesRemove[i].setAttribute("onclick", newClick);
- elesRemove[i].setAttribute("title", "Your suggestion that has a comment!");
- elesRemove[i].style.color = "#777";
- elesRemove[i].style.cursor = "not-allowed";
- }
- }
- }
- }
- }
- }
- }
-
- } // End suggestions.php
-
- if (url.indexOf("translate.php") > -1)
- {
- var searchText = getQueryByName("search_input");
- if (searchText != "")
- {
- document.title = searchText + " - " + document.title;
- }
- else
- {
- var fileID = getQueryByName("file_ID");
- if (fileID != "")
- {
- var eleFile = document.querySelector("#leftAreaContainer label[for='chosenfile']");
- if (eleFile != null)
- {
- var file = eleFile.textContent.trim();
- if (file.indexOf("Limit search results to CURRENT FILE: ") == 0)
- {
- file = file.replace("Limit search results to CURRENT FILE: ", "");
- var fileNew = file.split("#").reverse().join(" # ").trim();
- document.title = fileNew + " - " + document.title;
- }
- }
- }
- else
- {
- var eleInput = document.querySelector("#search_input");
- if (eleInput != null)
- {
- var valInput = eleInput.value.trim();
- if (valInput.indexOf("SUGGESTIONS FROM: ") == 0)
- {
- document.title = valInput.replace("SUGGESTIONS FROM: ", "") + " - " + document.title;
- }
- }
- }
- }
-
- var outer = document.getElementById("suggestions_box_outer");
- if (outer != null)
- {
- outer.setAttribute("onclick","hideSuggestionsBox();");
- }
-
- var divBtn = document.createElement("div");
- document.body.appendChild(divBtn);
- divBtn.innerHTML = ' \
- <div class="stsh_showing_group"> \
- <span class="stsh_showing_header">Hide</span>\
- <br/> <input value="App" class="stsh_btn_short" type="button" onmouseup="hideKeyAppInterval(); return false;" /> \
- <input value="Game" class="stsh_btn_short" type="button" onmouseup="hideKeyGameInterval(); return false;" /> \
- <br/> <input value="FAQ" class="stsh_btn_short" type="button" onmouseup="hideKeyFaqInterval(); return false;" /> \
- <input value="Support" class="stsh_btn_short" type="button" onmouseup="hideKeySupportInterval(); return false;" /> \
- <br/> <input value="Promo" class="stsh_btn_short" type="button" onmouseup="hideKeyPromoInterval(); return false;" /> \
- <input value="Email" class="stsh_btn_short" type="button" onmouseup="hideKeyEmailInterval(); return false;" /> \
- <br/> \
- <br/> <input value="Hide not similar" class="stsh_btn_long" type="button" onmouseup="hideStrNotMatchInterval(); return false;" /> \
- <br/> <input value="Hide very long" class="stsh_btn_long" type="button" onmouseup="hideStrLongInterval(); return false;" /> \
- \
- <br/> <span class="stsh_showing_header">Hide Suggestions</span>\
- <br/> <input id="stsh_showing_notTranslated" value="Not Translated (0)" class="stsh_btn_long" type="button" /> \
- <br/> <input id="stsh_showing_suggested" value="Suggested (0)" class="stsh_btn_long" type="button" /> \
- <br/> <input id="stsh_showing_resuggested" value="Resuggested (0)" class="stsh_btn_long" type="button" /> \
- <br/> <input id="stsh_showing_approved" value="Approved (0)" class="stsh_btn_long" type="button" /> \
- <br/> <input id="stsh_showing_declined" value="Declined (0)" class="stsh_btn_long" type="button" /> \
- <br/> <input id="stsh_showing_translated" value="Translated (0)" class="stsh_btn_long" type="button" /> \
- \
- <br/> <span class="stsh_showing_header">Sort by</span>\
- <br/> <input value="Key" class="stsh_btn_short" type="button" onmouseup="sortKeyInterval(); return false;" /> \
- <input value="String" class="stsh_btn_short" type="button" onmouseup="sortStringInterval(); return false;" /> \
- <br/> <input value="Word" class="stsh_btn_short" type="button" onmouseup="sortWordInterval(); return false;" /> \
- <input value="Length" class="stsh_btn_short" type="button" onmouseup="sortLengthInterval(); return false;" /> \
- <br/> \
- <br/> <input id="stsh_showing_refresh" value="Refresh" class="stsh_btn" type="button" onmouseup="hideSuggestionsBox(); return false;" /> \
- <br/> <input id="stsh_showing_all" value="Show All" class="stsh_btn" type="button" onmouseup="showKey(); return false;" /> \
- </div> \
- <div id="stsh_showing_current"></div> \
- <div id="stsh_showing"></div> \
- ';
-
- // Count showing
- function countShowing()
- {
- if (!isVisible()) return;
-
- var trKeys = document.querySelectorAll("#keylist > table:nth-child(1) > tbody:nth-child(1) > tr");
- var countAll = document.querySelectorAll("#keylist .copysmall").length;
- var countShow = 0;
- var countSuggest = 0;
- var countResuggest = 0;
- var countApprove = 0;
- var countDecline = 0;
- var countNotTranslated = 0;
- var countTranslated = 0;
-
- var txtApprove = "ready for Admin";
- var txtDecline = "ready for removal";
- var txtSuggest = "suggestion";
-
- for (var i = 0; i < trKeys.length; i++)
- {
- if (trKeys[i].style.display != "none")
- {
- var eleCounter = trKeys[i].querySelector("tr.copysmall > td:nth-child(3)");
- if (eleCounter != null)
- {
- countShow++;
- var txtCounter = eleCounter.textContent.trim();
- if (txtCounter.indexOf(txtApprove) > -1)
- {
- countApprove++;
- }
- else if (txtCounter.indexOf(txtDecline) > -1)
- {
- countDecline++;
- }
- else if (txtCounter.indexOf(txtSuggest) > -1)
- {
- var eleNotTranslated = trKeys[i].querySelector("span.token_nottranslated");
- if (eleNotTranslated != null)
- {
- countSuggest++;
- }
- else
- {
- countResuggest++;
- }
- }
- else
- {
- var eleNotTranslated = trKeys[i].querySelector("span.token_nottranslated");
- if (eleNotTranslated != null)
- {
- countNotTranslated++;
- }
- else
- {
- countTranslated++;
- }
- }
- }
- else
- {
- var eleTd = trKeys[i].querySelector("td");
- if (eleTd != null)
- {
- if (eleTd.textContent.trim() == "")
- {
- trKeys[i].parentElement.removeChild(trKeys[i]);
- }
- }
- }
- }
- }
- var eleShowing = document.getElementById("stsh_showing");
- if (eleShowing != null)
- {
- var newHtml = "Showing: <span class=\"stsh_showing_counter\">" + countShow + " of " + countAll + "</span>"
- + "<!-- " + countNotTranslated + ", " + countSuggest + ", " + countResuggest
- + ", " + countApprove + ", " + countDecline + ", " + countTranslated + " -->";
-
- if (eleShowing.innerHTML != newHtml)
- {
- eleShowing.innerHTML = newHtml;
-
- var eleBtnShowings = document.querySelectorAll("#stsh_showing_notTranslated, #stsh_showing_suggested, #stsh_showing_resuggested"
- + ", #stsh_showing_approved, #stsh_showing_declined, #stsh_showing_translated");
- if (eleBtnShowings.length == 6)
- {
- var counterArr = [countNotTranslated, countSuggest, countResuggest, countApprove, countDecline, countTranslated ];
- var counterTextArr = ["Not Translated", "Suggested", "Resuggested"
- , "Approved", "Declined", "Translated" ];
-
- for (var i = 0; i < eleBtnShowings.length; i++)
- {
- eleBtnShowings[i].value = counterTextArr[i] + " ("+ counterArr[i] +")" ;
- };
- }
- }
- }
- var eleShowingCur = document.getElementById("stsh_showing_current");
- if (eleShowingCur != null)
- {
- var eleOuter = document.getElementById("suggestions_box_outer");
- if (eleOuter != null)
- {
- if (eleOuter.style.display != "none")
- {
- if (eleShowingCur.style.display != "initial")
- eleShowingCur.style.display = "initial";
-
- var eleIframe = document.getElementById("suggestions_iframe");
- var iUrl = eleIframe.contentWindow.location.href;
- var listId = parseInt(getQueryByName("list_id", iUrl));
-
- if (isNaN(listId))
- listId = 1;
- else
- listId += 1;
-
- var newHtml = "Current: <span class=\"stsh_showing_counter\">" + listId + " of " + countShow + "</span>";
- if (eleShowingCur.innerHTML != newHtml)
- {
- eleShowingCur.innerHTML = newHtml;
- }
- }
- else
- {
- if (eleShowingCur.style.display != "none")
- {
- eleShowingCur.style.display = "none";
- eleShowingCur.innerHTML = "";
- }
- }
- }
- }
- }
- countShowing();
- setIntervalCustom(countShowing, 1000);
- // End Count showing
-
- // Line Counter
- function addLineCounter()
- {
- if (!isVisible()) return;
-
- var elesCounter = document.querySelectorAll(".stsh_lineCounter");
- if (elesCounter.length > 0)
- {
- var j = 1;
- for (var i = 0; i < elesCounter.length; i++)
- {
- if (elesCounter[i].parentElement.parentElement.parentElement.parentElement.style.display != "none")
- {
- if (elesCounter[i].textContent.trim() != j)
- {
- elesCounter[i].textContent = j;
- }
- j++;
- }
- }
- }
- else
- {
- var elesDiv = document.querySelectorAll("#keylist td:nth-child(1) > div");
- for (var i = 0; i < elesDiv.length; i++)
- {
- var eleNew = document.createElement("span");
- eleNew.classList.add("stsh_lineCounter_outer");
- eleNew.innerHTML =
- ' <span class="stsh_lineCounter"> '
- + (i + 1)
- + ' </span> ';
-
- elesDiv[i].appendChild(eleNew);
- }
- }
- }
- addLineCounter();
- setIntervalCustom(addLineCounter, 1000);
- // End Line Counter
-
- // Hide suggestions
- {
- function hideSuggestions(mode)
- {
- // mode: 0-5 (0: "Not Translated", 1: "Suggested", 2: "Resuggested", 3: "Approved", 4: "Declined", 5: "Translated")
-
- if (!isVisible()) return;
-
- if (mode < 0 || mode > 5) return;
-
- var display = "none";
- var txtApprove = "ready for Admin";
- var txtDecline = "ready for removal";
- var txtSuggest = "suggestion";
-
- var trKeys = document.querySelectorAll("#keylist > table:nth-child(1) > tbody:nth-child(1) > tr");
- for (var i = 0; i < trKeys.length; i++)
- {
- if (trKeys[i].style.display != display)
- {
- var curMode = -1;
-
- var eleCounter = trKeys[i].querySelector("tr.copysmall > td:nth-child(3)");
- if (eleCounter != null)
- {
-
- var txtCounter = eleCounter.textContent.trim();
- if (txtCounter.indexOf(txtApprove) > -1)
- {
- curMode = 3; // Approved
- }
- else if (txtCounter.indexOf(txtDecline) > -1)
- {
- curMode = 4; // Declined
- }
- else if (txtCounter.indexOf(txtSuggest) > -1)
- {
- var eleNotTranslated = trKeys[i].querySelector("span.token_nottranslated");
- if (eleNotTranslated != null)
- {
- curMode = 1; // Suggested
- }
- else
- {
- curMode = 2; // Resuggested
- }
- }
- else
- {
- var eleNotTranslated = trKeys[i].querySelector("span.token_nottranslated");
- if (eleNotTranslated != null)
- {
- curMode = 0; // Not Translated
- }
- else
- {
- curMode = 5; // Translated
- }
- }
- }
-
- if (curMode == mode)
- {
- trKeys[i].style.display = display;
- }
- }
- }
- }
-
- var itvTime = 300;
- var itvIdHider = [0, 0, 0, 0, 0, 0];
-
- var eleBtnShowings = document.querySelectorAll("#stsh_showing_notTranslated, #stsh_showing_suggested, #stsh_showing_resuggested"
- + ", #stsh_showing_approved, #stsh_showing_declined, #stsh_showing_translated");
- if (eleBtnShowings.length == 6)
- {
- for (var i = 0; i < eleBtnShowings.length; i++)
- {
- eleBtnShowings[i].param = i;
- eleBtnShowings[i].addEventListener("click", function(ev)
- {
- var mode = ev.target.param;
-
- clearInterval(itvIdHider[mode]);
- itvIdHider[mode] = setIntervalCustom(function(ev)
- {
- hideSuggestions(mode);
- }, itvTime);
-
- hideSuggestions(mode);
- countShowing();
- eleBtnShowings[mode].setAttribute("disabled", "disabled");
- });
- }
-
- var eleBtnShowAll = document.querySelector("#stsh_showing_all");
- if (eleBtnShowAll != null)
- {
- eleBtnShowAll.addEventListener("click", function()
- {
- for (var i = 0; i < eleBtnShowings.length; i++)
- {
- clearInterval(itvIdHider[i]);
- countShowing();
- eleBtnShowings[i].removeAttribute("disabled");
- }
- });
- }
- }
-
- } // End Hide suggestions
-
- resizeSuggestionBox();
-
- // Add Frame button when iframe load failed
- {
- var ifrm = document.querySelector("#suggestions_iframe");
- if (ifrm != null)
- {
- ifrm.addEventListener("DOMAttrModified", function (ev)
- {
- if (ev.attrName === "src")
- {
- var divFrame = document.querySelector("#stsh_frame");
- if (divFrame == null)
- {
- var divOuter = document.querySelector("#suggestions_box_outer");
- if (divOuter != null)
- {
- divFrame = document.createElement("div");
- divFrame.id = "stsh_frame";
- divOuter.appendChild(divFrame);
- }
- }
- if (divFrame != null)
- {
- var src = ifrm.getAttribute("src");
- divFrame.innerHTML = '<br/> <a class="stsh_a_button" target="_blank" '
- + ' href="' + src + '">Frame</a> ';
- }
- }
- }, false);
- }
- }
-
- } // End translate.php
-
- if (url.indexOf("user_activity.php") > -1)
- {
- var user = "";
- var eleAvatar = document.querySelector(".friend_block_avatar > a[href^='https://steamcommunity.com']");
- if (eleAvatar != null)
- {
- eleAvatar.href = eleAvatar.href.replace("https://steamcommunity.com", "http://steamcommunity.com");
-
- if (eleAvatar.href.indexOf("http://steamcommunity.com/profiles/") == 0)
- {
- user = eleAvatar.href.replace("http://steamcommunity.com/profiles/", "");
- }
-
- var name = eleAvatar.firstElementChild.getAttribute("title");
- if (name == "")
- {
- name = user;
- }
- document.title = name + " - " + document.title;
- }
-
- var stsh_activityAddLink_start = new Date();
- var stsh_activityAddLink_itv = setIntervalCustom(function(user)
- {
- var stsh_activityAddLink_isEnd = false;
- var stsh_activityAddLink_cur = new Date();
-
- var h3s = document.querySelectorAll("#leftAreaContainer h3");
- if (h3s.length == 2)
- {
- var td = h3s[1].parentElement;
- var matchArr = td.innerHTML.match(/<\/h3>.+<br>/i);
- if (matchArr != null)
- {
- var name = matchArr[0].replace("</h3>-","").replace("-<br>","").replace("<br>","").trim();
- if (name == "")
- {
- name = user;
- }
- if (name == "")
- {
- name = "Steam";
- }
-
- var tagNew = "";
- if (user == "")
- {
- tagNew = "</h3><a id='stsh_id' class='stsh_blue' target='_blank' href='http://steamcommunity.com/my'>" + name + "</a>"
- + ", <a class='stsh_green' target='_blank' href='http://translation.steampowered.com/WhereIsEsty.php'>Esty</a><br><br>";
- }
- else
- {
- tagNew = "</h3><a id='stsh_id' class='stsh_blue' target='_blank' href='http://steamcommunity.com/profiles/"
- + user + "'>" + name + "</a>"
- + ", <a class='stsh_green' target='_blank' href='http://translation.steampowered.com/WhereIsEsty.php?collectionof="
- + user + "'>Esty</a>"
- /*+ ", <a class='stsh_green' target='_blank' href='http://translation.steampowered.com/translate.php?user="
- + user + "&onionhunter=1&liststatus=1'>Onion</a>*/
- + " <br><br> ";
- }
- td.innerHTML = td.innerHTML.replace(/<\/h3>.+<br>/i, tagNew);
-
- stsh_activityAddLink_isEnd = true;
- }
-
- if (stsh_activityAddLink_isEnd || stsh_activityAddLink_cur - stsh_activityAddLink_start > 10000)
- {
- clearInterval(stsh_activityAddLink_itv);
- }
- }
- }, 300, user);
-
- var countWord = "";
- var countSugg = "";
-
- var inputDials = document.querySelectorAll("#leftAreaContainer input.dial");
- if (inputDials.length == 2)
- {
- countWord = inputDials[0].getAttribute("title").replace("words", "").trim();
- countSugg = inputDials[1].getAttribute("title").replace("suggestions", "").trim();
- }
-
- var tdCount = document.querySelector("#leftAreaContainer td[align='left']");
- if (tdCount != null)
- {
- tdCount.innerHTML = '<div style="width: 100px; display: inline-block; text-align: center;">Word: '
- + countWord + '</div> <div style="width: 100px; display: inline-block; text-align: center; margin-left: 13px;">Suggestion: '
- + countSugg + '</div>';
- }
-
- var sug = document.body.textContent;
-
- var regComment = /VIEW COMMENT/g;
- var regSuggest = /VIEW SUGGESTION/g;
-
- var strComment = "...RECEIVED A MODERATOR COMMENT";
- var strPending = "...ARE PENDING";
- var strApproved = "...WERE APPROVED";
- var strDeclined = "...WERE DECLINED";
- var strApplied = "...HAVE BEEN APPLIED WITHIN THE LAST 14 DAYS";
- var strRemoved = "...HAVE BEEN REMOVED WITHIN THE LAST 14 DAYS";
-
- var startComment = sug.indexOf(strComment);
- var startPending = sug.indexOf(strPending);
- var startApproved = sug.indexOf(strApproved);
- var startDeclined = sug.indexOf(strDeclined);
- var startApplied = sug.indexOf(strApplied);
- var startRemoved = sug.indexOf(strRemoved);
-
- var sugComment = sug.substring(startComment,startPending);
- var sugPending = sug.substring(startPending,startApproved);
- var sugApproved = sug.substring(startApproved,startDeclined);
- var sugDeclined = sug.substring(startDeclined,startApplied);
- var sugApplied = sug.substring(startApplied,startRemoved);
- var sugRemoved = sug.substring(startRemoved);
-
- var countComment = (sugComment.match(regComment) || []).length;
- var countPending = (sugPending.match(regSuggest) || []).length;
- var countApproved = (sugApproved.match(regSuggest) || []).length;
- var countDeclined = (sugDeclined.match(regSuggest) || []).length;
- var countApplied = (sugApplied.match(regSuggest) || []).length;
- var countRemoved = (sugRemoved.match(regSuggest) || []).length;
-
- var divBtn = document.createElement("div");
- document.body.appendChild(divBtn);
- divBtn.innerHTML = ' \
- <div style="position: fixed; z-index: 3; right: 12px; top: 84px; line-height: 24px; text-align: right;"> \
- <input value="To Progress" class="stsh_btn_long" type="button" onmouseup="scrollToId(\'stsh_id\', -50); return false;" /> \
- \
- <br/> <span class="stsh_scroll_header">Scroll To</span>\
- <br/> <input value="Comment (' + countComment + ')" class="stsh_btn_long" type="button" onmouseup="scrollToId(\'sectionComment\'); return false;" /> \
- <br/> <input value="Pending (' + countPending + ')" class="stsh_btn_long" type="button" onmouseup="scrollToId(\'sectionPending\'); return false;" /> \
- <br/> <input value="Approved (' + countApproved + ')" class="stsh_btn_long" type="button" onmouseup="scrollToId(\'sectionApproved\'); return false;" /> \
- <br/> <input value="Declined (' + countDeclined + ')" class="stsh_btn_long" type="button" onmouseup="scrollToId(\'sectionDeclined\'); return false;" /> \
- <br/> <input value="Applied (' + countApplied + ')" class="stsh_btn_long" type="button" onmouseup="scrollToId(\'sectionApplied\'); return false;" /> \
- <br/> <input value="Removed (' + countRemoved + ')" class="stsh_btn_long" type="button" onmouseup="scrollToId(\'sectionRemoved\'); return false;" /> \
- <br/> \
- <br/> <input value="Hide Suggestions" class="stsh_btn_long" type="button" onmouseup="hideSuggestion(); return false;" /> \
- <br/> <input value="Show Suggestions" class="stsh_btn_long" type="button" onmouseup="showSuggestion(); return false;" /> \
- <br/> \
- <br/> <input value="Refresh" class="stsh_btn_long" type="button" onmouseup="window.location = window.location.href; return false;" /> \
- </div> \
- ';
-
- var divContainer = document.querySelector("#leftAreaContainer");
- if (divContainer != null)
- {
- divContainer.innerHTML = divContainer.innerHTML
- .replace("...RECEIVED A MODERATOR COMMENT","<span id='sectionComment' class='stsh_suggestion_header'>...RECEIVED A MODERATOR COMMENT (" + countComment + ")</span>")
- .replace("...ARE PENDING","<span id='sectionPending' class='stsh_suggestion_header'>...ARE PENDING (" + countPending + ")</span>")
- .replace("...WERE APPROVED","<span id='sectionApproved' class='stsh_suggestion_header'>...WERE APPROVED (" + countApproved + ")</span>")
- .replace("...WERE DECLINED","<span id='sectionDeclined' class='stsh_suggestion_header'>...WERE DECLINED (" + countDeclined + ")</span>")
- .replace("...HAVE BEEN APPLIED WITHIN THE LAST 14 DAYS","<span id='sectionApplied' class='stsh_suggestion_header'>...HAVE BEEN APPLIED WITHIN THE LAST 14 DAYS (" + countApplied + ")</span>")
- .replace("...HAVE BEEN REMOVED WITHIN THE LAST 14 DAYS","<span id='sectionRemoved' class='stsh_suggestion_header'>...HAVE BEEN REMOVED WITHIN THE LAST 14 DAYS (" + countRemoved + ")</span>");
- }
-
- var cans = document.querySelectorAll("canvas");
- for (var i = 0; i < cans.length; i++)
- {
- cans[i].parentElement.removeChild(cans[i]);
- }
-
- var aKeys = document.querySelectorAll("#leftAreaContainer li > a:nth-child(1)");
- for (var i = 0; i < aKeys.length; i++)
- {
- var key = aKeys[i].textContent;
- var keyArr = key.substr(21).trim().split(" >> ");
- keyArr[0] = "<span style='color: #FFF !important;'>" + keyArr[0] + "</span>";
- var keyNew = key.substr(0,21) + keyArr.join(" >> ") + "";
- aKeys[i].innerHTML = keyNew;
- }
-
- var liMode = strComment;
-
- var liSugs = document.querySelectorAll("#leftAreaContainer > li, #leftAreaContainer > form > li");
- for (var i = 0; i < liSugs.length; i++)
- {
- if (liMode == strComment)
- {
- liSugs[i].setAttribute("class", "stsh_suggestion stsh_suggestion_comment");
- }
- else if (liMode == strPending)
- {
- liSugs[i].setAttribute("class", "stsh_suggestion stsh_suggestion_pending");
- }
- else if (liMode == strApproved)
- {
- liSugs[i].setAttribute("class", "stsh_suggestion stsh_suggestion_approved");
- }
- else if (liMode == strDeclined)
- {
- liSugs[i].setAttribute("class", "stsh_suggestion stsh_suggestion_declined");
- }
- else if (liMode == strApplied)
- {
- liSugs[i].setAttribute("class", "stsh_suggestion stsh_suggestion_applied");
- }
- else if (liMode == strRemoved)
- {
- liSugs[i].setAttribute("class", "stsh_suggestion stsh_suggestion_removed");
- }
-
- var content = liSugs[i].textContent;
- if (content.indexOf(strRemoved) > -1)
- {
- liMode = strRemoved;
- }
- else if (content.indexOf(strApplied) > -1)
- {
- liMode = strApplied;
- }
- else if (content.indexOf(strDeclined) > -1)
- {
- liMode = strDeclined;
- }
- else if (content.indexOf(strApproved) > -1)
- {
- liMode = strApproved;
- }
- else if (content.indexOf(strPending) > -1)
- {
- liMode = strPending;
- }
- }
-
- // Change language & correct url
- {
- var aProgresses = document.querySelectorAll("div > .friend_block_avatar a[onmouseout]");
- for (var i = 0; i < aProgresses.length; i++)
- {
- var langCur = getQueryByName("lang", aProgresses[i].href);
- if (langCur == "")
- {
- aProgresses[i].href = aProgresses[i].href + lang;
- }
- else
- {
- if (langCur != lang)
- {
- var langQuery = (url.indexOf("?") > -1) ? "&lang=" : "?lang=";
- window.location = url + langQuery + langCur;
- }
- }
-
- var aContent = aProgresses[i].textContent.trim();
- if (aContent.indexOf("SUGGESTIONS") > -1)
- {
- aProgresses[i].href = aProgresses[i].href + "&listsort=5&liststatus=1&paginationrows=1000";
- }
- else if (aContent.indexOf("REVIEWS") > -1)
- {
- aProgresses[i].href = aProgresses[i].href + "&listsort=5&liststatus=3&paginationrows=1000";
- }
- }
- }
-
- // Add hours calculator
- {
- var eleFinalize = document.querySelector("#hours input[name='Finalize']");
- if (eleFinalize != null)
- {
- var eleFinalizeParent = eleFinalize.parentElement;
- eleFinalizeParent.setAttribute("colspan", "2");
- eleFinalizeParent.style.verticalAlign = "top";
-
- var elePad = document.createElement("td");
- insertBeforeElement(elePad, eleFinalizeParent);
-
- var eleCalc = document.createElement("td");
- eleCalc.classList.add("stsh_hoursCalc");
-
- insertBeforeElement(eleCalc, eleFinalizeParent);
-
- var ele = document.createElement("b");
- ele.textContent = " Hours Calculator ";
- eleCalc.appendChild(ele);
-
- ele = document.createElement("br");
- eleCalc.appendChild(ele);
-
- var ele = document.createElement("span");
- ele.innerHTML = " Enter date or time to calculate range (calculate only hours and minutes). "
- + "<br/>You can enter date \"2016-01-01 08:05:00\" or time \"08:05:00\" or time \"8:05\".";
- ele.setAttribute("style", "display: inline-block; padding-bottom: 4px;");
- eleCalc.appendChild(ele);
-
- ele = document.createElement("br");
- eleCalc.appendChild(ele);
-
- var ele = document.createElement("span");
- ele.textContent = " From: ";
- eleCalc.appendChild(ele);
-
- var ele = document.createElement("input");
- ele.id = "stsh_hoursCalc_from"
- ele.setAttribute("type", "text");
- ele.setAttribute("onkeypress", "return event.keyCode != 13;");
- ele.addEventListener("keyup", function()
- {
- calculateHours();
- });
- eleCalc.appendChild(ele);
-
- var ele = document.createElement("span");
- ele.innerHTML = " To: ";
- eleCalc.appendChild(ele);
-
- var ele = document.createElement("input");
- ele.id = "stsh_hoursCalc_to"
- ele.setAttribute("type", "text");
- ele.setAttribute("onkeypress", "return event.keyCode != 13;");
- ele.addEventListener("keyup", function()
- {
- calculateHours();
- });
- eleCalc.appendChild(ele);
-
- var ele = document.createElement("span");
- ele.innerHTML = " Result: ";
- eleCalc.appendChild(ele);
-
- var ele = document.createElement("b");
- ele.id = "stsh_hoursCalc_result"
- ele.textContent = " 00:00 ";
- eleCalc.appendChild(ele);
-
- function calculateHours()
- {
- var rgxDate = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/;
- var rgxTime = /^\d{1,2}:\d{2}(:\d{2})?$/;
-
- var eleFrom = document.querySelector("#stsh_hoursCalc_from");
- var eleTo = document.querySelector("#stsh_hoursCalc_to");
- var eleRes = document.querySelector("#stsh_hoursCalc_result");
-
- if (eleFrom != null && eleTo != null && eleRes != null)
- {
- var rawFrom = eleFrom.value.trim();
- var rawTo = eleTo.value.trim();
-
- var valFrom = 0;
- var valTo = 0;
-
- if (rgxDate.test(rawFrom))
- {
- rawFrom = rawFrom.substr(11);
- }
- if (rgxTime.test(rawFrom))
- {
- var arrTime = rawFrom.split(":");
- valFrom = parseInt(arrTime[1]) + (parseInt(arrTime[0]) * 60);
- }
-
- if (rgxDate.test(rawTo))
- {
- rawTo = rawTo.substr(11);
- }
- if (rgxTime.test(rawTo))
- {
- var arrTime = rawTo.split(":");
- valTo = parseInt(arrTime[1]) + (parseInt(arrTime[0]) * 60);
- }
-
- var valDiff = Math.abs(valTo - valFrom);
-
- var valHr = parseInt(valDiff / 60);
- var valMn = valDiff % 60;
-
- eleRes.textContent = padZero(valHr, 2) + ":" + padZero(valMn, 2);
- }
- }
- }
- }
-
- } // End user_activity.php
-
- if (/\/rally[0-9]{0,4}/.test(url))
- {
- resizeSuggestionBox();
-
- var outer = document.getElementById("suggestions_box_outer");
- if (outer != null)
- {
- outer.setAttribute("onclick","hideSuggestionsBox();");
- }
-
- // Set cur lang to first
- {
- var first = document.querySelector(".gradienttable tr:nth-child(6)");
- var cur = null;
-
- var tdLangs = document.querySelectorAll(".gradienttable tr > td:nth-child(1)");
- for (var i = 0; i < tdLangs.length; i++)
- {
- if (lang == tdLangs[i].textContent.trim().toLowerCase())
- {
- cur = tdLangs[i].parentElement;
- break;
- }
- }
-
- if (cur != null)
- {
- first.parentElement.insertBefore(cur, first);
- }
- }
-
- // Change row per page
- {
- var eleAs = document.querySelectorAll(".gradienttable tr:nth-child(6) a[href^='translate.php?']");
- for (var i = 0; i < eleAs.length; i++)
- {
- eleAs[i].href = eleAs[i].href + "&paginationrows=1000";
- }
- }
-
- var inputClose = document.querySelector("td:nth-child(3) > input:nth-child(1)");
- if (inputClose != null)
- {
- inputClose.value = "Close (Esc)";
- }
-
- } // End rally.php
-
- if (/\/rally_results_?[0-9]{0,4}/.test(url))
- {
- var h3 = document.querySelector("table.curved h3");
- if (h3 != null)
- {
- document.title = h3.textContent.trim();
- }
-
- var inputClose = document.querySelector("td:nth-child(3) > input:nth-child(1)");
- if (inputClose != null)
- {
- inputClose.value = "Close (Esc)";
- inputClose.focus();
- }
-
- var src = document.documentURI;
- var insert = ' <a class="stsh_a_button" target="_blank" '
- + ' href="' + src + '">Frame</a> ';
-
- var tdFirst = document.querySelector("td:nth-child(1)");
- if (tdFirst != null)
- {
- var ele = document.createElement("td");
- ele.setAttribute("align", "right");
- ele.innerHTML = insert;
- tdFirst.parentElement.insertBefore(ele, tdFirst);
- }
-
- var inputPrev = document.querySelector("input[value^='Prev']");
- if (inputPrev != null)
- {
- addKeyCtrl(document, inputPrev, 219, "["); // [
- addKeyCtrl(document, inputPrev, "BracketLeft", ""); // [
- //addKeyCtrl(document, inputPrev, 0, ""); // [
- //addKeyCtrl(document, inputPrev, 53, ""); // [
-
- disableAfterClick(inputPrev);
- }
-
- var inputNext = document.querySelector("input[value^='Next']");
- if (inputNext != null)
- {
- addKeyCtrl(document, inputNext, 221, "]"); // ]
- addKeyCtrl(document, inputNext, "BracketRight", ""); // ]
- //addKeyCtrl(document, inputNext, 188, ""); // ]
- //addKeyCtrl(document, inputNext, 173, ""); // ]
- //addKeyCtrl(document, inputNext, 169, ""); // ]
-
- disableAfterClick(inputNext);
- }
-
- } // End rally_results.php
-
- if (url.indexOf("/WhereIsEsty.php") > -1)
- {
- resizeSuggestionBox();
-
- var outer = document.getElementById("suggestions_box_outer");
- if (outer != null)
- {
- outer.setAttribute("onclick","hideSuggestionsBox();");
- }
-
- var divContainer = document.querySelector("#pageContainer");
- if (divContainer != null)
- {
- var ele = document.createElement("div");
- ele.id = "logout";
- ele.innerHTML = ' <a class="stsh_a_button" target="_blank" '
- + ' href="/home.php">Home</a> ';
- divContainer.appendChild(ele);
- }
-
- var divContent = document.querySelector("#leftAreaContainer > div");
- if (divContent != null)
- {
- var countSnap = document.querySelectorAll("div.box").length;
- var user = "";
- var name = "";
-
- var eleImg = document.querySelector("#leftAreaContainer > div > div > a > img ");
- if (eleImg != null)
- {
- name = eleImg.getAttribute("title");
- user = eleImg.parentElement.getAttribute("href").replace("https://steamcommunity.com/profiles/", "");
- }
- var ele = document.createElement("div");
- ele.setAttribute("class", "stsh_snapshot");
- ele.innerHTML = "<a class='stsh_blue' target='_blank' href='http://translation.steampowered.com/user_activity.php?user="
- + user + "'>" + name + "</a>"
- + "<br>Snapshot: " + countSnap;
-
- divContent.appendChild(ele);
- }
-
- } // End WhereIsEsty.php
-
- if (url.indexOf("/stickerbox.php") > -1)
- {
- document.querySelector("textarea[name='add_comment']").focus();
-
- var inputPrev = document.querySelector("img[src*='previous.png'");
- if (inputPrev != null)
- {
- addKeyCtrl(document, inputPrev, 219, ""); // [
- addKeyCtrl(document, inputPrev, "BracketLeft", ""); // [
- //addKeyCtrl(document, inputPrev, 0, ""); // [
- //addKeyCtrl(document, inputPrev, 53, ""); // [
-
- disableAfterClick(inputPrev);
- }
-
- var inputNext = document.querySelector("img[src*='next.png'");
- if (inputNext != null)
- {
- addKeyCtrl(document, inputNext, 221, ""); // ]
- addKeyCtrl(document, inputNext, "BracketRight", ""); // ]
- //addKeyCtrl(document, inputNext, 188, ""); // ]
- //addKeyCtrl(document, inputNext, 173, ""); // ]
- //addKeyCtrl(document, inputNext, 169, ""); // ]
-
- disableAfterClick(inputNext);
- }
- } // End stickerbox.php
-
- if (/\/(home|index)/i.test(url))
- {
- // Set cur lang to first
- {
- var first = null;
- var cur = null;
- var curLang = lang.substring(0, 4);
-
- if (curLang == "schi")
- curLang = "sim.";
- else if (curLang == "tchi")
- curLang = "tra.";
-
- var eleLangs = document.querySelectorAll("#overall .progress");
- first = eleLangs[0];
- for (var i = 0; i < eleLangs.length; i++)
- {
- if (curLang == eleLangs[i].textContent.trim().substring(0, 4).toLowerCase())
- {
- cur = eleLangs[i];
- break;
- }
- }
-
- if (cur != null)
- {
- var curSib1 = cur.nextSibling;
- var curSib2 = curSib1.nextSibling;
- var curSib3 = curSib2.nextSibling;
- var curSib4 = curSib3.nextSibling;
- var curSib5 = curSib4.nextSibling;
- var curSib6 = curSib5.nextSibling;
-
- insertBeforeElement(cur, first);
- insertAfterElement(curSib6, cur);
- insertAfterElement(curSib5, cur);
- insertAfterElement(curSib4, cur);
- insertAfterElement(curSib3, cur);
- insertAfterElement(curSib2, cur);
- insertAfterElement(curSib1, cur);
- }
- }
-
- if (document.querySelector("#logout") != null)
- {
- var tmplHome = ' \
- <div class="stsh_home_group"> \
- <span class="stsh_home_header">Shortcuts</span>\
- <br/> <a class="stsh_a_button stsh_btn_med" target="_blank" href="/translate.php?search_input=DATE%3A+%DATE%&paginationrows=1000">New Today</a> \
- <br/> <a class="stsh_a_button stsh_btn_med" target="_blank" href="/glossary.php">Glossary</a> \
- \
- <br/> <span class="stsh_home_header">Rally</span>\
- <br/> <a class="stsh_a_button stsh_btn_med" target="_blank" href="/rally.php">Rally 2015</a> \
- <br/> <a class="stsh_a_button stsh_btn_med" target="_blank" href="/rally2014.php">Rally 2014</a> \
- <br/> <a class="stsh_a_button stsh_btn_med" target="_blank" href="/rally2013.php">Rally 2013</a> \
- \
- <br/> <span class="stsh_home_header">Events</span>\
- <br/> <a class="stsh_a_button stsh_btn_med" target="_blank" href="/onionolooorm.php">Typonion</a> \
- <br/> <a class="stsh_a_button stsh_btn_med" target="_blank" href="/dstbattle.php">DST Battle</a> \
- <br/> <a class="stsh_a_button stsh_btn_med" target="_blank" href="/dota2.php">DOTA 2</a> \
- </div> \
- ';
-
- var curDate = new Date();
- curDate.setTime(curDate.getTime() - (1000 * 60 * 60 * 8));
-
- if (isDstUsa(curDate.getUTCFullYear(), curDate.getUTCMonth() + 1, curDate.getUTCDate(), curDate.getUTCHours()))
- {
- curDate.setTime(curDate.getTime() + (1000 * 60 * 60 * 1));
- }
-
- tmplHome = tmplHome.replace("%DATE%", curDate.toISOString().substr(0, 10));
-
- var eleNew = document.createElement("div");
-
- eleNew.innerHTML = tmplHome;
-
- document.body.appendChild(eleNew);
- }
-
- } // End home.php
-
- if (url.indexOf("/glossary.php") > -1)
- {
-
- } // End glossary.php
-
- window.addEventListener("beforeunload", function (e)
- {
- clearTimeoutAll();
- clearIntervalAll();
- });
-
- } // End Main
-
- function client()
- {
- var clientScript = ' \
- \
- var itvTime = 300; \
- var itvIdHideKeyApp = 0; \
- var itvIdHideKeyGame = 0; \
- var itvIdHideKeyFaq = 0; \
- var itvIdHideKeySupport = 0; \
- var itvIdHideKeyPromo = 0; \
- var itvIdHideKeyEmail = 0; \
- var itvIdHideStrNotMatch = 0; \
- var itvIdHideStrLong = 0; \
- var itvIdSortKey = 0; \
- \
- var isVisible = (function() \
- { \
- var stateKey; \
- var eventKey; \
- var keys = \
- { \
- hidden: "visibilitychange", \
- webkitHidden: "webkitvisibilitychange", \
- mozHidden: "mozvisibilitychange", \
- msHidden: "msvisibilitychange" \
- }; \
- for (stateKey in keys) \
- { \
- if (stateKey in document) \
- { \
- eventKey = keys[stateKey]; \
- break; \
- } \
- } \
- return function(c) \
- { \
- if (c) \
- { \
- document.addEventListener(eventKey, c); \
- } \
- return !document[stateKey]; \
- } \
- })(); \
- \
- var timeoutList = new Array(); \
- var intervalList = new Array(); \
- \
- function setTimeoutCustom(func, tm, params) \
- { \
- var id = setTimeout(func, tm, params); \
- timeoutList.push(id); \
- return id; \
- } \
- \
- function clearTimeoutAll() \
- { \
- for (var i = 0; i < timeoutList.length; i++) \
- { \
- clearTimeout(timeoutList[i]); \
- } \
- } \
- \
- function setIntervalCustom(func, tm, params) \
- { \
- var id = setInterval(func, tm, params); \
- intervalList.push(id); \
- return id; \
- } \
- \
- function clearIntervalAll() \
- { \
- for (var i = 0; i < intervalList.length; i++) \
- { \
- clearInterval(intervalList[i]); \
- } \
- } \
- \
- function setVisibleKey(startKey, visible) \
- { \
- if (!isVisible()) return; \
- \
- startKey = startKey.toLowerCase(); \
- var display = visible != true ? "none" : ""; \
- 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)"); \
- for (var i = 0; i < eleKeys.length; i++) \
- { \
- try \
- { \
- if (eleKeys[i].textContent.trim().toLowerCase().indexOf(startKey) > -1) \
- { \
- var eleTarget = eleKeys[i].parentElement.parentElement.parentElement.parentElement.parentElement.parentElement; \
- if (eleTarget.style.display != display) \
- { \
- eleTarget.style.display = display; \
- } \
- } \
- } \
- catch (ex) \
- { \
- } \
- } \
- } \
- \
- function hideKeyGame() \
- { \
- setVisibleKey("GAMES/", false); \
- setVisibleKey("TF_", false); \
- } \
- \
- function hideKeyApp() \
- { \
- setVisibleKey("# storefront_english_apps.txt #", false); \
- setVisibleKey("# storefront_english_main.txt # #app_", false); \
- setVisibleKey("# community_english.txt # SharedFiles_App_", false); \
- setVisibleKey("# appmgmt_english.txt #", false); \
- } \
- \
- function hideKeyFaq() \
- { \
- setVisibleKey("# support_faq_english.txt #", false); \
- } \
- \
- function hideKeySupport() \
- { \
- setVisibleKey("# supportui_english.txt #", false); \
- setVisibleKey("# help_english.txt #", false); \
- } \
- \
- function hideKeyPromo() \
- { \
- setVisibleKey("#promo", false); \
- setVisibleKey("#hardware", false); \
- setVisibleKey("ControllerBinding", false); \
- setVisibleKey("Library_Controller", false); \
- } \
- \
- function hideKeyEmail() \
- { \
- setVisibleKey("#email", false); \
- } \
- \
- function showKey() \
- { \
- clearInterval(itvIdHideKeyApp); \
- clearInterval(itvIdHideKeyGame); \
- clearInterval(itvIdHideKeyFaq); \
- clearInterval(itvIdHideKeySupport); \
- clearInterval(itvIdHideKeyPromo); \
- clearInterval(itvIdHideKeyEmail); \
- clearInterval(itvIdSortKey); \
- clearInterval(itvIdHideStrNotMatch); \
- clearInterval(itvIdHideStrLong); \
- setVisibleKey("", true); \
- \
- hideSuggestionsBox(); \
- } \
- \
- function sortKey(mode) \
- { \
- /* \
- mode: \
- 1: key \
- 2: string \
- 3: word \
- 4: length \
- */ \
- if (!isVisible()) return; \
- \
- var keyArr = new Array(); \
- var valArr = new Array(); \
- var key; \
- var str; \
- \
- var dot = "..."; \
- var dotLengthMinus = 0 - dot.length; \
- var isDot = false; \
- \
- 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)"); \
- for (var i = 0; i < eleKeys.length; i++) \
- { \
- try \
- { \
- key = eleKeys[i].textContent.trim(); \
- str = ""; \
- isDot = false; \
- if (mode != 1) \
- { \
- str = eleKeys[i].parentElement.nextSibling.nextSibling.firstElementChild.textContent.trim(); \
- isDot = (str.substr(dotLengthMinus) == dot); \
- } \
- if (mode == 2) \
- { \
- key = str + " ___ " + key; \
- } \
- else if (mode == 3) \
- { \
- key = (isDot ? "99_" : "00_") \
- + padZero(str.split(" ").length, 2) + "_" + padZero(str.split(/[^a-z0-9 ]/i).length, 2) \
- + " ___ "+ str + " ___ " + key; \
- } \
- else if (mode == 4) \
- { \
- key = (isDot ? "99_" : "00_") \
- + (str.split(/[^a-z0-9]/i).length > 1 ? "99_" : "00_") \
- + padZero(str.length, 3) \
- + " ___ "+ str + " ___ " + key; \
- } \
- key = key.toLowerCase(); \
- keyArr.push(key); \
- valArr[key] = eleKeys[i].parentElement.parentElement.parentElement \
- .parentElement.parentElement.parentElement.outerHTML.trim(); \
- } \
- catch (ex) \
- { \
- } \
- } \
- \
- var keyArrTmp = keyArr.slice(); \
- keyArr.sort(); \
- \
- var isSame = true; \
- for (var i = 0; i < keyArr.length; i++) \
- { \
- if (keyArr[i] != keyArrTmp[i]) \
- { \
- isSame = false; \
- } \
- } \
- \
- if (!isSame) \
- { \
- var eleTable = document.querySelector("#keylist > table:nth-child(1) > tbody:nth-child(1)"); \
- if (eleTable != null) \
- { \
- var newInner = ""; \
- \
- for (var i = 0; i < keyArr.length; i++) \
- { \
- newInner += valArr[keyArr[i]]; \
- } \
- \
- eleTable.innerHTML = newInner; \
- } \
- } \
- } \
- \
- function scrollToId(id, offset) \
- { \
- if (typeof offset == "undefined") \
- { \
- offset = -20; \
- } \
- \
- var ele = document.getElementById(id); \
- if (ele != null) \
- { \
- ele.scrollIntoView(true); \
- window.scrollBy(0, offset); \
- } \
- } \
- \
- function setVisibleSuggestion(visible) \
- { \
- var display = visible != true ? "none" : ""; \
- var els = document.querySelectorAll(".copy"); \
- for (var i = 0; i < els.length; i++) \
- { \
- if (els[i].id.indexOf("showwalletkeys") < 0 && els[i].id != "abuse_report" \
- && els[i].id != "moderator_announcement") \
- { \
- if (els[i].style.display != display) \
- { \
- els[i].style.display = display; \
- } \
- } \
- } \
- } \
- \
- function showSuggestion() \
- { \
- setVisibleSuggestion(true); \
- } \
- \
- function hideSuggestion() \
- { \
- setVisibleSuggestion(false); \
- } \
- \
- function hideKeyAppInterval() \
- { \
- clearInterval(itvIdHideKeyApp); \
- itvIdHideKeyApp = setIntervalCustom(hideKeyApp, itvTime); \
- } \
- \
- function hideKeyGameInterval() \
- { \
- clearInterval(itvIdHideKeyGame); \
- itvIdHideKeyGame = setIntervalCustom(hideKeyGame, itvTime); \
- } \
- \
- function hideKeyFaqInterval() \
- { \
- clearInterval(itvIdHideKeyFaq); \
- itvIdHideKeyFaq = setIntervalCustom(hideKeyFaq, itvTime); \
- } \
- \
- function hideKeySupportInterval() \
- { \
- clearInterval(itvIdHideKeySupport); \
- itvIdHideKeySupport = setIntervalCustom(hideKeySupport, itvTime); \
- } \
- \
- function hideKeyPromoInterval() \
- { \
- clearInterval(itvIdHideKeyPromo); \
- itvIdHideKeyPromo = setIntervalCustom(hideKeyPromo, itvTime); \
- } \
- \
- function hideKeyEmailInterval() \
- { \
- clearInterval(itvIdHideKeyEmail); \
- itvIdHideKeyEmail = setIntervalCustom(hideKeyEmail, itvTime); \
- } \
- \
- function sortKeyInterval() \
- { \
- clearInterval(itvIdSortKey); \
- itvIdSortKey = setIntervalCustom(sortKey, itvTime, 1); \
- } \
- \
- function sortStringInterval() \
- { \
- clearInterval(itvIdSortKey); \
- itvIdSortKey = setIntervalCustom(sortKey, itvTime, 2); \
- } \
- \
- function sortWordInterval() \
- { \
- clearInterval(itvIdSortKey); \
- itvIdSortKey = setIntervalCustom(sortKey, itvTime, 3); \
- } \
- \
- function sortLengthInterval() \
- { \
- clearInterval(itvIdSortKey); \
- itvIdSortKey = setIntervalCustom(sortKey, itvTime, 4); \
- } \
- \
- function pressHideSuggestion() \
- { \
- document.addEventListener("keydown", function(e) { \
- if (e.keyCode == 27) { \
- if (parent != null) \
- { \
- parent.hideSuggestionsBox(); \
- } \
- else \
- { \
- hideSuggestionsBox(); \
- } \
- } \
- return false; \
- }); \
- } \
- pressHideSuggestion(); \
- \
- function hideStrNotMatch() \
- { \
- if (!isVisible()) return; \
- \
- var display = "none"; \
- \
- var searchStr = decodeURIComponent(document.documentURI.replace(/^.*search_input=/i,"").replace(/&.*$/i,"")) \
- .replace(/\\+/g," ").trim(); \
- searchStr = searchStr.toLowerCase(); \
- \
- 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)"); \
- for (var i = 0; i < eleStrs.length; i++) \
- { \
- try \
- { \
- var valStr = eleStrs[i].childElements()[0].textContent.trim().toLowerCase(); \
- var valTrn = eleStrs[i].childElements()[2].textContent.trim().toLowerCase(); \
- if (valStr != searchStr && valTrn != searchStr) \
- { \
- var eleTarget = eleStrs[i].parentElement.parentElement.parentElement.parentElement.parentElement; \
- if (eleTarget.style.display != display) \
- { \
- eleTarget.style.display = display; \
- } \
- } \
- } \
- catch (ex) \
- { \
- } \
- } \
- } \
- \
- function hideStrNotMatchInterval() \
- { \
- clearInterval(itvIdHideStrNotMatch); \
- itvIdHideStrNotMatch = setIntervalCustom(hideStrNotMatch, itvTime); \
- } \
- \
- function hideStrLong() \
- { \
- if (!isVisible()) return; \
- \
- var display = "none"; \
- var dot = "..."; \
- var dotLengthMinus = 0 - dot.length; \
- \
- 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)"); \
- for (var i = 0; i < eleStrs.length; i++) \
- { \
- try \
- { \
- var valStr = eleStrs[i].textContent.trim(); \
- if (valStr.substr(dotLengthMinus) == dot) \
- { \
- var eleTarget = eleStrs[i].parentElement.parentElement.parentElement.parentElement.parentElement.parentElement; \
- if (eleTarget.style.display != display) \
- { \
- eleTarget.style.display = display; \
- } \
- } \
- } \
- catch (ex) \
- { \
- } \
- } \
- } \
- \
- function hideStrLongInterval() \
- { \
- clearInterval(itvIdHideStrLong); \
- itvIdHideStrLong = setIntervalCustom(hideStrLong, itvTime); \
- } \
- \
- function clickToSelect(ele) \
- { \
- var range = document.createRange(); \
- range.setStartBefore(ele.firstChild); \
- range.setEndAfter(ele.lastChild); \
- var sel = window.getSelection(); \
- sel.removeAllRanges(); \
- sel.addRange(range); \
- } \
- \
- function syncUrlArray() \
- { \
- if (!isVisible()) return; \
- \
- var displayNone = "none"; \
- var strStart = "showSuggestionsBox( \'"; \
- var strEnd = "\' ); return false;"; \
- var strCur = "&list_id="; \
- var strAll = "&endnext="; \
- var regPos = /&list_id=\\d+&endnext=\\d+/g; \
- var isEdit = false; \
- var eleDivs = []; \
- var urls = []; \
- \
- var trKeys = document.querySelectorAll("#keylist > table:nth-child(1) > tbody:nth-child(1) > tr"); \
- for (var i = 0; i < trKeys.length; i++) \
- { \
- if (trKeys[i].style.display != displayNone) \
- { \
- var eleDiv = trKeys[i].childNodes[0].childNodes[0]; \
- if (typeof eleDiv.getAttribute != "undefined" \
- && eleDiv.getAttribute("onclick") != null) \
- { \
- eleDivs.push(eleDiv); \
- } \
- } \
- } \
- \
- for (var i = 0, l = eleDivs.length; i < l; i++) \
- { \
- var evOld = eleDivs[i].getAttribute("onclick"); \
- if (evOld != null) \
- { \
- var url = evOld.replace(strStart,"").replace(strEnd,"").replace(regPos,""); \
- url = url + strCur + i + strAll + l; \
- urls.push(url); \
- \
- var evNew = strStart + url + strEnd; \
- if (evOld != evNew) \
- { \
- eleDivs[i].setAttribute("onclick", evNew); \
- isEdit = true; \
- } \
- } \
- } \
- \
- if (isEdit || typeof URLarray == "undefined" || URLarray.length != urls.length) \
- { \
- URLarray = urls; \
- } \
- } \
- \
- function setFrameColor(color) \
- { \
- var frame = document.querySelector("div#suggestions_box iframe"); \
- if (frame != null) \
- { \
- if (frame.style.backgroundColor != color) \
- { \
- frame.style.setProperty("background-color", color, "important"); \
- } \
- } \
- } \
- \
- function padZero(num, size) \
- { \
- return (1e15+num+"").slice(-size); \
- } \
- \
- function doInstant() \
- { \
- var url = document.documentURI; \
- if (url.indexOf("user_activity.php") > -1) \
- { \
- showSuggestion(); \
- \
- document.addEventListener("DOMContentLoaded", function (e) \
- { \
- if (typeof $ != "undefined") \
- { \
- $(".dial").css("display", "none"); \
- setTimeoutCustom(function() \
- { \
- /* Restore drawing progress */ \
- $(function() { \
- $(".dial").css("display", ""); \
- $(".dial").knob({ \
- "draw" : function () { \
- $(this.i).val(this.cv + "%"); \
- } \
- }); \
- }) \
- }, 50); \
- } \
- }); \
- } \
- else if (url.indexOf("translate.php") > -1) \
- { \
- setIntervalCustom(function() \
- { \
- syncUrlArray(); \
- }, itvTime); \
- } \
- else if (url.indexOf("suggestions.php") > -1) \
- { \
- if (parent != window) \
- { \
- var main = document.querySelector("#suggestionmain"); \
- if (main != null) \
- { \
- var color = window.getComputedStyle(main).backgroundColor; \
- parent.setFrameColor(color); \
- } \
- } \
- } \
- \
- window.addEventListener("beforeunload", function (e) \
- { \
- clearTimeoutAll(); \
- clearIntervalAll(); \
- }); \
- \
- } \
- doInstant(); \
- \
- ';
-
- var eleClientScript = document.createElement("script");
- eleClientScript.innerHTML = clientScript;
- document.head.appendChild(eleClientScript);
- } // End client
-
- attachOnReady(client);
- attachOnReady(main);
-
-
-
- // End