Arca base64 autodecoder

auto decode Base64 encoded link in Arca.live

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

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