de4js helper

Enable Unreadable option in de4js

  1. // ==UserScript==
  2. // @name de4js helper
  3. // @namespace https://baivong.github.io/de4js/
  4. // @description Enable Unreadable option in de4js
  5. // @version 1.12.0
  6. // @icon https://i.imgur.com/CJ5MfxV.png
  7. // @author Zzbaivong
  8. // @license MIT
  9. // @match https://lelinhtinh.github.io/de4js/
  10. // @include http://127.0.0.1:4000/de4js/
  11. // @include http://localhost:4000/de4js/
  12. // @require https://greasemonkey.github.io/gm4-polyfill/gm4-polyfill.js?v=a834d46
  13. // @noframes
  14. // @connect jsnice.org
  15. // @supportURL https://github.com/lelinhtinh/de4js/issues
  16. // @run-at document-idle
  17. // @grant GM_xmlhttpRequest
  18. // @grant GM.xmlHttpRequest
  19. // ==/UserScript==
  20.  
  21. 'use strict';
  22.  
  23. const nicify = document.getElementById('nicify'),
  24. label = nicify.nextSibling.nextSibling.textContent,
  25. none = document.getElementById('none'),
  26. input = document.getElementById('input'),
  27. output = document.getElementById('readable'),
  28. view = document.getElementById('view');
  29.  
  30. function jsnice() {
  31. if (!isOnine()) return;
  32. const txt = view.textContent.trim() || input.value.trim();
  33. if (!txt) return;
  34.  
  35. view.classList.add('waiting');
  36. GM.xmlHttpRequest({
  37. method: 'POST',
  38. url: 'http://jsnice.org/beautify?pretty=0&rename=1&types=0&packers=0&transpile=0&suggest=0',
  39. responseType: 'json',
  40. data: txt,
  41. onload: (response) => {
  42. let source;
  43.  
  44. if (response.response && response.response.js) {
  45. source = response.response.js;
  46. }
  47.  
  48. nicify.checked = false;
  49. none.checked = true;
  50.  
  51. if (!source) {
  52. view.textContent = 'Unknown error';
  53. } else {
  54. output.value = source;
  55. output.onchange();
  56. }
  57. },
  58. onerror: (err) => {
  59. console.error(err); // eslint-disable-line no-console
  60. },
  61. });
  62. }
  63.  
  64. function isOnine() {
  65. nicify.disabled = !navigator.onLine;
  66. return navigator.onLine;
  67. }
  68.  
  69. nicify.disabled = false;
  70. nicify.nextSibling.nextSibling.textContent = label;
  71.  
  72. input.addEventListener('input', () => {
  73. if (nicify.checked) jsnice();
  74. });
  75.  
  76. nicify.addEventListener('click', () => {
  77. if (nicify.checked) jsnice();
  78. });
  79.  
  80. nicify.addEventListener('onchange', () => {
  81. if (nicify.checked) jsnice();
  82. });
  83.  
  84. window.addEventListener('online', isOnine);
  85. window.addEventListener('offline', isOnine);
  86. isOnine();

QingJ © 2025

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