Arca base64 autodecoder

auto decode Base64 encoded link in Arca.live

当前为 2024-02-02 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Arca base64 autodecoder
  3. // @name:ko 아카라이브 Base64 자동 디코더
  4. // @version 1.223
  5. // @author Laria
  6. // @match https://arca.live/b/*/*
  7. // @description auto decode Base64 encoded link in Arca.live
  8. // @description:ko 아카라이브 내 Base64로 인코딩된 링크를 자동으로 복호화합니다.
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=arca.live
  10. // @require https://cdn.jsdelivr.net/npm/sweetalert2@11
  11. // @license MIT
  12. // @encoding utf-8
  13. // @run-at document-end
  14. // @supportURL https://greasyfork.org/ko/scripts/482577
  15. // @namespace https://greasyfork.org/users/1235854
  16. // @grant GM.getValue
  17. // @grant GM.setValue
  18. // @grant GM.deleteValue
  19. // @grant GM.registerMenuCommand
  20. // @grant GM.unregisterMenuCommand
  21. // @grant GM.setClipboard
  22. // ==/UserScript==
  23. /*
  24. * == Change log ==
  25. * 1.0 - Release
  26. * 1.1 - Invalid character update (replace -> replaceAll)
  27. * 1.11 - Improved show multiple links
  28. * 1.12 - Show Single links Bugfix
  29. * 1.13 - Bugfix 1.12
  30. * 1.14 - Base64 add padding func
  31. * 1.15 - Add annotation, display improvements
  32. * 1.16 - Display improved - CSS applied
  33. * 1.17 - var safe, max_iter defined (~7, def:3)
  34. * 1.18 - auto update check, log system
  35. * 1.20 - add menu(base64 depth, user-drag auto decoding, hide encoded link, update notify)
  36. * 1.201 - base64 depth extends - 11, temporary disable - drag auto decoding
  37. * 1.202 - improve encoded link click callback, feature block in edit mode, enable drag auto decoding
  38. * 1.203 - add menu(restore defaults)
  39. * 1.204 - set update check interval -> 1day(86400), seperate localparameter
  40. * 1.205 - url chk add(write), code stabilization
  41. * 1.206 - add menu(expand menu), newline, encoded link copy function, show url hostname
  42. * 1.207 - show total decoded count on article top, update link fix/improve redirection, update chk interval modify(86400 -> 21600)
  43. * 1.21 - window alert/confirm -> swal2 gui
  44. * 1.211 - version fix
  45. * 1.212 - remove unavailble function
  46. * 1.213 - show total decoded hostname, improve swal2 ui
  47. * 1.220 - notice when script updated, improve internal db, improve show encoded link, add show decode summary(and detected site hostname), encoded link show feature discontinued
  48. * 1.221 - scroll decoded link highlight, code optimization
  49. * 1.222 - minor bug fix
  50. * 1.223 - temporary disable update check, notice (update server change)
  51. */
  52.  
  53. /*
  54. * == TODO ==
  55. * auto decoding newline/space
  56. * detect channel => specific decoding
  57. * show warning message(redirection)
  58. * // @changelogURL https://arca.live/
  59. */
  60.  
  61. //base64 encoded(http:/*, https:/*) string prefix
  62. const regexEncodedPrefixDef = [
  63. /(aHR0cDovL|aHR0cHM6Ly)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //encoding 1 time
  64. /(YUhSMGNEb3ZM|YUhSMGNITTZMe)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //encoding 2 time
  65. /(WVVoU01HTkViM1pN|WVVoU01HTklUVFpNZ)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //encoding 3 time
  66. /(V1ZWb1UwMUhUa1ZpTTFwT|V1ZWb1UwMUhUa2xVVkZwTl)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //encoding 4 time
  67. /(VjFaV2IxVXdNVWhVYTFacFRURndU|VjFaV2IxVXdNVWhVYTJ4VlZrWndUb)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //encoding 5 time
  68. /(VmpGYVYySXhWWGROVldoVllURmFjRlJVUm5kV|VmpGYVYySXhWWGROVldoVllUSjRWbFpyV25kVW)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //encoding 6 time
  69. /(Vm1wR1lWWXlTWGhXV0dST1ZsZG9WbGxVUm1GalJsSlZVbTVrV|Vm1wR1lWWXlTWGhXV0dST1ZsZG9WbGxVU2pSV2JGcHlWMjVrVl)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //encoding 7 time
  70. /(Vm0xd1IxbFdXWGxUV0doWFYwZFNUMVpzWkc5V2JHeFZVbTFHYWxKc1NsWlZiVFZyV|Vm0xd1IxbFdXWGxUV0doWFYwZFNUMVpzWkc5V2JHeFZVMnBTVjJKR2NIbFdNalZyVm)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //encoding 8 time
  71. /(Vm0weGQxSXhiRmRYV0d4VVYwZG9XRll3WkZOVU1WcHpXa2M1VjJKSGVGWlZiVEZIWVd4S2MxTnNXbFppVkZaeV|Vm0weGQxSXhiRmRYV0d4VVYwZG9XRll3WkZOVU1WcHpXa2M1VjJKSGVGWlZNbkJUVmpKS1IyTkliRmROYWxaeVZt)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //encoding 9 time
  72. /(Vm0wd2VHUXhTWGhpUm1SWVYwZDRWVll3Wkc5WFJsbDNXa1pPVlUxV2NIcFhhMk0xVmpKS1NHVkdXbFppVkVaSVdWZDRTMk14VG5OWGJGcHBWa1phZ|Vm0wd2VHUXhTWGhpUm1SWVYwZDRWVll3Wkc5WFJsbDNXa1pPVlUxV2NIcFhhMk0xVmpKS1NHVkdXbFpOYmtKVVZtcEtTMUl5VGtsaVJtUk9ZV3hhZVZad)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //encoding 10 time
  73. /(Vm0wd2QyVkhVWGhUV0docFVtMVNXVll3WkRSV1ZsbDNXa2M1V0ZKc2JETlhhMXBQVmxVeFYyTkljRmhoTWsweFZtcEtTMU5IVmtkWGJGcHBWa1ZhU1ZkV1pEUlRNazE0Vkc1T1dHSkdjSEJXYTFwaF|Vm0wd2QyVkhVWGhUV0docFVtMVNXVll3WkRSV1ZsbDNXa2M1V0ZKc2JETlhhMXBQVmxVeFYyTkljRmhoTWsweFZtcEtTMU5IVmtkWGJGcE9ZbXRLVlZadGNFdFRNVWw1Vkd0c2FWSnRVazlaVjNoaFpWWmFk)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //encoding 11 time
  74. ];
  75.  
  76. //TODO
  77. const regexEncodedPrefixNewline1 = [
  78. /(Cmh0dHA6L|Cmh0dHBzOi8)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //with 1 newline, encoding 1 time
  79. /(Q21oMGRIQTZM|Q21oMGRIQnpPaT)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //with 1 newline, encoding 2 time
  80. /(UTIxb01HUklRVFpN|aaaa)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //with 1 newline, encoding 3 time
  81. /(VVRJeGIwMUhVa2xSVkZwT|aaaa)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //with 1 newline, encoding 4 time
  82. /(VlZSSmVHSXdNVWhWYTJ4U1ZrWndU|aaaa)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //with 1 newline, encoding 5 time
  83. /(VmxaU1NtVkhTWGROVldoV1lUSjRVMVpyV25kV|aaaa)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //with 1 newline, encoding 6 time
  84. /(Vm14YVUxTnRWa2hUV0dST1ZsZG9WMWxVU2pSVk1WcHlWMjVrV|aaaa)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //with 1 newline, encoding 7 time
  85. /(Vm0xNFlWVXhUblJXYTJoVVYwZFNUMVpzWkc5V01XeFZVMnBTVmsxV2NIbFdNalZyV|aaaa)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //with 1 newline, encoding 8 time
  86. /(Vm0weE5GbFdWWGhVYmxKWFlUSm9WVll3WkZOVU1WcHpXa2M1VjAxWGVGWlZNbkJUVm1zeFYyTkliRmROYWxaeV|aaaa)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //with 1 newline, encoding 9 time
  87. /(Vm0wd2VFNUdiRmRXV0doVllteEtXRmxVU205V1ZsbDNXa1pPVlUxV2NIcFhhMk0xVmpBeFdHVkdXbFpOYmtKVVZtMXplRll5VGtsaVJtUk9ZV3hhZV|aaaa)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //with 1 newline, encoding 10 time
  88. /(Vm0wd2QyVkZOVWRpUm1SWFYwZG9WbGx0ZUV0WFJteFZVMjA1VjFac2JETlhhMXBQVmxVeFYyTkljRmhoTWsweFZtcEJlRmRIVmtkWGJGcE9ZbXRLVlZadE1YcGxSbGw1Vkd0c2FWSnRVazlaVjNoaFpW|aaaa)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //with 1 newline, encoding 11 time
  89. ];
  90.  
  91. //TODO
  92. const regexEncodedPrefixNewline2 = [
  93. /(CgpodHRwOi8|CgpodHRwczov)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //with 2 newline, encoding 1 time
  94. /(|)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //with 2 newline, encoding 2 time
  95. /(|)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //with 2 newline, encoding 3 time
  96. /(|)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //with 2 newline, encoding 4 time
  97. /(|)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //with 2 newline, encoding 5 time
  98. /(|)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //with 2 newline, encoding 6 time
  99. /(|)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //with 2 newline, encoding 7 time
  100. /(|)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //with 2 newline, encoding 8 time
  101. /(|)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //with 2 newline, encoding 9 time
  102. /(|)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //with 2 newline, encoding 10 time
  103. /(|)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //with 2 newline, encoding 11 time
  104. ];
  105.  
  106. //TODO
  107. const regexEncodedPrefixSpace1 = [
  108. /(IGh0dHA6L|IGh0dHBzOi8)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //with 1 space, encoding 1 time
  109. /(|)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //with 1 space, encoding 2 time
  110. /(|)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //with 1 space, encoding 3 time
  111. /(|)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //with 1 space, encoding 4 time
  112. /(|)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //with 1 space, encoding 5 time
  113. /(|)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //with 1 space, encoding 6 time
  114. /(|)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //with 1 space, encoding 7 time
  115. /(|)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //with 1 space, encoding 8 time
  116. /(|)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //with 1 space, encoding 9 time
  117. /(|)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //with 1 space, encoding 10 time
  118. /(|)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //with 1 space, encoding 11 time
  119. ];
  120.  
  121. //TODO
  122. const regexEncodedPrefixSpace2 = [
  123. /(ICBodHRwOi8|ICBodHRwczov)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //with 2 space, encoding 1 time
  124. /(|)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //with 2 space, encoding 2 time
  125. /(|)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //with 2 space, encoding 3 time
  126. /(|)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //with 2 space, encoding 4 time
  127. /(|)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //with 2 space, encoding 5 time
  128. /(|)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //with 2 space, encoding 6 time
  129. /(|)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //with 2 space, encoding 7 time
  130. /(|)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //with 2 space, encoding 8 time
  131. /(|)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //with 2 space, encoding 9 time
  132. /(|)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //with 2 space, encoding 10 time
  133. /(|)(\w|=|\+|\/)*(?=[^\+=\w\/])/g, //with 2 space, encoding 11 time
  134. ];
  135.  
  136.  
  137. //internal db v2
  138. let abadInternalDB = {
  139. prototype01: {
  140. encodedLink: {
  141. abad_123456:{
  142. type: 'article',
  143. raw: 'aHR0cHM6Ly...',
  144. isEnabled: false, //click to true
  145. },
  146. },
  147. decodedLink: {
  148. abad_456789: {
  149. no: 1,
  150. type: 'article', //article, comment
  151. hostname: 'arca.live',
  152. title: 'first link',
  153. href: 'https://base64decode.org',
  154. srcid: 'abad_123456', //encoded
  155. },
  156. },
  157. },
  158. encodedLink: {},
  159. decodedLink: {},
  160. decodedList: [], //stack, increment
  161.  
  162. hostnameSetRaw: new Set(), //decoded link domain hostname set (non duplicate), raw data, type:set
  163. hostnameSet: [], //decoded link domain hostname set (non duplicate), sorted
  164. internalDB: {
  165. //auto decoding maximum
  166. autoDecodingMaximum:Math.min(regexEncodedPrefixDef.length, regexEncodedPrefixNewline1.length, regexEncodedPrefixNewline2.length, regexEncodedPrefixSpace1.length, regexEncodedPrefixSpace2.length),
  167. //total decode count
  168. totlaDecodedCount:0,//TODO
  169. //auto drag decoding enabled
  170. dragDecodingEnable:false,
  171. //SWAL2 enabled
  172. swal2Enable:false,
  173. },
  174. externalDB: { //GM
  175. decodeDeniedChannel:[],//proto
  176.  
  177. },
  178. };
  179.  
  180. const abadConstDB = {
  181. regInvalid: /[^\w\+\/=]/, //regex prefix - drag
  182. updateInterval: 21600, //update check interval (sec, def:1 day(86400))
  183.  
  184. //logging prefix
  185. logPrompt: {
  186. default: '['+GM.info.script.name+']',
  187. decodeManager: '['+GM.info.script.name+'-DEC]',
  188. updateManager: '['+GM.info.script.name+'-UPD]',
  189. paramManager: '['+GM.info.script.name+'-PAR]',
  190. },
  191. SWAL2Title: `<span style="font-size: 82.5%;">${('name:ko' in GM.info.script)?GM.info.script['name:ko']:GM.info.script.name}</span><i style="font-size: 40%;"> V ${GM.info.script.version} ${(GM.info.script.buildmode != undefined && GM.info.script.buildmode != '')?GM.info.script.buildmode:''}</i>`,
  192. };
  193. //`
  194.  
  195. //update chk, fail->false
  196. let updateAvailble = true;
  197.  
  198. //total decode count
  199. let hindex = 0;
  200.  
  201. //drag function comparison
  202. let lastSelected = document;
  203. let lastSelectedTime = Date.now();
  204.  
  205. //script local parameter
  206. let localParameter = {
  207. 'prevversion': {
  208. 'param_name': 'prevversion',
  209. 'value': -1.0,
  210. 'def_value': -1.0,
  211. },
  212. 'lastupdate': {
  213. 'param_name': 'lastupdate',
  214. 'value': 0,
  215. 'def_value': 0,
  216. },
  217. 'basedepth': {
  218. 'param_name': 'basedepth',
  219. 'value': 3,
  220. 'def_value': 3,
  221. },
  222. 'enclinkhide': { //func discontinued, reset default
  223. 'param_name': 'enclinkhide',
  224. 'value': false,
  225. 'def_value': false,
  226. },
  227. 'draggable': {
  228. 'param_name': 'draggable',
  229. 'value': false,
  230. 'def_value': false,
  231. },
  232. 'updatechk': {
  233. 'param_name': 'chkupd',
  234. 'value': true,
  235. 'def_value': true,
  236. },
  237. 'updatenoti': {
  238. 'param_name': 'updatenoti',
  239. 'value': true,
  240. 'def_value': true,
  241. },
  242. 'extlinkwarn': {
  243. 'param_name': 'extlinkwarn',
  244. 'value': true,
  245. 'def_value': true,
  246. },
  247. 'deniedchannel': {
  248. 'param_name': 'deniedchannel',
  249. 'value': [],
  250. 'def_value': [],
  251. },
  252. 'expandmenu': {
  253. 'param_name': 'expandmenu',
  254. 'value': true,
  255. 'def_value': true,
  256. },
  257. };
  258.  
  259. //script menu structure
  260. let menuStructure = {
  261. 'basedepth': {
  262. 'param_name': localParameter.basedepth,
  263. 'name': '🎛 base64 깊이 조절하기 - 현재 값 : 알수없음',
  264. 'desc': '자동 base64 디코딩 깊이를 조절할 수 있습니다.',
  265. 'id': -1,
  266. 'func': menuFunctionBasedepth,
  267. 'visible': true,
  268. },
  269. 'enclinkhide': {
  270. 'param_name': localParameter.enclinkhide,
  271. 'name': '🔗 인코딩된 링크 [보이기/숨기기]',
  272. 'desc': '자동 base64 디코딩 전 인코딩된 링크를 항상 보이게 할지 설정할 수 있습니다.',
  273. 'id': -1,
  274. 'func': menuFunctionEnchide,
  275. 'visible': false, //discontinued since 1.220
  276. },
  277. 'extlinkwarn': {
  278. 'param_name': localParameter.extlinkwarn,
  279. 'name': '❔ TODO:❗️ 외부 링크 경고 [보이기/숨기기]',
  280. 'desc': '디코딩된 링크 클릭 시 외부링크에 대한 경고 메시지 표시 여부를 설정할 수 있습니다.',
  281. 'id': -1,
  282. 'func': menuFunctionNotAvailable,
  283. 'visible': false, //TODO
  284. },
  285. 'draggable': {
  286. 'param_name': localParameter.draggable,
  287. 'name': '🖱 드래그 시 자동 디코딩 [켜기/끄기]',
  288. 'desc': '드래그 시 자동으로 드래그한 부분을 base64로 디코딩할지 설정할 수 있습니다.',
  289. 'id': -1,
  290. 'func': menuFunctionDraggable,
  291. 'visible': true,
  292. },
  293. 'deniedchannel': {
  294. 'param_name': localParameter.deniedchannel,
  295. 'name': '❔ TODO:🏷 이 채널에서 자동 디코딩 [끄기/켜기]',
  296. 'desc': '현재 보고있는 채널에서 자동 디코딩 기능 여부를 설정할 수 있습니다.',
  297. 'id': -1,
  298. 'func': menuFunctionNotAvailable,
  299. 'visible': false, //TODO
  300. },
  301. 'updatechk': {
  302. 'param_name': localParameter.updatechk,
  303. 'name': '🔄 업데이트 알림 [켜기/끄기]',
  304. 'desc': '새 버전이 나올 시 업데이트 확인 알림을 띄울지 여부를 설정할 수 있습니다.',
  305. 'id': -1,
  306. 'func': menuFunctionUpdateCheck,
  307. 'visible': false,
  308. },
  309. 'updatenoti': {
  310. 'param_name': localParameter.updatenoti,
  311. 'name': '✅ 업데이트 완료 알림 [켜기/끄기]',
  312. 'desc': '업데이트 완료되었을 때 알림을 띄울지 여부를 설정할 수 있습니다.',
  313. 'id': -1,
  314. 'func': menuFunctionUpdateNotice,
  315. 'visible': false,
  316. },
  317. 'checkupd': {
  318. 'param_name': null,
  319. 'name': '❔ TODO:🔃 업데이트 확인',
  320. 'desc': '본 스크립트의 업데이트를 확인합니다.',
  321. 'id': -1,
  322. 'func': menuFunctionCheckUpdate,
  323. 'visible': false, //TODO
  324. },
  325. 'resetdefaults': {
  326. 'param_name': null,
  327. 'name': '🛠 스크립트 기본값 초기화',
  328. 'desc': '스크립트의 사용자 설정을 초기화하고 설치 상태로 되돌립니다.',
  329. 'id': -1,
  330. 'func': menuFunctionRstDefaults,
  331. 'visible': true,
  332. },
  333.  
  334. //proto
  335. 'prototype': {
  336. 'param_name': null, //if visible is false -> parameter use deafults
  337. 'name': '🔤 확장패널 메뉴 제목', //extension menu pannel elem button title
  338. 'desc': '확장패널 설명 내용.', //description
  339. 'id': -1, //managed by extension
  340. 'func': menuFunctionNotAvailable, //click event function
  341. 'visible': false, //extension menu pannel visible
  342. },
  343. //default
  344. 'expandmenu': {
  345. 'param_name': localParameter.expandmenu,
  346. 'name': '⚙️ 스크립트 메뉴 [축소/확장]',
  347. 'desc': '스크립트 설정 메뉴를 확장하거나 축소할 수 있습니다.',
  348. 'id': -1,
  349. 'func': menuFunctionChangeExpandMode,
  350. 'visible': true,
  351. },
  352. };
  353.  
  354.  
  355. /*
  356. * https://stackoverflow.com/questions/4386300
  357. * addListener(div, 'click', eventReturner(), false)
  358. * // and later
  359. * removeAllListeners(div, 'click')
  360. */
  361.  
  362. let _eventHandlers = {}; // somewhere global
  363.  
  364. const addListener = (node, event, handler, capture = false) => {
  365. if (!(event in _eventHandlers)) {
  366. _eventHandlers[event] = [];
  367. }
  368. // here we track the events and their nodes (note that we cannot
  369. // use node as Object keys, as they'd get coerced into a string
  370. _eventHandlers[event].push({ node: node, handler: handler, capture: capture });
  371. node.addEventListener(event, handler, capture);
  372. };
  373.  
  374. const removeAllListeners = (targetNode, event) => {
  375. // remove listeners from the matching nodes
  376. _eventHandlers[event]
  377. .filter(({ node }) => node === targetNode)
  378. .forEach(({ node, handler, capture }) => node.removeEventListener(event, handler, capture));
  379.  
  380. // update _eventHandlers global
  381. _eventHandlers[event] = _eventHandlers[event].filter(
  382. ({ node }) => node !== targetNode,
  383. );
  384. };
  385.  
  386. function sleep(ms) {
  387. return new Promise((r) => setTimeout(r, ms));
  388. }
  389.  
  390. function getLocation(href) {
  391. var match = href.toString().match(/^(https?\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)([\/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/);
  392. return match && {
  393. href: href,
  394. protocol: match[1],
  395. host: match[2],
  396. hostname: match[3],
  397. port: match[4],
  398. pathname: match[5],
  399. search: match[6],
  400. hash: match[7]
  401. };
  402. }
  403.  
  404. //element id - random uuid
  405. function createElemID() {
  406. return 'abad_'+self.crypto.randomUUID();
  407. }
  408.  
  409. //auto add padding - add '=' padding in base64 encoded string
  410. function base64AddPadding(str) {
  411. return str + Array((4 - str.length % 4) % 4 + 1).join('=');
  412. }
  413.  
  414. //base64 decode
  415. const Base64 = {
  416. _keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
  417. decode : function (input) {
  418. let output = "";
  419. let chr1, chr2, chr3;
  420. let enc1, enc2, enc3, enc4;
  421. let i = 0;
  422.  
  423. input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
  424.  
  425. while (i < input.length) {
  426. enc1 = this._keyStr.indexOf(input.charAt(i++));
  427. enc2 = this._keyStr.indexOf(input.charAt(i++));
  428. enc3 = this._keyStr.indexOf(input.charAt(i++));
  429. enc4 = this._keyStr.indexOf(input.charAt(i++));
  430.  
  431. chr1 = (enc1 << 2) | (enc2 >> 4);
  432. chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
  433. chr3 = ((enc3 & 3) << 6) | enc4;
  434.  
  435. //last bits
  436. output = output + String.fromCharCode(chr1);
  437. if (enc3 != 64) { //=
  438. output = output + String.fromCharCode(chr2);
  439. }
  440. if (enc4 != 64) { //==
  441. output = output + String.fromCharCode(chr3);
  442. }
  443. }
  444.  
  445. output = Base64._utf8_decode(output);
  446. return output;
  447. },
  448. // private method for UTF-8 decoding
  449. _utf8_decode : function (utftext) {
  450. let string = "";
  451. let i = 0;
  452. let c = 0;
  453. let c1 = 0;
  454. let c2 = 0;
  455. let c3 = 0;
  456.  
  457. while (i < utftext.length) {
  458. c = utftext.charCodeAt(i);
  459. if (c < 128) {
  460. string += String.fromCharCode(c);
  461. i++;
  462. }
  463. else if ((c > 191) && (c < 224)) {
  464. c2 = utftext.charCodeAt(i+1);
  465. string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
  466. i += 2;
  467. }
  468. else {
  469. c2 = utftext.charCodeAt(i+1);
  470. c3 = utftext.charCodeAt(i+2);
  471. string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
  472. i += 3;
  473. }
  474. }
  475. return string;
  476. }
  477. };
  478.  
  479. //scroll(vertical) to elem(id)
  480. const scrollToTarget = function(id_tmp, target) {
  481. window.console.log(abadConstDB.logPrompt.default,'scroll to -', id_tmp);
  482. const targetElem = document.getElementById(id_tmp);
  483. if (abadInternalDB.internalDB.swal2Enable) {
  484. Swal.close();
  485. Swal.fire({
  486. icon: 'success',
  487. title: abadConstDB.SWAL2Title,
  488. html: `<b style="font-size: 82.5%;">${(target==undefined)?'해당':target} 위치로 이동했습니다.</b>`,
  489. footer: `<i style="font-size: 76.5%;">해당 요소가 보이지 않는다면 접기 되어있는 부분을 펼쳐주세요.</i>`,
  490. toast: true,
  491. position: 'top-end',
  492. timer: 3500,
  493. timerProgressBar: true,
  494. confirmButtonText: '확인',
  495. });
  496. } else {
  497. window.alert(abadConstDB.logPrompt.default+'\n해당 위치로 이동했습니다.\n(해당 요소가 보이지 않는다면 접기 되어있는 부분을 펼쳐주세요.)');
  498. }
  499.  
  500. //highlight color
  501. targetElem.style.background = '#06ff004f';
  502. //scroll to elem, viewport center
  503. window.scrollTo({top:window.pageYOffset + targetElem.getBoundingClientRect().top - (window.innerHeight / 2), behavior:'smooth'});
  504.  
  505. //restore style
  506. sleep(2750).then(() => {
  507. targetElem.style.background = null;
  508. targetElem.style.transition = "all 1s";
  509. sleep(750).then(() => {
  510. targetElem.style.transition = null;
  511. });
  512. });
  513. };
  514.  
  515. //encoded link click callback
  516. function showEncodedLink(event) {
  517. const self = event.currentTarget;
  518. //check exist
  519. if (abadInternalDB.encodedLink.hasOwnProperty(self.id)) {
  520. const rawLink = abadInternalDB.encodedLink[self.id].raw;
  521. if (!abadInternalDB.encodedLink[self.id].isEnabled) {
  522. window.console.log(abadConstDB.logPrompt.decodeManager, 'show encoded link -', abadInternalDB.encodedLink[self.id].raw);
  523. self.innerHTML = rawLink;
  524. self.style.color = '#4758bc';
  525. self.title = '디코딩 전 인코딩된 링크입니다, 클릭 시 내용이 복사됩니다.';
  526. abadInternalDB.encodedLink[self.id].isEnabled = true;
  527. } else {
  528. window.console.log(abadConstDB.logPrompt.default, 'copy link to clipboard -', rawLink);
  529. try {
  530. GM.setClipboard(rawLink);
  531.  
  532. if (abadInternalDB.internalDB.swal2Enable) {
  533. window.console.log(abadConstDB.logPrompt.default,'show rawlink copy modal');
  534. let timerInterval;
  535. Swal.fire({
  536. title: abadConstDB.SWAL2Title,
  537. html: `<b>인코딩된 코드가 클립보드로 복사되었습니다.</b><br><div style="margin-top: 15; text-align:left; font-size:72.5%">또는 아래 코드를 복사:<div style="overflow-y:auto; overflow-wrap: anywhere; margin: 5 0 5; width:100%; height:150px; background-color: #e6e6e6;">${rawLink}</div></div>`,
  538. confirmButtonText: '확인',
  539. icon: 'success',
  540. timer: 3000,
  541. timerProgressBar: true,
  542. footer: `<span id="footer" style="font-size: 82.5%;">&nbsp;</span>`,
  543. didOpen: (modal) => {
  544. let autoClose = true;
  545. modal.onmouseenter = (event) => {
  546. autoClose = false;
  547. Swal.stopTimer();
  548. modal.querySelector("#footer").innerHTML = `<i style="font-size: 82.5%;">창에서 마우스를 떼면 일정시간 자동으로 닫힙니다.</i>`;
  549. };
  550. modal.onmouseleave = (event) => {
  551. autoClose = true;
  552. Swal.resumeTimer();
  553. };
  554. timerInterval = setInterval(() => {
  555. if(autoClose) {
  556. modal.querySelector("#footer").innerHTML = `<i style="font-size: 82.5%;">약 ${(isNaN(Math.floor(Swal.getTimerLeft()/1000))?'0':Math.floor(Swal.getTimerLeft()/1000))}초 창이 자동으로 닫힙니다.</i>`;
  557. }
  558. }, 100);
  559. },
  560. willClose: (modal) => {
  561. clearInterval(timerInterval);
  562. window.console.log(abadConstDB.logPrompt.default,'close rawlink copy modal');
  563. },
  564. });
  565. } else {
  566. window.alert(abadConstDB.logPrompt.default+'\n인코딩된 코드가 클립보드로 복사되었습니다.');
  567. }
  568. } catch (e) {
  569. window.console.warn(abadConstDB.logPrompt.decodeManager, 'error occured link copy:', e);
  570. if (abadInternalDB.internalDB.swal2Enable) {
  571. Swal.fire({
  572. title: abadConstDB.SWAL2Title,
  573. html: `<b>코드 복사 실패</b><br><i>수동으로 복사해주세요..</i>`,
  574. icon: 'error',
  575. confirmButtonText: '확인',
  576. });
  577. } else {
  578. window.alert(abadConstDB.logPrompt.default+'\n코드 복사 실패.');
  579. }
  580. }
  581. }
  582. } else {
  583. window.console.warn(abadConstDB.logPrompt.decodeManager, 'cannot find property(enc_link) :', self.id);
  584. if (abadInternalDB.internalDB.swal2Enable) {
  585. Swal.fire({
  586. title: abadConstDB.SWAL2Title,
  587. html: `<b>원본 링크를 찾을 없습니다..</b>`,
  588. footer: `<span style="font-size: 77.5%;">ID: ${self.id}</span>`,
  589. icon: 'error',
  590. timer: 2000,
  591. timerProgressBar: true,
  592. confirmButtonText: '확인',
  593. });
  594. } else {
  595. window.alert(abadConstDB.logPrompt.default+'\n원본 링크를 찾을 수 없습니다..');
  596. }
  597. }
  598. return;
  599. }
  600.  
  601. //show decoding summary (click callback)
  602. function showDecodeSummary(event) {
  603. if (abadInternalDB.internalDB.swal2Enable) {
  604. //event callback list
  605. let eventCallbackList = [];
  606. //decoded list wrapper
  607. const decodedLinkListWrapper = createElemID();
  608.  
  609. //remove decoded list event
  610. const removeEvent = function() {
  611. while (eventCallbackList.length > 0) {
  612. try {
  613. removeAllListeners(document.querySelector('#'+eventCallbackList.pop()), 'click');
  614. } catch (_) {}
  615. }
  616. };
  617. //show detected site list modal
  618. const openDetectedSiteList = function(event) {
  619. removeEvent();
  620. window.console.log(abadConstDB.logPrompt.default,'open detected site list modal');
  621. this.removeEventListener('click', openDetectedSiteList);
  622. Swal.fire({
  623. title: abadConstDB.SWAL2Title,
  624. html: `<div style="text-align:left;"><strong>== 현재 페이지에서 감지된 사이트 목록 ==</strong><div id="dsList" style="margin: 15 0 10; overflow:auto; width:100%; height:250px; background-color: #e6e6e6;">불러오는중...</div></div><div id="dsCount" style="font-size: 60%; text-align:right;">로딩이 끝나지 않는다면 브라우저 로그를 확인해주세요.</div>`,
  625. confirmButtonText: '닫기',
  626. didOpen: (modal) => {
  627. Swal.showLoading();
  628. sleep(1000).then(() => {
  629. modal.querySelector('#dsList').innerHTML = '';
  630. abadInternalDB.hostnameSet.forEach(function(tar) {
  631. const dsCont = document.createElement("p");
  632. dsCont.style.margin = 0;
  633. dsCont.innerText = '- ';
  634. dsCont.style.whiteSpace = 'nowrap';
  635. const dsLink = document.createElement("a");
  636. //dsLink.href = tar; //TODO: add protocol(https)
  637. //dsLink.title = tar.concat(' (새 창으로 열기)');
  638. dsLink.rel = "external nofollow noopener noreferrer";
  639. dsLink.target = "_blank";
  640. dsLink.innerText = tar;
  641. dsCont.appendChild(dsLink);
  642. modal.querySelector('#dsList').appendChild(dsCont);
  643. });
  644. modal.querySelector('#dsCount').innerHTML = `<i>총 ${abadInternalDB.hostnameSet.length}개</i>&nbsp;`;
  645. Swal.hideLoading();
  646. });
  647. },
  648. });
  649. };
  650.  
  651. //show modal
  652. Swal.fire({
  653. title: abadConstDB.SWAL2Title, //<a id="${eventCaller}">aaa</a>
  654. html: `<b>이 페이지에서 디코딩된 링크 <span id="sdsdectype" style="font-size: 72.5%;">( 로드중.. )</span></b><br><div style="margin-top: 15; text-align:left; font-size:72.5%"><b>디코딩된 링크 목록:</b><div id="${decodedLinkListWrapper}" style="overflow: auto; margin: 10 0 10; width:100%; height:250px; background-color: #e6e6e6;">불러오는중...</div></div><div style="font-size: 60%; text-align:right;"><i>각 링크 클릭 시 새로운 창에 열립니다.</i>&nbsp;</div>`,
  655. confirmButtonText: '닫기',
  656. footer: `<b id="footer">로딩중..</b>`,
  657. didOpen: (modal) => {
  658. window.console.log(abadConstDB.logPrompt.default,'open declink list modal');
  659. Swal.showLoading();
  660. let elemArticleCnt = 0;
  661. let elemCommentCnt = 0;
  662.  
  663. sleep(200).then(() => {
  664. //remove all
  665. modal.querySelector('#'+decodedLinkListWrapper).innerHTML = '';
  666. let contWrapper = document.createElement("span");
  667. Object.keys(abadInternalDB.decodedLink).forEach(function(targetRaw) {
  668. //target elem
  669. const target = abadInternalDB.decodedLink[targetRaw];
  670. //each elem
  671. let cont = document.createElement("p");
  672. cont.style.marginBottom = '0.3rem';
  673. cont.style.whiteSpace = 'nowrap';
  674. //cont.style.marginBottom = '0.5rem';
  675. //scroll to elem
  676. const elemGotoLocation = document.createElement("a");
  677. elemGotoLocation.id = createElemID();
  678. elemGotoLocation.innerHTML = `[<u>클릭 해당 위치로 이동</u>]`;
  679. elemGotoLocation.title = "클릭 시 이 페이지에서 해당 링크가 있는 위치로 이동합니다.";
  680. elemGotoLocation.href = "javascript:void(0);";
  681.  
  682. //get type
  683. let elemType = {'show':'❔', 'desc':'알수없음'};
  684. if (target.type == 'article') {
  685. elemArticleCnt++;
  686. elemType = {'show':'📑', 'desc':'게시글'};
  687. } else if (target.type == 'comment') {
  688. elemCommentCnt++;
  689. elemType = {'show':'💬', 'desc':'댓글'};
  690. }
  691.  
  692. //cont with loc
  693. const contLink = document.createElement("a");
  694. contLink.href = target.href;
  695. contLink.title = target.title+' ('+elemType.desc+') (새 창으로 열기)';
  696. contLink.rel = "external nofollow noopener noreferrer";
  697. contLink.target = "_blank";
  698. contLink.innerHTML = `&gt; ${target.no}번째 링크(${elemType.show}) (${target.hostname})`;
  699.  
  700. //append link elem
  701. cont.appendChild(contLink);
  702. cont.appendChild(document.createTextNode(" - "));
  703. //append scroll elem
  704. cont.appendChild(elemGotoLocation);
  705. //append decoded list wrapper
  706. modal.querySelector('#'+decodedLinkListWrapper).appendChild(cont);
  707.  
  708. const seprator = document.createElement("div");
  709. seprator.style.marginTop = '0.1rem';
  710. seprator.style.marginBottom = '0.1rem';
  711. seprator.style.borderTop = '2px solid #b8b8b885';
  712. modal.querySelector('#'+decodedLinkListWrapper).appendChild(seprator);
  713.  
  714. //register event id
  715. eventCallbackList.push(elemGotoLocation.id);
  716. const eventWrapper = function(event) {
  717. //remove all
  718. removeEvent();
  719. //goto element
  720. scrollToTarget(target.id, `${target.no}번째 링크(${elemType.show})`);
  721. };
  722. //attach event - scroll to each elem
  723. addListener(elemGotoLocation, 'click', eventWrapper);
  724. });
  725. modal.querySelector('#sdsdectype').innerText = '( '+((elemArticleCnt>0)?('게시글'+((elemCommentCnt>0)?' 또는 ':'')):'')+((elemCommentCnt>0)?'댓글':'')+' )';
  726.  
  727. //attach event - get detected site list
  728. const modalFooter = modal.querySelector('#footer');
  729. modalFooter.innerHTML = `<a style="font-size: 97.5%;" href="javascript:void(0);" title="클릭 시 현재 페이지에서 감지된 사이트 목록을 표시합니다.">감지된 사이트 목록 표시 (클릭)</a>`;
  730. modalFooter.addEventListener('click', openDetectedSiteList);
  731. //load finish
  732. Swal.hideLoading();
  733. });
  734. },
  735. willClose: (modal) => {
  736. //dettach all event
  737. modal.querySelector('#footer').removeEventListener('click', openDetectedSiteList);
  738. removeEvent();
  739. window.console.log(abadConstDB.logPrompt.default,'close declink list modal');
  740. },
  741. });
  742. } else {
  743. window.alert(abadConstDB.logPrompt.default+'\n(SWAL2가 비활성화 되어있어 감지된 사이트 목록만 표시합니다.)\n== 감지된 사이트 목록 ('+abadInternalDB.hostnameSet.length+'개)\n- '+abadInternalDB.hostnameSet.join('\n- '));
  744. }
  745. }
  746.  
  747. //link area
  748. function createEncodedLink(src) {
  749. return `<span style="font-size: 87.5%;color: #47bc73 !important;">[ ${src.toString()} ]</span>`;
  750. }
  751.  
  752. //encoded link element
  753. function createMaskEncodedLink(src, genMode, uuid) {
  754. abadInternalDB.encodedLink[uuid] = {
  755. type: genMode,
  756. raw: src,
  757. isShown: false,
  758. };
  759. return `<a id="${uuid}" title="클릭 시 디코딩 전 인코딩된 링크를 표시합니다." href="javascript:void(0);">클릭 인코딩된 코드 보기</a>`;
  760. }
  761.  
  762. //link creation
  763. function createLink(src, index, url, depth, genMode, uuid, parentuuid, hidelink = false) {
  764. //n번째 링크 (base64 깊이: 0) [ ABCDEF= / 클릭시 원본~ ]
  765. abadInternalDB.hostnameSetRaw.add(url.hostname);
  766. return `<a id="${uuid}" href="${url.href}" title="${url.href} (새 창으로 열기)" target="_blank" rel="external nofollow noopener noreferrer">${index.toString()}번째 링크 (base64 깊이: ${depth.toString()}) <span style="font-size: 77.5%;">(${url.hostname})</span></a> ${(hidelink?createEncodedLink(createMaskEncodedLink(src, genMode, parentuuid)):createEncodedLink(src))}`;
  767. }
  768.  
  769. //decode & generate
  770. function replacerGen(numIter, genMode) {
  771. return function(source) {
  772. try {
  773. let rstring = ""; //return msg
  774. window.console.log('\n'+abadConstDB.logPrompt.decodeManager,'No.',(hindex+1),'encoded link:\n', source.toString()); //source
  775.  
  776. //decode
  777. let converted = Base64.decode(base64AddPadding(source));
  778. //attempt to decode nested base64 encoded string
  779. for (let i=0; i<numIter; i++) {
  780. converted = Base64.decode(base64AddPadding(converted));
  781. }
  782. hindex++;
  783.  
  784. //remove invalid string - �
  785. converted = decodeURI(encodeURI(converted).replaceAll('%00', ''));
  786. window.console.log(abadConstDB.logPrompt.decodeManager,'No.',hindex,'decode completed (depth:',numIter+1,'):\n',converted.toString()); //converted
  787.  
  788. //trim
  789. converted = converted.trim();
  790.  
  791. //split by new line
  792. converted = converted.split(/\r?\n/);
  793.  
  794. const registerDecodedLink = function(_target, _uuid, _parentuuid) {
  795. abadInternalDB.decodedLink[_uuid] = {
  796. id: _uuid,
  797. no: hindex,
  798. type: genMode,
  799. hostname: _target.hostname,
  800. title: _target.href+' (base 깊이: '+(numIter+1).toString()+')',
  801. href: _target.href,
  802. srcid: _parentuuid,
  803. };
  804. abadInternalDB.decodedList.push(_uuid);
  805. };
  806.  
  807. if (converted.length == 2 && converted[converted.length-1] == '') {
  808. //single component
  809. const uuid = createElemID();
  810. const parentuuid = createElemID();
  811. const url_t = getLocation(converted[0]);
  812. registerDecodedLink(url_t, uuid, parentuuid);
  813. rstring += createLink(source, hindex, url_t, numIter+1, genMode, uuid, parentuuid, !localParameter.enclinkhide.value);
  814. } else if (converted.length > 1) {
  815. //multiple component
  816. const parentuuid = createElemID();
  817. rstring += createEncodedLink(localParameter.enclinkhide.value?source.toString():createMaskEncodedLink(source.toString(), genMode, parentuuid));
  818.  
  819. let nindex = 1;
  820. const hindexPrev = hindex;
  821. converted.forEach(function(i) {
  822. if (i != '') {
  823. const uuid = createElemID();
  824. const url_t = getLocation(i);
  825. registerDecodedLink(url_t, uuid, parentuuid);
  826. rstring += `<br><span style="margin-left:2px;">└ </span>${createLink(`<span style="color: #47bc73;" title="자동으로 분할된 ${nindex.toString()}번째 링크입니다.">링크 자동 분할 : ${nindex.toString()}번째</span>`, hindex, url_t, numIter+1, genMode, uuid, parentuuid)}`;
  827. hindex++;
  828. nindex++;
  829. }
  830. });
  831. //apply last components
  832. hindex--;
  833. nindex--;
  834.  
  835. window.console.log(abadConstDB.logPrompt.decodeManager,'No.',hindexPrev,'- splitted total :', nindex);
  836. rstring = `<span style="color: #e83e8c;"><b><i>분할된 링크 ${nindex.toString()}개</i></b></span> ${rstring}`;
  837. } else {
  838. const uuid = createElemID();
  839. const parentuuid = createElemID();
  840. const url_t = getLocation(converted);
  841. registerDecodedLink(url_t, uuid, parentuuid);
  842. rstring += createLink(source, hindex, url_t, numIter+1, genMode, uuid, parentuuid, !localParameter.enclinkhide.value);
  843. }
  844. return rstring;
  845. } catch(e) {
  846. window.console.warn('\n'+abadConstDB.logPrompt.decodeManager,'error occured during decoding:', e);
  847. window.console.warn(abadConstDB.logPrompt.decodeManager,'base64 decode fail:', source);
  848. }
  849. return `<span style="color: #ff0000;" title="base64 디코딩 중 오류가 발생했습니다. 자세한 내용은 브라우저 로그를 확인해주세요..">[ base64 변환 실패: ${source.toString()}]</span>`;
  850. };
  851. }
  852.  
  853. //user drag event
  854. function selClicked(event) {
  855. const sel = document.getSelection().toString();
  856. if (!sel.match(abadConstDB.regInvalid) && sel.length >= 10 && lastSelectedTime + 200 < Date.now()) {
  857. try {
  858. window.console.log(abadConstDB.logPrompt.decodeManager,'live match -',sel.toString());
  859. let converted = decodeURI(encodeURI(Base64.decode(base64AddPadding(sel))).replaceAll('%00', ''));
  860. window.console.log(abadConstDB.logPrompt.decodeManager,'converted -',converted.toString());
  861. this.innerHTML = `<span style="color: green;" title="드래그 하여 디코딩 된 결과입니다.">${this.innerHTML.replace(sel, converted)}</span>`;
  862. } catch (e) {
  863. return;
  864. } finally {
  865. this.removeEventListener('click', selClicked);
  866. }
  867. }
  868. }
  869.  
  870. //user drag activate
  871. function activateDragDecoding() {
  872. if (abadInternalDB.internalDB.dragDecodingEnable) {
  873. window.console.log(abadConstDB.logPrompt.default,'USR-Drag already enabled.');
  874. return;
  875. }
  876. abadInternalDB.internalDB.dragDecodingEnable = true;
  877. window.console.log(abadConstDB.logPrompt.default,'USR-Drag enabled.');
  878. document.addEventListener('selectionchange', function() {
  879. let sel = document.getSelection().anchorNode;
  880. if (sel) {
  881. sel = sel.parentElement;
  882. if (sel != lastSelected) {
  883. lastSelected.removeEventListener('click', selClicked);
  884. sel.addEventListener('click', selClicked);
  885. lastSelected = sel;
  886. lastSelectedTime = Date.now();
  887. }
  888. }
  889. });
  890. }
  891.  
  892. //use only swal2
  893. function showSWAL2ErrorLog(reason, err) {
  894. if (abadInternalDB.internalDB.swal2Enable) {
  895. Swal.fire({
  896. title: abadConstDB.SWAL2Title,
  897. didOpen: () => {
  898. Swal.hideLoading();
  899. },
  900. html: `<b>경고! ${reason} 도중<br>문제가 발생했습니다.</b><br><br><i>아래 로그를 참고해주세요..</i>`,
  901. footer: `<div style="text-align:left;">브라우저 에러 로그:</div><div style="text-align:left; margin: 5 0 5; overflow:auto; width:100%; height:150px; background-color: #e6e6e6;">${err}</div>`,
  902. icon: 'error',
  903. confirmButtonText: '닫기',
  904. });
  905. } else {
  906. window.alert(abadConstDB.logPrompt.default+'\n경고! SWAL2가 활성화되지 않았습니다..\ntype:err');
  907. }
  908. }
  909.  
  910. //update check
  911. function checkForUpdate() {
  912. const cur_version = parseFloat(GM.info.script.version);
  913. const prev_version = parseFloat(localParameter.prevversion.value);
  914.  
  915. //new version detect
  916. if (cur_version > prev_version) {
  917. if (prev_version == -1) {
  918. //previous version is lost
  919. window.console.warn(abadConstDB.logPrompt.updateManager,'previous version not detected.');
  920. window.console.log(abadConstDB.logPrompt.paramManager,'save script version:', cur_version);
  921. try {
  922. GM.setValue(localParameter.prevversion.param_name, cur_version);
  923. } catch(e) {
  924. window.console.error(abadConstDB.logPrompt.paramManager,'previous script verson saving failed -', e);
  925. }
  926. } else {
  927. window.console.log(abadConstDB.logPrompt.updateManager,'script update detected', prev_version, '->', cur_version);
  928. try {
  929. GM.setValue(localParameter.prevversion.param_name, cur_version);
  930. } catch(e) {
  931. window.console.error(abadConstDB.logPrompt.paramManager,'previous script verson saving failed -', e);
  932. }
  933. if (localParameter.updatenoti.value) {
  934. if (abadInternalDB.internalDB.swal2Enable) {
  935. Swal.fire({
  936. title: abadConstDB.SWAL2Title,
  937. html: `<b>스크립트가 업데이트 되었습니다.</b><br><br><i style="font-size: 82.5%;">이전버전 : V ${prev_version}<br>현재버전 : V ${cur_version}</i><br><br><strong><span style="font-size: 92.5%;">체인지로그: ${(GM.info.script.changelogURL != undefined && GM.info.script.changelogURL!='')?'<a style="color: #e83e8c;" href="'+GM.info.script.changelogURL+'" title="클릭 시 체인지로그 게시글로 이동합니다." target="_blank" rel="external nofollow noopener noreferrer">(클릭)</a>':'<i title="게시글 링크가 준비되지 않았습니다..">(게시글 준비중)</i>'}</span></strong>`,
  938. icon: 'success',
  939. toast: true,
  940. confirmButtonText: '확인',
  941. position: "top-end",
  942. input: "checkbox",
  943. inputValue: 0,
  944. inputPlaceholder: `<span style="font-size: 92.5%;">업데이트 알림 다시보지 않기</span>`,
  945. timer: 10000,
  946. timerProgressBar: true,
  947. didOpen: (modal) => {
  948. modal.onmouseenter = Swal.stopTimer;
  949. modal.onmouseleave = Swal.resumeTimer;
  950. },
  951. }).then((result) => {
  952. if (result.value == 1) {
  953. window.console.log(abadConstDB.logPrompt.paramManager,'updatenoti change',true.toString(),'to',false.toString());
  954. try {
  955. GM.setValue(localParameter.updatenoti.param_name, false);
  956. localParameter.updatenoti.value = false;
  957. window.console.log(abadConstDB.logPrompt.paramManager,"updatenoti change successful");
  958. menuStructureUpdate();
  959. Swal.fire({
  960. title: abadConstDB.SWAL2Title,
  961. html: `<b style="font-size: 82.5%;">앞으로 업데이트 알림을 띄우지 않습니다.</b><br><br><i style="font-size: 77.5%;">※ <u>설정</u>에서 변경할 있습니다.</i>`,
  962. icon: 'success',
  963. toast: true,
  964. confirmButtonText: '확인',
  965. position: "top-end",
  966. timer: 3000,
  967. timerProgressBar: true,
  968. didOpen: (modal) => {
  969. modal.onmouseenter = Swal.stopTimer;
  970. modal.onmouseleave = Swal.resumeTimer;
  971. },
  972. });
  973. } catch(e) {
  974. localParameter.updatenoti.value = true;
  975. window.console.error(abadConstDB.logPrompt.paramManager,"updatenoti change fail -", e);
  976. showSWAL2ErrorLog('파라미터 변경', e);
  977. }
  978. }
  979. });
  980. } else {
  981. //TODO:window alert
  982. }
  983. }
  984. }
  985. }
  986.  
  987. if (!updateAvailble || !localParameter.updatechk.value) {
  988. window.console.log(abadConstDB.logPrompt.updateManager,'updchk skipped.');
  989. return;
  990. }
  991. const currentTime = Math.floor(new Date().getTime() / 1000);
  992. if (currentTime - localParameter.lastupdate.value < abadConstDB.updateInterval) {
  993. window.console.log(abadConstDB.logPrompt.updateManager,'updchk already done in '+abadConstDB.updateInterval+' sec.. skip updchk');
  994. return;
  995. }
  996. try {
  997. GM.setValue(localParameter.lastupdate.param_name, currentTime);
  998. } catch(e) {
  999. window.console.error(abadConstDB.logPrompt.updateManager,'last upd time write fail -', e);
  1000. return;
  1001. }
  1002.  
  1003. window.console.log(abadConstDB.logPrompt.updateManager,'checking for update...');
  1004.  
  1005. const svrMetadataLink = (GM.info.script.updateURL != undefined)?GM.info.script.updateURL:'https://update.greasyfork.org/scripts/482577/Arca%20base64%20autodecoder.meta.js';
  1006. const scriptLink = (GM.info.script.downloadURL != undefined)?GM.info.script.downloadURL:'https://greasyfork.org/ko/scripts/482577';
  1007. fetch(svrMetadataLink)
  1008. .then(response => response.text())
  1009. .then(data => {
  1010. //extract version from greaskyfork script
  1011. const match = data.match(/@version\s+(\d+\.\d+)/);
  1012. if (match) {
  1013. const tar_version = parseFloat(match[1]);
  1014.  
  1015. const openUpdateLink = () => {
  1016. window.console.log(abadConstDB.logPrompt.updateManager,'opening source url..');
  1017. if(window.open(scriptLink) == null) {
  1018. window.console.log(abadConstDB.logPrompt.updateManager,'popup block detected..');
  1019. if (abadInternalDB.internalDB.swal2Enable) {
  1020. Swal.fire({
  1021. title: abadConstDB.SWAL2Title,
  1022. html: `<b>팝업 차단</b>이 설정된 것으로 보입니다.<br>차단을 해제해주세요..`,
  1023. icon: 'warning',
  1024. timer: 15000,
  1025. timerProgressBar: true,
  1026. toast: true,
  1027. confirmButtonText: '확인',
  1028. });
  1029. } else {
  1030. window.alert(abadConstDB.logPrompt.default+'\n팝업 차단이 설정된 것으로 보입니다, 차단을 해제해주세요..');
  1031. }
  1032. } else {
  1033. if (abadInternalDB.internalDB.swal2Enable) {
  1034. Swal.fire({
  1035. title: abadConstDB.SWAL2Title,
  1036. html: `<i style="font-size: 82.5%;">업데이트 새로고침해야 적용됩니다.</i>`,
  1037. icon: 'info',
  1038. timer: 15000,
  1039. timerProgressBar: true,
  1040. toast: true,
  1041. confirmButtonText: '확인',
  1042. });
  1043. } else {
  1044. window.alert(abadConstDB.logPrompt.default+'\n업데이트 후 새로고침해야 적용됩니다.');
  1045. }
  1046. }
  1047. };
  1048.  
  1049. //new version detected
  1050. if (tar_version > cur_version) {
  1051. window.console.log(abadConstDB.logPrompt.updateManager,'new version available. ('+cur_version+' -> '+tar_version+')');
  1052. let timerInterval;
  1053. if (abadInternalDB.internalDB.swal2Enable) {
  1054. //y/n dialog
  1055. Swal.fire({
  1056. title: abadConstDB.SWAL2Title,
  1057. html: `<strong>새로운 버전이 감지되었습니다. 업데이트를 권장합니다.</strong><br>( 기존버전 : ${cur_version}, 새로운 버전 : ${tar_version} )<br>(변경사항은 아카라이브 게시글을 참고해주세요.)<br><br><i style="font-size: 82.5%;">"알림 끄기"를 누르면 앞으로 업데이트 알림을 띄우지 않습니다.</i>`,
  1058. icon: 'info',
  1059. showDenyButton: true,
  1060. showCancelButton: true,
  1061. confirmButtonColor: '#3085d6',
  1062. denyButtonColor: '#d33',
  1063. confirmButtonText: '업데이트',
  1064. denyButtonText: '알림 끄기',
  1065. cancelButtonText: '이번엔 건너뛰기',
  1066. timer: 20000,
  1067. timerProgressBar: true,
  1068. footer: '<span id="footer" style="font-size: 82.5%;">&nbsp;</span>',
  1069. didOpen: (modal) => {
  1070. modal.onmouseenter = Swal.stopTimer;
  1071. modal.onmouseleave = Swal.resumeTimer;
  1072. timerInterval = setInterval(() => {
  1073. modal.querySelector("#footer").innerHTML = `<i style="font-size: 82.5%;">약 ${(isNaN(Math.floor(Swal.getTimerLeft()/1000))?'0':Math.floor(Swal.getTimerLeft()/1000))}초 창이 자동으로 닫힙니다.</i>`;
  1074. }, 100);
  1075. },
  1076. willClose: () => {
  1077. clearInterval(timerInterval);
  1078. },
  1079. }).then((result) => {
  1080. if (result.isConfirmed) {
  1081. //get extension env
  1082. if (!GM.info.scriptWillUpdate) {
  1083. window.console.log(abadConstDB.logPrompt.updateManager,'extension not allowed auto update..');
  1084. Swal.fire({
  1085. title: abadConstDB.SWAL2Title,
  1086. html: `<b>주의!</b><br><br><span style="font-size: 97.5%;">스크립트 내용 변경 등으로 인해<br>확장프로그램 내 <b>자동 업데이트</b>가 꺼져있는 같습니다.</span><br><br><span style="font-size: 72.5%;">업데이트 시 기존 스크립트에 덮어쓰게 되어 <u>기존 내용이 <b>손실</b>될 있습니다.</u></span><br><br>이 확인 업데이트 바랍니다.<br><br><i style="font-size: 82.5%;">(계속하려면 확인, 취소하려면 취소를 눌러주세요.)</i>`,
  1087. icon: 'warning',
  1088. showCancelButton: true,
  1089. confirmButtonColor: '#3085d6',
  1090. cancelButtonColor: '#d33',
  1091. confirmButtonText: '확인',
  1092. cancelButtonText: '취소',
  1093. timer: 20000,
  1094. timerProgressBar: true,
  1095. footer: '<span id="footer" style="font-size: 82.5%;">&nbsp;</span>',
  1096. didOpen: (modal) => {
  1097. modal.onmouseenter = Swal.stopTimer;
  1098. modal.onmouseleave = Swal.resumeTimer;
  1099. timerInterval = setInterval(() => {
  1100. modal.querySelector("#footer").innerHTML = `<i style="font-size: 82.5%;">약 ${(isNaN(Math.floor(Swal.getTimerLeft()/1000))?'0':Math.floor(Swal.getTimerLeft()/1000))}초 자동으로 취소됩니다.</i>`;
  1101. }, 100);
  1102. },
  1103. willClose: () => {
  1104. clearInterval(timerInterval);
  1105. },
  1106. }).then((result) => {
  1107. if (result.isConfirmed) {
  1108. openUpdateLink();
  1109. } else {
  1110. window.console.log(abadConstDB.logPrompt.updateManager,"user canceled.");
  1111. }
  1112. });
  1113. } else {
  1114. openUpdateLink();
  1115. }
  1116. } else if (result.isDenied){
  1117. window.console.log(abadConstDB.logPrompt.paramManager,'updatechk change',true.toString(),'to',false.toString());
  1118. try {
  1119. GM.setValue(localParameter.updatechk.param_name, false);
  1120. localParameter.updatechk.value = false;
  1121. window.console.log(abadConstDB.logPrompt.paramManager,"updatechk change successful");
  1122. menuStructureUpdate();
  1123. Swal.fire({
  1124. icon: 'success',
  1125. title: abadConstDB.SWAL2Title,
  1126. html: `<b style="font-size: 82.5%;">앞으로 업데이트 알림을 띄우지 않습니다.</b><br><i style="font-size: 77.5%;">※ <u>설정</u>에서 변경하실 있습니다.</i>`,
  1127. toast: true,
  1128. position: 'top-end',
  1129. timer: 3000,
  1130. timerProgressBar: true,
  1131. confirmButtonText: '확인',
  1132. });
  1133. } catch(e) {
  1134. localParameter.updatechk.value = true;
  1135. window.console.error(abadConstDB.logPrompt.paramManager,"updatechk change fail -", e);
  1136. showSWAL2ErrorLog('파라미터 변경', e);
  1137. }
  1138. } else if (result.isDismissed){
  1139. if (result.dismiss == "timeout") {
  1140. window.console.log(abadConstDB.logPrompt.updateManager,"canceled (timeout)");
  1141. } else if (["cancel", "backdrop"].includes(result.dismiss)) {
  1142. window.console.log(abadConstDB.logPrompt.updateManager,"canceled (user cancel)");
  1143. } else {
  1144. window.console.log(abadConstDB.logPrompt.updateManager,'unknown dismiss -',result.dismiss);
  1145. }
  1146. } else {
  1147. window.console.log(abadConstDB.logPrompt.updateManager,"upd-modal unknown state");
  1148. }
  1149. });
  1150. } else {
  1151. //y/n dialog
  1152. if (window.confirm(abadConstDB.logPrompt.default+'\n새로운 버전이 감지되었습니다. 업데이트를 권장합니다.\n( 기존버전 : '+cur_version+', 새로운 버전 : '+tar_version+' )\n(변경사항은 아카라이브 게시글을 참고해주세요.)\n\n취소를 누르면 앞으로 업데이트 알림을 띄우지 않습니다.')) {
  1153. //get extension env
  1154. if (!GM.info.scriptWillUpdate) {
  1155. window.console.log(abadConstDB.logPrompt.updateManager,'extension not allowed auto update..');
  1156. if (window.confirm(abadConstDB.logPrompt.default+'\n주의! 스크립트 내용 변경 등으로 인해 확장프로그램 내 자동 업데이트가 꺼져있는 것 같습니다.\n업데이트 시 기존 스크립트에 덮어쓰게 되어 기존 내용이 손실될 수 있습니다.\n이 점 확인 후 업데이트 바랍니다.\n\n(계속하려면 확인, 취소하려면 취소를 눌러주세요.)')) {
  1157. openUpdateLink();
  1158. } else {
  1159. window.console.log(abadConstDB.logPrompt.updateManager,"user canceled.");
  1160. }
  1161. } else {
  1162. openUpdateLink();
  1163. }
  1164. } else {
  1165. window.console.log(abadConstDB.logPrompt.paramManager,'updatechk change',true.toString(),'to',false.toString());
  1166. try {
  1167. GM.setValue(localParameter.updatechk.param_name, false);
  1168. localParameter.updatechk.value = false;
  1169. window.console.log(abadConstDB.logPrompt.paramManager,"updatechk change successful");
  1170. menuStructureUpdate();
  1171. window.alert(abadConstDB.logPrompt.default+'\n앞으로 업데이트 알림을 띄우지 않습니다.');
  1172. } catch(e) {
  1173. localParameter.updatechk.value = true;
  1174. window.console.error(abadConstDB.logPrompt.paramManager,"updatechk change fail -", e);
  1175. window.alert(abadConstDB.logPrompt.default+'\n파라미터 변경 중 문제 발생, 브라우저 로그를 확인해주세요..');
  1176. }
  1177. }
  1178. }
  1179. } else {
  1180. window.console.log(abadConstDB.logPrompt.updateManager,'latest version', cur_version, 'detected. (eth:',tar_version,')');
  1181. }
  1182. } else {
  1183. window.console.error(abadConstDB.logPrompt.updateManager,'unable to extract version..');
  1184. }
  1185. })
  1186. .catch(error => {
  1187. updateAvailble = false;
  1188. window.console.error(abadConstDB.logPrompt.updateManager,'link unreachable.. -', error);
  1189. //fetch err -> next retry (CORS)
  1190. try {
  1191. GM.setValue(localParameter.updatechk.param_name, true);
  1192. GM.setValue(localParameter.lastupdate.param_name, currentTime - abadConstDB.updateInterval + 60);
  1193. } catch (_) {}
  1194. });
  1195. updateAvailble = false;
  1196. }
  1197.  
  1198. //menu update
  1199. function menuStructureUpdate(fistRun = false) {
  1200. //pre process
  1201. localParameter.basedepth.value = localParameter.basedepth.value > abadInternalDB.internalDB.autoDecodingMaximum ? abadInternalDB.internalDB.autoDecodingMaximum : localParameter.basedepth.value;
  1202.  
  1203. //update menu name
  1204. menuStructure.basedepth.name = '🎛 base64 깊이 조절하기 - 현재 값 : '+localParameter.basedepth.value+'회';
  1205. menuStructure.enclinkhide.name = '🔗 인코딩된 링크 '+(localParameter.enclinkhide.value?'숨기기':'보이기');
  1206. menuStructure.draggable.name = '🖱 드래그 시 자동 디코딩 '+(localParameter.draggable.value?'끄기':'켜기');
  1207. menuStructure.updatechk.name = '🔄 업데이트 알림 '+(localParameter.updatechk.value?'끄기':'켜기');
  1208. menuStructure.updatenoti.name = '✅ 업데이트 완료 알림 '+(localParameter.updatenoti.value?'끄기':'켜기');
  1209.  
  1210. menuStructure.extlinkwarn.name = '❗️ 외부 링크 경고 '+(localParameter.extlinkwarn.value?'숨기기':'보이기');
  1211. menuStructure.deniedchannel.name = '🏷 이 채널에서 자동 디코딩 [끄기/켜기]';
  1212.  
  1213. menuStructure.expandmenu.name = '⚙️ 스크립트 메뉴 '+(localParameter.expandmenu.value?'축소':'확장');
  1214.  
  1215. //remove exist menu cmd
  1216. if (!fistRun) {
  1217. Object.keys(menuStructure).forEach(function(i) {
  1218. try {
  1219. GM.unregisterMenuCommand(menuStructure[i].id);
  1220. } catch(_) {}
  1221. });
  1222. }
  1223. //monkey menu cmd register
  1224. try {
  1225. //all menu expanded
  1226. if(localParameter.expandmenu.value) {
  1227. Object.keys(menuStructure).forEach(function(i) {
  1228. if (menuStructure[i].visible) {
  1229. menuStructure[i].id = GM.registerMenuCommand(menuStructure[i].name, menuStructure[i].func, {title:menuStructure[i].desc});
  1230. } else {
  1231. //if invisible -> use default parameter
  1232. if (localParameter.hasOwnProperty(i)) {
  1233. localParameter[i].value = localParameter[i].def_value;
  1234. }
  1235. }
  1236. });
  1237. //simple menu
  1238. } else {
  1239. menuStructure.expandmenu.id = GM.registerMenuCommand(menuStructure.expandmenu.name, menuStructure.expandmenu.func, {title:menuStructure.expandmenu.desc});
  1240. }
  1241. window.console.log(abadConstDB.logPrompt.paramManager,'ext opt pannel',(fistRun?'registered':'reloaded'));
  1242. } catch(e) {
  1243. window.console.error(abadConstDB.logPrompt.paramManager,'err - ext opt pannel',(fistRun?'register':'reload'),'- ', e);
  1244. Object.keys(menuStructure).forEach(function(i) {
  1245. try {
  1246. GM.unregisterMenuCommand(menuStructure[i].id);
  1247. } catch(_) {}
  1248. });
  1249. try { GM.registerMenuCommand('ⓘ 메뉴 추가 실패, 브라우저 로그 참고', () => {
  1250. if (abadInternalDB.internalDB.swal2Enable) {
  1251. Swal.fire({
  1252. title: abadConstDB.SWAL2Title,
  1253. html: `메뉴 추가 도중 문제가 발생했습니다.<br><i>브라우저 로그를 확인해주세요..</i>`,
  1254. icon: 'error',
  1255. timer: 5000,
  1256. timerProgressBar: true,
  1257. confirmButtonText: '확인',
  1258. });
  1259. } else {
  1260. window.alert(abadConstDB.logPrompt.default+'\n메뉴 추가 도중 문제가 발생했습니다, 브라우저 로그를 확인해주세요..');
  1261. }
  1262. }); } catch(_) {}
  1263. }
  1264. }
  1265.  
  1266. function menuFuncSubPageReload(showmsg) {
  1267. if (abadInternalDB.internalDB.swal2Enable) {
  1268. Swal.fire({
  1269. title: abadConstDB.SWAL2Title,
  1270. html: `${((showmsg==undefined)?'':('<b>'+showmsg+'</b><br><br>'))}<i>> 반영을 위해 사이트 새로고침이 필요합니다.<br>사이트를 새로고침할까요?</i>`,
  1271. icon: 'info',
  1272. showCancelButton: true,
  1273. confirmButtonColor: '#3085d6',
  1274. confirmButtonText: '새로고침',
  1275. cancelButtonText: '취소',
  1276. }).then((result) => {
  1277. if (result.isConfirmed) {
  1278. window.console.log(abadConstDB.logPrompt.default, 'page reloading..');
  1279. window.location.reload(true);
  1280. } else {
  1281. window.console.log(abadConstDB.logPrompt.default, 'page reload canceled');
  1282. }
  1283. });
  1284. } else {
  1285. if(window.confirm(abadConstDB.logPrompt.default+'\n'+((showmsg==undefined)?'':(showmsg+'\n\n'))+'> 반영을 위해 사이트 새로고침이 필요합니다, 사이트를 새로고침할까요?')) {
  1286. window.console.log(abadConstDB.logPrompt.default, 'page reloading..');
  1287. window.location.reload(true);
  1288. } else {
  1289. window.console.log(abadConstDB.logPrompt.default, 'page reload canceled');
  1290. }
  1291. }
  1292. }
  1293.  
  1294. function menuFunctionBasedepth() {
  1295. menuStructureUpdate();
  1296. const previousValue = localParameter.basedepth.value;
  1297. const str_common_1 = ' ( 지정 가능한 범위: 1~'+abadInternalDB.internalDB.autoDecodingMaximum.toString()+' )';
  1298.  
  1299. if (abadInternalDB.internalDB.swal2Enable) {
  1300. const slideHandler = function(event) {
  1301. const target = Swal.getPopup().querySelector("#footer");
  1302. if (event.target.value > 7) {
  1303. target.style.display = 'block';
  1304. target.innerHTML = `<i>(값을 너무 크게 지정하면 브라우저 성능에 영향을 있습니다.)</i>`;
  1305. } else {
  1306. target.style.display = 'none';
  1307. }
  1308. };
  1309. Swal.fire({
  1310. title: abadConstDB.SWAL2Title,
  1311. icon: "question",
  1312. input: "range",
  1313. html: `<b>Base64 자동 디코딩 중첩 횟수를 얼마로 지정할까요?</b><div style = "font-size: 75%; margin: 1em auto 1em"><i>(인코딩을 인코딩한 것을 여러번 반복한 것을 자동으로 풀어냅니다.)</i></div><span style = "font-size: 87.5%;">현재 값: ${previousValue.toString()}회,${(previousValue == 3 ? '' : ' 기본값: 3회,')}${str_common_1}`,
  1314. inputAttributes: {
  1315. min: "1",
  1316. max: abadInternalDB.internalDB.autoDecodingMaximum.toString(),
  1317. step: "1"
  1318. },
  1319. footer: `<i id="footer">${(previousValue > 7)?'(값을 너무 크게 지정하면 브라우저 성능에 영향을 줄 수 있습니다.)':''}</i>`,
  1320. inputValue: previousValue,
  1321. showCancelButton: true,
  1322. confirmButtonColor: '#3085d6',
  1323. confirmButtonText: '변경',
  1324. cancelButtonText: '취소',
  1325. inputValidator: (value) => {
  1326. return new Promise((resolve) => {
  1327. if (value == previousValue) {
  1328. resolve(`기존값과 동일합니다, 현재 값: ${previousValue}회`);
  1329. } else {
  1330. resolve();
  1331. }
  1332. });
  1333. },
  1334. didOpen: (modal) => {
  1335. modal.querySelector(".swal2-range").firstChild.addEventListener('input', slideHandler, false);
  1336. },
  1337. willClose: (modal) => {
  1338. modal.querySelector(".swal2-range").firstChild.removeEventListener('input', slideHandler);
  1339. },
  1340. }).then((result) => {
  1341. if (result.isConfirmed) {
  1342. const targetValue = parseInt(result.value);
  1343. window.console.log(abadConstDB.logPrompt.paramManager,'basedepth change',previousValue.toString(),'to',targetValue.toString());
  1344. localParameter.basedepth.value = targetValue;
  1345. try {
  1346. GM.setValue(localParameter.basedepth.param_name, targetValue);
  1347. window.console.log(abadConstDB.logPrompt.paramManager,"basedepth change successful");
  1348. menuFuncSubPageReload('자동 디코딩 중첩 횟수가 '+previousValue.toString()+'에서 '+targetValue.toString()+'(으)로<br>변경이 완료되었습니다.');
  1349. } catch(e) {
  1350. localParameter.basedepth.value = previousValue;
  1351. window.console.error(abadConstDB.logPrompt.paramManager,"basedepth change fail -", e);
  1352. showSWAL2ErrorLog('파라미터 변경', e);
  1353. } finally {
  1354. menuStructureUpdate();
  1355. }
  1356. } else {
  1357. window.console.log(abadConstDB.logPrompt.default,'basedepth change canceled.');
  1358. }
  1359. });
  1360. } else {
  1361. while (true) {
  1362. const input = window.prompt(abadConstDB.logPrompt.default+'\nBase64 자동 디코딩 중첩 횟수를 얼마로 지정할까요?\n(인코딩을 인코딩한 것을 여러번 반복한 것을 자동으로 풀어냅니다.)\n현재 값: '+previousValue.toString()+'회,'+(previousValue == 3 ? '' : ' 기본값: 3회,')+str_common_1+'\n\n(값을 너무 크게 지정하면 브라우저 성능에 영향을 줄 수 있습니다.)', previousValue);
  1363. if (input == null) {
  1364. window.console.log(abadConstDB.logPrompt.default,'basedepth change canceled.');
  1365. break;
  1366. }
  1367. if (!isNaN(input)) {
  1368. const targetValue = parseInt(input);
  1369. if (targetValue == previousValue) {
  1370. window.alert(abadConstDB.logPrompt.default+'\n동일한 값을 입력했습니다, 현재 값: '+previousValue+'회');
  1371. } else if (targetValue >= 1 && targetValue <= abadInternalDB.internalDB.autoDecodingMaximum) {
  1372. window.console.log(abadConstDB.logPrompt.paramManager,'basedepth change',previousValue.toString(),'to',targetValue.toString());
  1373. localParameter.basedepth.value = targetValue;
  1374. try {
  1375. GM.setValue(localParameter.basedepth.param_name, targetValue);
  1376. window.console.log(abadConstDB.logPrompt.paramManager,"basedepth change successful");
  1377. menuFuncSubPageReload('값이 '+previousValue.toString()+'에서 '+targetValue.toString()+'으로 변경이 완료되었습니다.');
  1378. } catch(e) {
  1379. localParameter.basedepth.value = previousValue;
  1380. window.console.error(abadConstDB.logPrompt.paramManager,"basedepth change fail -", e);
  1381. window.alert(abadConstDB.logPrompt.default+'\n파라미터 변경 중 문제 발생, 브라우저 로그를 확인해주세요..');
  1382. } finally {
  1383. menuStructureUpdate();
  1384. break;
  1385. }
  1386. } else {
  1387. window.alert(abadConstDB.logPrompt.default+'\n'+targetValue+'(으)로 설정할 수 없습니다.\n범위를 초과하였습니다..'+str_common_1);
  1388. }
  1389. } else {
  1390. window.alert(abadConstDB.logPrompt.default+'\n'+input+'은(는)숫자가 아닙니다.\n숫자만 입력해주세요..'+str_common_1);
  1391. }
  1392. }
  1393. }
  1394. }
  1395.  
  1396. function menuFunctionEnchide() {
  1397. menuStructureUpdate();
  1398. const currentState = localParameter.enclinkhide.value;
  1399. if (abadInternalDB.internalDB.swal2Enable) {
  1400. Swal.fire({
  1401. title: abadConstDB.SWAL2Title,
  1402. html: `<b>디코딩 인코딩된 링크를 ${(currentState?'숨기시':'표시하')}겠습니까?</b><br><br><i>(앞으로 디코딩 전 인코딩된 링크를<br>"${(currentState?'클릭 시 기존링크 보기':'aHR0cHM6Ly9hcmNhLmx..')}"와 같은 형태로<br>보여줍니다.)</i>`,
  1403. icon: 'question',
  1404. showCancelButton: true,
  1405. confirmButtonColor: '#3085d6',
  1406. cancelButtonColor: '#d33',
  1407. confirmButtonText: (currentState?'숨기기':'표시하기'),
  1408. cancelButtonText: '취소',
  1409. }).then((result) => {
  1410. if (result.isConfirmed) {
  1411. const targetState = !currentState;
  1412. window.console.log(abadConstDB.logPrompt.paramManager,'enchide change',currentState.toString(),'to',targetState.toString());
  1413. localParameter.enclinkhide.value = targetState;
  1414. try {
  1415. GM.setValue(localParameter.enclinkhide.param_name, targetState);
  1416. window.console.log(abadConstDB.logPrompt.paramManager,"enchide change successful");
  1417. menuFuncSubPageReload('앞으로 인코딩된 링크를 '+(targetState?'표시합':'숨깁')+'니다.');
  1418. } catch(e) {
  1419. localParameter.enclinkhide.value = currentState;
  1420. window.console.error(abadConstDB.logPrompt.paramManager,"enchide change fail -", e);
  1421. showSWAL2ErrorLog('파라미터 변경', e);
  1422. } finally {
  1423. menuStructureUpdate();
  1424. }
  1425. } else {
  1426. window.console.log(abadConstDB.logPrompt.default,'enchide change canceled.');
  1427. }
  1428. });
  1429. } else {
  1430. if (window.confirm(abadConstDB.logPrompt.default+'\n디코딩 시 인코딩된 링크를 '+(currentState?'숨기시':'표시하')+'겠습니까?\n\n(앞으로 디코딩 전 인코딩된 링크를\n"'+(currentState?'클릭 시 기존링크 보기':'aHR0cHM6Ly9hcmNhLmx..')+'"와 같은 형태로 보여줍니다.)')) {
  1431. const targetState = !currentState;
  1432. window.console.log(abadConstDB.logPrompt.paramManager,'enchide change',currentState.toString(),'to',targetState.toString());
  1433. localParameter.enclinkhide.value = targetState;
  1434. try {
  1435. GM.setValue(localParameter.enclinkhide.param_name, targetState);
  1436. window.console.log(abadConstDB.logPrompt.paramManager,"enchide change successful");
  1437. menuFuncSubPageReload('앞으로 인코딩된 링크를 '+(targetState?'표시합':'숨깁')+'니다.');
  1438. } catch(e) {
  1439. localParameter.enclinkhide.value = currentState;
  1440. window.console.error(abadConstDB.logPrompt.paramManager,"enchide change fail -", e);
  1441. window.alert(abadConstDB.logPrompt.default+'\n파라미터 변경 중 문제 발생, 브라우저 로그를 확인해주세요..');
  1442. } finally {
  1443. menuStructureUpdate();
  1444. }
  1445. } else {
  1446. window.console.log(abadConstDB.logPrompt.default,'enchide change canceled.');
  1447. }
  1448. }
  1449. }
  1450.  
  1451. function menuFunctionDraggable() {
  1452. menuStructureUpdate();
  1453. const currentState = localParameter.draggable.value;
  1454. if (abadInternalDB.internalDB.swal2Enable) {
  1455. Swal.fire({
  1456. title: abadConstDB.SWAL2Title,
  1457. html: `<b>드래그 자동 디코딩을 ${(currentState?'비':'')}활성화 하시겠습니까?</b><br><br><i>(앞으로 인코딩된 부분을 드래그${(currentState?'해도<br>자동으로 디코딩되지 않습':' 시 Base64로 인코딩된<br>것으로 판단 되면 자동으로 디코딩을 시도합')}니다.)</i>${(currentState?'':'<br><br><i>(이 기능은 작동이 불안정할 수 있습니다.)</i>')}`,
  1458. icon: 'question',
  1459. showDenyButton: true,
  1460. showCancelButton: !currentState,
  1461. confirmButtonColor: '#3085d6',
  1462. confirmButtonText: (currentState?'비활성화':'활성화'),
  1463. denyButtonText: '취소',
  1464. cancelButtonText: '이번에만 활성화',
  1465. }).then((result) => {
  1466. if (result.isConfirmed) {
  1467. const targetState = !currentState;
  1468. window.console.log(abadConstDB.logPrompt.paramManager,'draggable change',currentState.toString(),'to',targetState.toString());
  1469. localParameter.draggable.value = targetState;
  1470. try {
  1471. GM.setValue(localParameter.draggable.param_name, targetState);
  1472. window.console.log(abadConstDB.logPrompt.paramManager,"draggable change successful");
  1473. if (targetState) {
  1474. try {
  1475. activateDragDecoding();
  1476. Swal.fire({
  1477. icon: 'success',
  1478. title: abadConstDB.SWAL2Title,
  1479. html: `<b style="font-size: 77.5%">앞으로 드래그 자동 디코딩을 진행합니다.</b>`,
  1480. toast: true,
  1481. position: 'center',
  1482. timer: 2000,
  1483. timerProgressBar: true,
  1484. confirmButtonText: '확인',
  1485. });
  1486. } catch(e) {
  1487. window.console.error(abadConstDB.logPrompt.default,"draggable activate fail -", e);
  1488. showSWAL2ErrorLog('드래그 시 자동 디코딩 활성화', e);
  1489. }
  1490. } else {
  1491. menuFuncSubPageReload('앞으로 드래그 해도 반응하지 않습니다.');
  1492. }
  1493. } catch(e) {
  1494. localParameter.draggable.value = currentState;
  1495. window.console.error(abadConstDB.logPrompt.paramManager,"draggable change fail -", e);
  1496. showSWAL2ErrorLog('파라미터 변경', e);
  1497. } finally {
  1498. menuStructureUpdate();
  1499. }
  1500. } else if (result.isDismissed) {
  1501. try {
  1502. activateDragDecoding();
  1503. Swal.fire({
  1504. icon: 'success',
  1505. title: abadConstDB.SWAL2Title,
  1506. html: `<b style="font-size: 77.5%">드래그 자동 디코딩이 활성화되었습니다.</b><br><i style="font-size: 67.5%">새로고침 시 자동으로 비활성화됩니다.</i>`,
  1507. toast: true,
  1508. position: 'center',
  1509. timer: 2000,
  1510. timerProgressBar: true,
  1511. confirmButtonText: '확인',
  1512. });
  1513. } catch(e) {
  1514. window.console.error(abadConstDB.logPrompt.default,"draggable activate fail -", e);
  1515. showSWAL2ErrorLog('드래그 시 자동 디코딩 활성화(일회성)', e);
  1516. }
  1517. }else {
  1518. window.console.log(abadConstDB.logPrompt.default,'draggable change canceled.');
  1519. }
  1520. });
  1521. } else {
  1522. if (window.confirm(abadConstDB.logPrompt.default+'\n드래그 시 자동 디코딩을 '+(currentState?'비':'')+'활성화 하시겠습니까?\n\n(앞으로 인코딩된 부분을 드래그'+(currentState?'해도 자동으로 디코딩되지 않습':' 시 Base64로 인코딩된것으로\n판단 되면 자동으로 디코딩을 시도합')+'니다.)'+(currentState?'':'\n\n(이 기능은 작동이 불안정할 수 있습니다.)'))) {
  1523. const targetState = !currentState;
  1524. window.console.log(abadConstDB.logPrompt.paramManager,'draggable change',currentState.toString(),'to',targetState.toString());
  1525. localParameter.draggable.value = targetState;
  1526. try {
  1527. GM.setValue(localParameter.draggable.param_name, targetState);
  1528. window.console.log(abadConstDB.logPrompt.paramManager,"draggable change successful");
  1529. if (targetState) {
  1530. try {
  1531. activateDragDecoding();
  1532. window.alert(abadConstDB.logPrompt.default+'\n앞으로 드래그 시 자동 디코딩을 진행합니다.');
  1533. } catch(e) {
  1534. window.console.error(abadConstDB.logPrompt.default,"draggable activate fail -", e);
  1535. window.alert(abadConstDB.logPrompt.default+'\n드래그 시 자동 디코딩 활성화 중 문제가 발생했습니다, 브라우저 로그를 확인해주세요..\n새로고침이 필요합니다..');
  1536. }
  1537. } else {
  1538. menuFuncSubPageReload('앞으로 드래그 해도 반응하지 않습니다.');
  1539. }
  1540. } catch(e) {
  1541. localParameter.draggable.value = currentState;
  1542. window.console.error(abadConstDB.logPrompt.paramManager,"draggable change fail -", e);
  1543. window.alert(abadConstDB.logPrompt.default+'\n파라미터 변경 중 문제 발생, 브라우저 로그를 확인해주세요..');
  1544. } finally {
  1545. menuStructureUpdate();
  1546. }
  1547. } else {
  1548. window.console.log(abadConstDB.logPrompt.default,'draggable change canceled.');
  1549. }
  1550. }
  1551. }
  1552.  
  1553. //TODO
  1554. function menuFunctionCheckUpdate() {
  1555. let timerInterval;
  1556. Swal.fire({
  1557. title: abadConstDB.SWAL2Title,
  1558. html: `스크립트 업데이트 확인중..<br><br>[DEMO:TODO]<br>left <b></b> ms.`,
  1559. timer: 2000,
  1560. timerProgressBar: true,
  1561. allowOutsideClick: false,
  1562. allowEscapeKey: false,
  1563. allowEnterKey: false,
  1564. didOpen: () => {
  1565. Swal.showLoading();
  1566. const timer = Swal.getPopup().querySelector("b");
  1567. timerInterval = setInterval(() => {
  1568. timer.textContent = `${Swal.getTimerLeft()}`;
  1569. }, 100);
  1570. },
  1571. willClose: () => {
  1572. clearInterval(timerInterval);
  1573. },
  1574. }).then((result) => {
  1575. Swal.fire({
  1576. icon: 'success',
  1577. title: abadConstDB.SWAL2Title,
  1578. html: `스크립트가 최신버전입니다<br><i>${GM.info.script.name} V ${GM.info.script.version}</i>`,
  1579. toast: true,
  1580. position: 'center',
  1581. timer: 2000,
  1582. timerProgressBar: true,
  1583. confirmButtonText: '확인',
  1584. });
  1585.  
  1586. /* Read more about handling dismissals below */
  1587. if (result.dismiss === Swal.DismissReason.timer) {
  1588. console.log("TMOUT");
  1589. }
  1590. });
  1591. }
  1592.  
  1593. function menuFunctionUpdateCheck() {
  1594. menuStructureUpdate();
  1595. const currentState = localParameter.updatechk.value;
  1596. if (abadInternalDB.internalDB.swal2Enable) {
  1597. Swal.fire({
  1598. title: abadConstDB.SWAL2Title,
  1599. html: `<b>업데이트 알림을 ${(currentState?'끄':'켜')}시겠습니까?</b><br><br><i>(앞으로 업데이트가 있${(currentState?'어도 알려주지 않습':'으면 자동으로 알려줍')}니다.)</i>`,
  1600. icon: 'question',
  1601. showCancelButton: true,
  1602. confirmButtonColor: '#3085d6',
  1603. cancelButtonColor: '#d33',
  1604. confirmButtonText: (currentState?'끄기':'켜기'),
  1605. cancelButtonText: '취소',
  1606. }).then((result) => {
  1607. if (result.isConfirmed) {
  1608. const targetState = !currentState;
  1609. window.console.log(abadConstDB.logPrompt.paramManager,'updatechk change',currentState.toString(),'to',targetState.toString());
  1610. localParameter.updatechk.value = targetState;
  1611. try {
  1612. GM.setValue(localParameter.updatechk.param_name, targetState);
  1613. window.console.log(abadConstDB.logPrompt.paramManager,"updatechk change successful");
  1614. Swal.fire({
  1615. icon: 'success',
  1616. title: abadConstDB.SWAL2Title,
  1617. html: `<b style="font-size: ${(targetState?'75':'77.5')}%">앞으로 업데이트${(targetState?'가 존재하면':'')} 알림을 ${(targetState?'웁':'우지 않습')}니다.</b>`,
  1618. toast: true,
  1619. position: 'center',
  1620. timer: 2000,
  1621. timerProgressBar: true,
  1622. confirmButtonText: '확인',
  1623. });
  1624. } catch(e) {
  1625. localParameter.updatechk.value = currentState;
  1626. window.console.error(abadConstDB.logPrompt.paramManager,"updatechk change fail -", e);
  1627. showSWAL2ErrorLog('파라미터 변경', e);
  1628. } finally {
  1629. menuStructureUpdate();
  1630. }
  1631. } else {
  1632. window.console.log(abadConstDB.logPrompt.default,'updatechk change canceled.');
  1633. }
  1634. });
  1635. } else {
  1636. if (window.confirm(abadConstDB.logPrompt.default+'\n업데이트 알림을 '+(currentState?'끄':'켜')+'시겠습니까?\n\n(앞으로 업데이트가 있'+(currentState?'어도 알려주지 않습':'으면 자동으로 알려줍')+'니다.)')) {
  1637. const targetState = !currentState;
  1638. window.console.log(abadConstDB.logPrompt.paramManager,'updatechk change',currentState.toString(),'to',targetState.toString());
  1639. localParameter.updatechk.value = targetState;
  1640. try {
  1641. GM.setValue(localParameter.updatechk.param_name, targetState);
  1642. window.console.log(abadConstDB.logPrompt.paramManager,"updatechk change successful");
  1643. window.alert(abadConstDB.logPrompt.default+'\n앞으로 업데이트'+(targetState?'가 존재하면':'')+' 알림을 띄'+(targetState?'웁':'우지 않습')+'니다.');
  1644. } catch(e) {
  1645. localParameter.updatechk.value = currentState;
  1646. window.console.error(abadConstDB.logPrompt.paramManager,"updatechk change fail -", e);
  1647. window.alert(abadConstDB.logPrompt.default+'\n파라미터 변경 중 문제 발생, 브라우저 로그를 확인해주세요..');
  1648. } finally {
  1649. menuStructureUpdate();
  1650. }
  1651. } else {
  1652. window.console.log(abadConstDB.logPrompt.default,'updatechk change canceled.');
  1653. }
  1654. }
  1655. }
  1656.  
  1657.  
  1658. function menuFunctionUpdateNotice() {
  1659. menuStructureUpdate();
  1660. const currentState = localParameter.updatenoti.value;
  1661. if (abadInternalDB.internalDB.swal2Enable) {
  1662. Swal.fire({
  1663. title: abadConstDB.SWAL2Title,
  1664. html: `<b>업데이트 완료 알림을 ${(currentState?'끄':'켜')}시겠습니까?</b><br><br><i>(앞으로 업데이트 완료 시 ${(currentState?'알려주지 않습':'자동으로 알려줍')}니다.)</i>`,
  1665. icon: 'question',
  1666. showCancelButton: true,
  1667. confirmButtonColor: '#3085d6',
  1668. cancelButtonColor: '#d33',
  1669. confirmButtonText: (currentState?'끄기':'켜기'),
  1670. cancelButtonText: '취소',
  1671. }).then((result) => {
  1672. if (result.isConfirmed) {
  1673. const targetState = !currentState;
  1674. window.console.log(abadConstDB.logPrompt.paramManager,'updatenoti change',currentState.toString(),'to',targetState.toString());
  1675. localParameter.updatenoti.value = targetState;
  1676. try {
  1677. GM.setValue(localParameter.updatenoti.param_name, targetState);
  1678. window.console.log(abadConstDB.logPrompt.paramManager,"updatenoti change successful");
  1679. Swal.fire({
  1680. icon: 'success',
  1681. title: abadConstDB.SWAL2Title,
  1682. html: `<b style="font-size: ${(targetState?'77.5':'70')}%">앞으로 업데이트 완료 알림을 ${(targetState?'웁':'우지 않습')}니다.</b>`,
  1683. toast: true,
  1684. position: 'center',
  1685. timer: 2000,
  1686. timerProgressBar: true,
  1687. confirmButtonText: '확인',
  1688. });
  1689. } catch(e) {
  1690. localParameter.updatenoti.value = currentState;
  1691. window.console.error(abadConstDB.logPrompt.paramManager,"updatenoti change fail -", e);
  1692. showSWAL2ErrorLog('파라미터 변경', e);
  1693. } finally {
  1694. menuStructureUpdate();
  1695. }
  1696. } else {
  1697. window.console.log(abadConstDB.logPrompt.default,'updatenoti change canceled.');
  1698. }
  1699. });
  1700. } else {
  1701. if (window.confirm(abadConstDB.logPrompt.default+'\n업데이트 완료 알림을 '+(currentState?'끄':'켜')+'시겠습니까?</b><br><br><i>(앞으로 업데이트 완료 시 '+(currentState?'알려주지 않습':'자동으로 알려줍')+'니다.)')) {
  1702. const targetState = !currentState;
  1703. window.console.log(abadConstDB.logPrompt.paramManager,'updatenoti change',currentState.toString(),'to',targetState.toString());
  1704. localParameter.updatenoti.value = targetState;
  1705. try {
  1706. GM.setValue(localParameter.updatenoti.param_name, targetState);
  1707. window.console.log(abadConstDB.logPrompt.paramManager,"updatenoti change successful");
  1708. window.alert(abadConstDB.logPrompt.default+'\n앞으로 업데이트 완료 시 알림을 띄'+(targetState?'웁':'우지 않습')+'니다.');
  1709. } catch(e) {
  1710. localParameter.updatenoti.value = currentState;
  1711. window.console.error(abadConstDB.logPrompt.paramManager,"updatenoti change fail -", e);
  1712. window.alert(abadConstDB.logPrompt.default+'\n파라미터 변경 중 문제 발생, 브라우저 로그를 확인해주세요..');
  1713. } finally {
  1714. menuStructureUpdate();
  1715. }
  1716. } else {
  1717. window.console.log(abadConstDB.logPrompt.default,'updatenoti change canceled.');
  1718. }
  1719. }
  1720. }
  1721.  
  1722. function menuFunctionChangeExpandMode() {
  1723. menuStructureUpdate();
  1724. const currentState = localParameter.expandmenu.value;
  1725. if (abadInternalDB.internalDB.swal2Enable) {
  1726. Swal.fire({
  1727. title: abadConstDB.SWAL2Title,
  1728. html: `<b>메뉴에 나타나는 항목을 ${(currentState?'줄일':'늘릴')}까요?</b><br><br><i>(앞으로 세부설정 메뉴가 ${(currentState?'숨겨':'보여')}집니다.)</i>`,
  1729. icon: 'question',
  1730. showCancelButton: true,
  1731. confirmButtonColor: '#3085d6',
  1732. cancelButtonColor: '#d33',
  1733. confirmButtonText: (currentState?'줄이기':'표시하기'),
  1734. cancelButtonText: '취소',
  1735. }).then((result) => {
  1736. if (result.isConfirmed) {
  1737. const targetState = !currentState;
  1738. window.console.log(abadConstDB.logPrompt.paramManager,'menuexpand change',currentState.toString(),'to',targetState.toString());
  1739. localParameter.expandmenu.value = targetState;
  1740. try {
  1741. GM.setValue(localParameter.expandmenu.param_name, targetState);
  1742. window.console.log(abadConstDB.logPrompt.paramManager,"menuexpand change successful");
  1743. Swal.fire({
  1744. icon: 'success',
  1745. title: abadConstDB.SWAL2Title,
  1746. html: `<b style="font-size: 87.5%">앞으로 세부설정 메뉴가 ${(targetState?'보여':'숨겨')}집니다.</b>`,
  1747. toast: true,
  1748. position: 'center',
  1749. timer: 2000,
  1750. timerProgressBar: true,
  1751. confirmButtonText: '확인',
  1752. });
  1753. } catch(e) {
  1754. localParameter.expandmenu.value = currentState;
  1755. window.console.error(abadConstDB.logPrompt.paramManager,"menuexpand change fail -", e);
  1756. showSWAL2ErrorLog('파라미터 변경', e);
  1757. } finally {
  1758. menuStructureUpdate();
  1759. }
  1760. } else {
  1761. window.console.log(abadConstDB.logPrompt.default,'menuexpand change canceled.');
  1762. }
  1763. });
  1764. } else {
  1765. if (window.confirm(abadConstDB.logPrompt.default+'\n메뉴에 나타나는 항목을 '+(currentState?'줄일':'늘릴')+'까요?\n\n(앞으로 세부설정 메뉴가 '+(currentState?'숨겨':'보여')+'집니다.)')) {
  1766. const targetState = !currentState;
  1767. window.console.log(abadConstDB.logPrompt.paramManager,'menuexpand change',currentState.toString(),'to',targetState.toString());
  1768. localParameter.expandmenu.value = targetState;
  1769. try {
  1770. GM.setValue(localParameter.expandmenu.param_name, targetState);
  1771. window.console.log(abadConstDB.logPrompt.paramManager,"menuexpand change successful");
  1772. window.alert(abadConstDB.logPrompt.default+'\n앞으로 세부설정 메뉴가 '+(targetState?'보여':'숨겨')+'집니다.');
  1773. } catch(e) {
  1774. localParameter.expandmenu.value = currentState;
  1775. window.console.error(abadConstDB.logPrompt.paramManager,"menuexpand change fail -", e);
  1776. window.alert(abadConstDB.logPrompt.default+'\n파라미터 변경 중 문제 발생, 브라우저 로그를 확인해주세요..');
  1777. } finally {
  1778. menuStructureUpdate();
  1779. }
  1780. } else {
  1781. window.console.log(abadConstDB.logPrompt.default,'menuexpand change canceled.');
  1782. }
  1783. }
  1784. }
  1785.  
  1786. function menuFunctionRstDefaults() {
  1787. menuStructureUpdate();
  1788. if (abadInternalDB.internalDB.swal2Enable) {
  1789. Swal.fire({
  1790. title: abadConstDB.SWAL2Title,
  1791. html: `<b>정말 스크립트 설정을 기본값으로 초기화하시겠습니까?</b><br><br><i>(초기화 완료 후 자동으로 새로고침됩니다.)</i>`,
  1792. icon: 'warning',
  1793. showCancelButton: true,
  1794. confirmButtonColor: '#3085d6',
  1795. cancelButtonColor: '#d33',
  1796. focusCancel: true,
  1797. confirmButtonText: '초기화 진행',
  1798. cancelButtonText: '취소',
  1799. showLoaderOnConfirm: true,
  1800. timer: 10000,
  1801. timerProgressBar: true,
  1802. didOpen: (modal) => {
  1803. modal.onmouseenter = Swal.stopTimer;
  1804. modal.onmouseleave = Swal.resumeTimer;
  1805. },
  1806. }).then((result) => {
  1807. if (result.isConfirmed) {
  1808. window.console.log(abadConstDB.logPrompt.paramManager, 'remove all settings..');
  1809. Swal.fire({
  1810. title: abadConstDB.SWAL2Title,
  1811. html: `<b>설정값을 제거중입니다, 잠시만 기다려주세요..</b>`,
  1812. footer: `<i>1 이내로 창이 사라지지 않으면 수동으로 새로고침해주세요.</i>`,
  1813. didOpen: () => {
  1814. Swal.showLoading();
  1815. },
  1816. showConfirmButton: false,
  1817. allowOutsideClick: false,
  1818. allowEscapeKey: false,
  1819. allowEnterKey: false,
  1820. });
  1821. try {
  1822. Object.keys(menuStructure).forEach(function(i) {
  1823. try {
  1824. GM.unregisterMenuCommand(menuStructure[i].id);
  1825. } catch(_) {}
  1826. });
  1827. for (const i of Object.keys(localParameter)) {
  1828. console.log(abadConstDB.logPrompt.paramManager, 'try to remove -', localParameter[i].param_name);
  1829. GM.deleteValue(localParameter[i].param_name);
  1830. }
  1831. sleep(250).then(() => {
  1832. window.console.log(abadConstDB.logPrompt.paramManager, 'all parameter removed.');
  1833. Swal.fire({
  1834. title: abadConstDB.SWAL2Title,
  1835. html: `<b>설정값이 모두 제거되었습니다.</b><br><br><i>(확인 후 현재 창이 자동으로 새로고침됩니다.)</i>`,
  1836. footer: `<i style="font-size: 82.5%;">비정상적으로 동작 스크립트를 재설치해주세요.</i>`,
  1837. icon: 'success',
  1838. confirmButtonColor: '#3085d6',
  1839. confirmButtonText: '확인',
  1840. didOpen: () => {
  1841. Swal.hideLoading();
  1842. },
  1843. }).then(() => {
  1844. window.location.reload(true);
  1845. });
  1846. });
  1847. } catch(e) {
  1848. window.console.error(abadConstDB.logPrompt.paramManager,'err - get sc parameter - ', e);
  1849. Swal.close();
  1850. showSWAL2ErrorLog('파라미터 초기화', e);
  1851. }
  1852. } else {
  1853. window.console.log(abadConstDB.logPrompt.default,'settings restore canceled.');
  1854. }
  1855. });
  1856. } else {
  1857. if (window.confirm(abadConstDB.logPrompt.default+'\n정말 스크립트 설정을 기본값으로 초기화하시겠습니까?\n\n(초기화 완료 후 자동으로 새로고침됩니다.)')) {
  1858. try {
  1859. window.console.log(abadConstDB.logPrompt.paramManager, 'remove all settings..');
  1860. for (const i of Object.keys(localParameter)) {
  1861. console.log(abadConstDB.logPrompt.paramManager, 'try to remove -', localParameter[i].param_name);
  1862. GM.deleteValue(localParameter[i].param_name);
  1863. }
  1864. Object.keys(menuStructure).forEach(function(i) {
  1865. try {
  1866. GM.unregisterMenuCommand(menuStructure[i].id);
  1867. } catch(_) {}
  1868. });
  1869. window.console.log(abadConstDB.logPrompt.paramManager, 'all parameter removed.');
  1870. window.alert(abadConstDB.logPrompt.default+'\n설정값이 모두 제거되었습니다.\n\n(확인 후 현재 창이 자동으로 새로고침됩니다.)');
  1871. window.location.reload(true);
  1872. } catch(e) {
  1873. window.console.error(abadConstDB.logPrompt.paramManager,'err - get sc parameter - ', e);
  1874. window.alert(abadConstDB.logPrompt.default+'\n경고! 파라미터 초기화 도중 문제가 발생했습니다. 브라우저 로그를 참고해주세요..');
  1875. }
  1876. } else {
  1877. window.console.log(abadConstDB.logPrompt.default,'settings restore canceled.');
  1878. }
  1879. }
  1880. }
  1881.  
  1882. function menuFunctionNotAvailable() {
  1883. window.console.log(abadConstDB.logPrompt.default,'unavailable function clicked');
  1884. if (abadInternalDB.internalDB.swal2Enable) {
  1885. Swal.fire({
  1886. title: abadConstDB.SWAL2Title,
  1887. html: `현재 사용할 없는 기능입니다..<br><br><i>(구현되지 않았거나 버그로 인해 일시적으로<br>현재버전에서 비활성화된 기능입니다.)</i>`,
  1888. icon: 'error',
  1889. timer: 5000,
  1890. timerProgressBar: true,
  1891. confirmButtonText: '확인',
  1892. });
  1893. } else {
  1894. window.alert(abadConstDB.logPrompt.default+'\n현재 사용할 수 없는 기능입니다..');
  1895. }
  1896. }
  1897.  
  1898. //main
  1899. (async () => {
  1900. 'use strict';
  1901.  
  1902. //chk browser env
  1903. if (((window.navigator.language || window.navigator.userLanguage) != 'ko-KR')) {
  1904. window.console.warn('Warning! this script support only korean language..');
  1905. }
  1906.  
  1907. window.console.log(abadConstDB.logPrompt.default,'V',GM.info.script.version,'pre processing..');
  1908.  
  1909. //Sweet Alert2 chk
  1910. if (window.Swal != undefined) {
  1911. const styleSA2 = document.createElement('style');
  1912. styleSA2.textContent = '.swal2-container { z-index: 2400; }';
  1913. document.head.appendChild(styleSA2);
  1914. abadInternalDB.internalDB.swal2Enable = true;
  1915. window.console.log(abadConstDB.logPrompt.default,'SA2 loaded');
  1916. }
  1917.  
  1918. //check edit mode
  1919. if (window.location.pathname.match(/\/b\/.*?\/(write|edit)/)) {
  1920. window.console.log(abadConstDB.logPrompt.default,'write/edit mode detected, function disabled.');
  1921. try {
  1922. GM.registerMenuCommand("작성/수정 모드에서는 동작하지 않음", ()=>{
  1923. if (abadInternalDB.internalDB.swal2Enable) {
  1924. Swal.fire({
  1925. title: abadConstDB.SWAL2Title,
  1926. html: `작성 또는 수정모드에서는 동작하지 않습니다..`,
  1927. icon: 'error',
  1928. timer: 5000,
  1929. timerProgressBar: true,
  1930. confirmButtonText: '확인',
  1931. });
  1932. } else {
  1933. window.alert(abadConstDB.logPrompt.default+'\n작성 또는 수정모드에서는 동작하지 않습니다..');
  1934. }
  1935. }, {title:'작성 또는 수정모드에서는 동작하지 않습니다.'});
  1936. } catch(_) {}
  1937. return;
  1938. }
  1939.  
  1940. window.console.log(abadConstDB.logPrompt.default,'abad enabled');
  1941.  
  1942. //load parameter
  1943. try {
  1944. for (const i of Object.keys(localParameter)) {
  1945. localParameter[i].value = await GM.getValue(localParameter[i].param_name, localParameter[i].def_value);
  1946. }
  1947. window.console.log(abadConstDB.logPrompt.paramManager, 'sc parameter load completed.');
  1948. } catch(e) {
  1949. window.console.error(abadConstDB.logPrompt.paramManager,'err - get sc parameter - ', e);
  1950. }
  1951.  
  1952. //apply parameter and register monkey menu command
  1953. menuStructureUpdate(true);
  1954.  
  1955. //chk update
  1956. await checkForUpdate();
  1957.  
  1958. //drag auto decoding
  1959. if (localParameter.draggable.value) {
  1960. activateDragDecoding();
  1961. }
  1962.  
  1963. window.console.log(abadConstDB.logPrompt.default,'script ready');
  1964. //main procedure
  1965.  
  1966. //article
  1967. let article = document.getElementsByClassName("article-content")[0];
  1968. if (article != undefined) {
  1969. for (let i=0; i<localParameter.basedepth.value; i++) {
  1970. article.innerHTML = article.innerHTML.replaceAll(regexEncodedPrefixDef[i], replacerGen(i, 'article'));
  1971. }
  1972. } else window.console.warn(abadConstDB.logPrompt.default,'article not found.');
  1973. const decoded_article = hindex;
  1974.  
  1975. //comment
  1976. let comments = document.getElementsByClassName("list-area");
  1977. if (article != undefined) {
  1978. if (comments.length != 0) {
  1979. for (let i=0; i<localParameter.basedepth.value; i++) {
  1980. comments[0].innerHTML = comments[0].innerHTML.replaceAll(regexEncodedPrefixDef[i], replacerGen(i, 'comment'));
  1981. }
  1982. }
  1983. } else window.console.warn(abadConstDB.logPrompt.default,'comments not found.');
  1984. const decoded_comment = hindex - decoded_article;
  1985.  
  1986. window.console.log(abadConstDB.logPrompt.decodeManager,'total',hindex,'link decode task finished. (article:', decoded_article, ', comment:', decoded_comment, ')');
  1987.  
  1988. //sorting detected hostname
  1989. abadInternalDB.hostnameSet = Array.from(abadInternalDB.hostnameSetRaw).sort();
  1990.  
  1991. //show result on article top
  1992. if (decoded_article+decoded_comment>0) {
  1993. let result = document.createElement("div");
  1994. result.id = createElemID();
  1995. result.class = 'btn';
  1996. result.style.marginTop = '10px';
  1997. result.style.marginBottom = '10px';
  1998. result.style.paddingTop = '7px';
  1999.  
  2000. let result_box = document.createElement("span");
  2001. //result_box.style.border = '1.5px solid #68b3ff';
  2002. //result_box.style.padding = '7px 15px';
  2003.  
  2004. let result_in = '<div style="color: #e83e8c; border: 1.5px solid #68b3ff; padding: 7px 15px;">';
  2005. if (decoded_article+decoded_comment>0) {
  2006. result_box.title = '클릭 시 디코딩된 링크를 한번에 볼 수 있습니다.';
  2007. result_in += `총 ${(decoded_article+decoded_comment)}개의 링크가 자동 디코딩되었습니다.<br><span style="font-size: 75%;">( ${((decoded_article>0)?('게시글: '+decoded_article+'개'+((decoded_comment>0)?' / ':'')):'')}${((decoded_comment>0)?('댓글: '+decoded_comment+'개'):'')} ) / ( 사이트 종류: ${abadInternalDB.hostnameSet.length}개 )</span>`;
  2008. result_in += `<p><i>(클릭하여 자세히 보기)</i></p>`;
  2009. } else {//not use
  2010. result_box.title = '이 게시글 또는 댓글에서 Base64로 인코딩 된 링크가 감지되지 않았습니다..';
  2011. result_in += '<span style="font-size: 75%;"><i>이 게시글 또는 댓글에서 Base64로 인코딩 된 링크가 감지되지 않았습니다..</i></span>';
  2012. }
  2013. result_in += '</div>';
  2014. result_box.innerHTML = result_in;
  2015. result_box.addEventListener('click', showDecodeSummary);
  2016. result.appendChild(result_box);
  2017. result.appendChild(document.createElement("hr"));
  2018. article.parentNode.prepend(result);
  2019. }
  2020.  
  2021. //add event listner - click, show original encoded link
  2022. if (!localParameter.enclinkhide.value) {
  2023. Object.keys(abadInternalDB.encodedLink).forEach(function(i) {
  2024. document.getElementById(i).addEventListener('click', showEncodedLink); //, { once : true }
  2025. });
  2026. }
  2027.  
  2028. })();