STEAM评测加密解密助手

快速加解密评测文本

  1. // ==UserScript==
  2. // @name Steam_Commit_Crypto
  3. // @name:zh-CN STEAM评测加密解密助手
  4. // @namespace https://blog.chrxw.com
  5. // @version 0.9
  6. // @description 快速加解密评测文本
  7. // @description:zh-CN 快速加解密评测文本
  8. // @author Chr_
  9. // @include /https://store\.steampowered\.com?/*.
  10. // @include /https://steamcommunity\.com?/*.
  11. // @require https://cdn.jsdelivr.net/gh/chr233/GM_Scripts@65475a39f3a5cef38f90b5ac29c560a4fdaee65d/Lib/Bear_Encode_Decode.js
  12. // @require https://cdn.jsdelivr.net/gh/chr233/GM_Scripts@65475a39f3a5cef38f90b5ac29c560a4fdaee65d/Lib/Basic_Crypto.js
  13. // @require https://cdn.jsdelivr.net/gh/chr233/GM_Scripts@65475a39f3a5cef38f90b5ac29c560a4fdaee65d/Lib/Morse_Code.js?
  14. // @require https://cdn.bootcdn.net/ajax/libs/crypto-js/4.0.0/crypto-js.min.js
  15. // @require https://cdn.jsdelivr.net/gh/chr233/GM_Scripts@65475a39f3a5cef38f90b5ac29c560a4fdaee65d/Lib/Core_Value_Encode.js
  16. // @connect steamcommunity.com
  17. // @license AGPL-3.0
  18. // @icon https://blog.chrxw.com/favicon.ico
  19. // @grant GM_xmlhttpRequest
  20. // @grant GM_setClipboard
  21. // ==/UserScript==
  22.  
  23. let G_ver = '0.9'; // 版本号
  24.  
  25. let G_CMode = 'syyz'; // 加密解密模式
  26.  
  27. const CryptoMode = { // 加解密模式
  28. // 'auto': ['自动猜测(非万能)', null, null],
  29. 'syyz': ['兽音译者', '兽音', bearEncode, bearDecode, '核心代码来自 https://github.com/sgdrg15rdg/beast_js'],
  30. // 'yflc': ['与佛论禅(在线)', '佛曰', yflcEncode, yflcDncode, '调用在线API http://hi.pcmoe.net/buddha.html'],
  31. 'shzy': ['核心价值观', '价值', valuesEncode, valuesDecode, '核心代码来自 https://github.com/sym233/core-values-encoder'],
  32. 'bs64': ['Base64', 'B64', base64Encode, base64Decode, '基于 Crypto JS'],
  33. 'msdm': ['摩尔斯电码', '摩尔斯', morseEncode, morseDecode, '核心代码来自 https://github.com/hustcc/xmorse'],
  34. };
  35.  
  36. const ValidElemtents = [ // 有效元素过滤器
  37. ['class', 'content'],
  38. ['id', 'ReviewText'],
  39. ['class', 'input_box'],
  40. ];
  41.  
  42. window.addEventListener('load', () => {
  43. 'use strict';
  44.  
  45. if (self != top && document.documentElement.scrollHeight < 200) {// 位于iframe中,不执行脚本
  46. return;
  47. }
  48.  
  49. addPanel();
  50.  
  51. window.addEventListener('mouseup', handleMouseUpEvent);
  52. window.addEventListener('mousedown', handleMouseDownEvent);
  53.  
  54. let bar = document.getElementById('sccTips');
  55. bar.style.visibility = 'hidden';
  56. });
  57.  
  58. // 添加GUI
  59. function addPanel() {
  60. function genButton(text, foo, id) {
  61. let b = document.createElement('button');
  62. b.textContent = text;
  63. b.style.cssText = 'vertical-align: inherit;padding: 0 5px;height: 24px;'
  64. b.addEventListener('click', foo);
  65. if (id) { b.id = id; }
  66. return b;
  67. }
  68. function genDiv(id) {
  69. let d = document.createElement('div');
  70. // d.style.cssText = 'vertical-align:middle;';
  71. if (id) { d.id = id };
  72. return d;
  73. }
  74. function genPanel(name, visiable) {
  75. let d = genDiv(name);
  76. d.style.cssText = 'background: rgba(58, 58, 58, 0.9);position: fixed;top: 50%;';
  77. d.style.cssText += 'text-align: center;transform: translate(0px, -50%);z-index: 1000;';
  78. d.style.cssText += 'border: 1px solid rgb(83, 83, 83);padding: 5px;';
  79. d.style.cssText += 'transition:right 0.8s;right:-350px;width:310px;font-size:14px;'
  80. if (visiable) {
  81. d.style.right = '0';
  82. }
  83. return d;
  84. }
  85. function genPanel2(name, visiable) {
  86. let d = genDiv(name);
  87. d.style.cssText = 'background: rgba(58, 58, 58, 0.9);position: fixed;';
  88. d.style.cssText += 'text-align: center;transform: translate(0px, -50%);z-index: 2000;';
  89. d.style.cssText += 'border: 1px solid rgb(83, 83, 83);padding: 2px;visibility: none';
  90. d.style.cssText += 'transition:visiable 0.8s;font-size:14px;'
  91. if (visiable) {
  92. d.style.visibility = 'visible';
  93. }
  94. return d;
  95. }
  96. function genLabel(text, bind) {
  97. let l = document.createElement('label');
  98. l.textContent = text;
  99. l.style.verticalAlign = 'inherit';
  100. if (bind) { l.setAttribute('for', bind); }
  101. return l;
  102. }
  103. function genA(text, url) {
  104. let a = document.createElement('a');
  105. a.textContent = text;
  106. a.href = url;
  107. return a;
  108. }
  109. function genSelect(id, choose, choice) {
  110. let s = document.createElement('select');
  111. s.id = id;
  112. s.style.cssText = 'color:#000;background:#fff;border:none;border-radius:0;vertical-align:inherit;width: 70%;height: 22px;';
  113. for (k in choose) {
  114. s.options.add(new Option(choose[k][0], k));
  115. }
  116. s.value = choice;
  117. for (let i = 0; i < s.childElementCount; i++) {
  118. s.children[i].style.background = '#fff';
  119. }
  120. return s;
  121. }
  122. function genSelect2(id) {
  123. let s = document.createElement('select');
  124. s.id = id;
  125. s.style.cssText = 'color:#000;background:#fff;border:none;border-radius:0;padding: 2px 0;margin: 0 2px;height: 22px;width: 50px;';
  126. s.options.add(new Option('解密', 'decode', true));
  127. s.options.add(new Option('加密', 'encode'));
  128. for (let i = 0; i < s.childElementCount; i++) {
  129. s.children[i].style.background = '#fff';
  130. }
  131. return s;
  132. }
  133. function genSpace() {
  134. let s = document.createElement('span');
  135. s.textContent = ' ';
  136. return s;
  137. }
  138. function genBr() {
  139. return document.createElement('br');
  140. }
  141. function genHr() {
  142. let h = document.createElement('hr');
  143. h.style.margin = '2px 0';
  144. return h;
  145. }
  146. function genTextArea(id, tips) {
  147. let t = document.createElement('textarea');
  148. if (id) { t.id = id; }
  149. if (tips) { t.placeholder = tips; }
  150. t.style.cssText = 'width: 98%;height: 100px;resize: vertical;font-size: 12px;';
  151. t.style.cssText += 'max-height:500px;background-color: #fff;padding: 2px;';
  152. return t;
  153. }
  154.  
  155. let panelFunc = genPanel('sccCtrl', false);
  156. document.body.appendChild(panelFunc);
  157.  
  158. let divTitle = genDiv();
  159. divTitle.style.marginBottom = '5px'
  160. let lblTitle = genLabel(`SCC - V ${G_ver} - By `, null);
  161. let lblUrl = genA('Chr_', 'https://steamcommunity.com/id/Chr_');
  162. let lblFeed = genA('[反馈]', 'https://blog.chrxw.com/scripts.html');
  163. let btnClose = genButton('关闭', () => { switchPanel(false); }, 'btnClose');
  164. btnClose.style.float = 'left';
  165.  
  166. divTitle.appendChild(lblTitle);
  167. divTitle.appendChild(lblUrl);
  168. divTitle.appendChild(genSpace());
  169. divTitle.appendChild(lblFeed);
  170. divTitle.appendChild(btnClose);
  171.  
  172. let txtInput = genTextArea('txtInput', '在这里输入密文');
  173.  
  174. let divMode = genDiv();
  175. let lblMode = genLabel('模式:', 'lblMode');
  176. let selMode = genSelect('selMode', CryptoMode, G_CMode);
  177. let btnHelp = genButton('?', showHelp, 'btnHelp');
  178.  
  179. divMode.style.marginBottom = '5px'
  180. divMode.appendChild(lblMode);
  181. divMode.appendChild(selMode);
  182. divMode.appendChild(genSpace());
  183. divMode.appendChild(btnHelp);
  184.  
  185. let divAction = genDiv()
  186. let btnDecode = genButton('解密↓', decode, 'btnDecode');
  187. let btnEncode = genButton('加密↑', encode, 'btnEncode');
  188. let btnExchange = genButton('交换↕', exchange, 'btnExchange');
  189. let btnCopyTxt = genButton('复制原文', copyTxt, 'btnCopyTxt');
  190. let btnCopyEnc = genButton('复制密文', copyEnc, 'btnCopyEnc');
  191. // let btnExtract = genButton('提取链接🌐', null, 'btnExchange');
  192.  
  193. divAction.style.marginBottom = '5px'
  194. divAction.appendChild(btnDecode);
  195. divAction.appendChild(genSpace());
  196. divAction.appendChild(btnEncode);
  197. divAction.appendChild(genSpace());
  198. divAction.appendChild(btnExchange);
  199. divAction.appendChild(genSpace());
  200. divAction.appendChild(btnCopyTxt);
  201. divAction.appendChild(genSpace());
  202. divAction.appendChild(btnCopyEnc);
  203. // divAction.appendChild(genSpace());
  204. // divAction.appendChild(btnExtract);
  205.  
  206. let txtOutput = genTextArea('txtOutput', '在这里输入明文');
  207.  
  208. panelFunc.appendChild(divTitle);
  209. panelFunc.appendChild(txtInput);
  210. panelFunc.appendChild(divMode);
  211. panelFunc.appendChild(divAction);
  212. panelFunc.appendChild(txtOutput);
  213.  
  214.  
  215. let panelTips = genPanel2('sccTips', false);
  216. document.body.appendChild(panelTips);
  217. let selBar = genSelect2('selBar');
  218. panelTips.appendChild(selBar);
  219.  
  220. for (let key in CryptoMode) {
  221. let name = CryptoMode[key][1];
  222. let btnFunc = genButton(name, () => { toolbarCallback(`${key}`); }, `btn${key}`);
  223. panelTips.appendChild(btnFunc);
  224. }
  225. }
  226.  
  227. // 加密
  228. function encode() {
  229. let m = document.getElementById('selMode');
  230. let i = document.getElementById('txtInput');
  231. let o = document.getElementById('txtOutput');
  232. let obj = CryptoMode[m.value][2];
  233. i.value = obj(o.value);
  234. }
  235. // 解密
  236. function decode() {
  237. let m = document.getElementById('selMode');
  238. let i = document.getElementById('txtInput');
  239. let o = document.getElementById('txtOutput');
  240. let obj = CryptoMode[m.value][3];
  241. o.value = obj(i.value);
  242. }
  243. // 交换明文密文
  244. function exchange() {
  245. let i = document.getElementById('txtInput');
  246. let o = document.getElementById('txtOutput');
  247. [i.value, o.value] = [o.value, i.value];
  248. }
  249.  
  250. // 鼠标松开事件(显示工具栏)
  251. function handleMouseUpEvent(event) {
  252. setTimeout(() => {
  253. let ele = event.target;
  254. let str = window.getSelection().toString();
  255. let bar = document.getElementById('sccTips');
  256.  
  257. if (str == "") { // 未选择文本,终止
  258. return;
  259. }
  260.  
  261. // 判断选中的文字是否处于特定的元素中
  262. for (let [key, value] of ValidElemtents) {
  263. let obj = ele.getAttribute(key);
  264. if (obj && obj.toString().indexOf(value) != -1) {
  265. console.log(str);
  266. console.log(key, value);
  267. let x, y;
  268. x = event.clientX + 15;
  269. y = event.clientY - 15;
  270. bar.style.left = `${x}px`;
  271. bar.style.top = `${y}px`;
  272. bar.style.visibility = 'visible';
  273. break;
  274. }
  275. }
  276. }, 200);
  277. }
  278. // 鼠标按下事件(隐藏工具栏)
  279. function handleMouseDownEvent(event) {
  280. let ele = event.target;
  281.  
  282. if (ele.parentElement.id != 'sccTips') {
  283.  
  284. let bar = document.getElementById('sccTips');
  285. if (bar.style.visibility != 'hidden') {
  286. bar.style.visibility = 'hidden';
  287. }
  288. }
  289.  
  290. }
  291.  
  292. // 工具栏回调
  293. function toolbarCallback(mode) {
  294. let m = document.getElementById('selMode');
  295. let bm = document.getElementById('selBar');
  296. let i = document.getElementById('txtInput');
  297. let o = document.getElementById('txtOutput');
  298. let b = document.getElementById('sccTips');
  299. let str = window.getSelection().toString();
  300. b.style.visibility = 'hidden';
  301. switchPanel(true);
  302. m.value = mode;
  303.  
  304. if (bm.value == 'encode') {
  305. o.value = str;
  306. encode();
  307. } else {
  308. i.value = str;
  309. decode();
  310. }
  311. }
  312.  
  313. // 显示/隐藏面板
  314. function switchPanel(mode) {
  315. let p = document.getElementById('sccCtrl');
  316.  
  317. if (mode === null) {
  318. if (p.style.right == '-350px') {
  319. p.style.right = '0';
  320. } else {
  321. p.style.right = '-350px';
  322. }
  323. } else {
  324. p.style.right = mode ? '0' : '-350px';
  325. }
  326. }
  327.  
  328. // 显示编码器信息
  329. function showHelp() {
  330. let m = document.getElementById('selMode');
  331. let msg = CryptoMode[m.value][4];
  332. ShowAlertDialog('编码器信息', msg);
  333. }
  334.  
  335. // 复制原文
  336. function copyTxt() {
  337. let o = document.getElementById('txtOutput');
  338. GM_setClipboard(o.value, { type: 'text', mimetype: 'text/plain' });
  339. }
  340.  
  341. // 复制密文
  342. function copyEnc() {
  343. let i = document.getElementById('txtInput');
  344. GM_setClipboard(i.value, { type: 'text', mimetype: 'text/plain' });
  345. }

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址