Arca base64 autodecoder

auto decode Base64 encoded link in Arca.live

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

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