Steam_Commit_Crypto

STEAM评测加密解密助手

目前為 2021-05-15 提交的版本,檢視 最新版本

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

QingJ © 2025

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