Arca base64 autodecoder

auto decode Base64 encoded link in Arca.live

安装此脚本?
作者推荐脚本

您可能也喜欢oo.pe redirection remover

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