diff --git a/_config.yml b/_config.yml index 31c127e..df15183 100644 --- a/_config.yml +++ b/_config.yml @@ -1,6 +1,6 @@ name: de4js description: JavaScript Deobfuscator and Unpacker -version: 1.3.2 +version: 1.4.0 author: Zzbaivong author_email: Zzbaivong@gmail.com url: https://lelinhtinh.github.io diff --git a/_data/options.yml b/_data/options.yml index f81c356..3fb3fd7 100644 --- a/_data/options.yml +++ b/_data/options.yml @@ -15,6 +15,6 @@ - key: p_a_c_k_e_r name: Packer - key: javascriptobfuscator - name: Javascript Obfuscator + name: JS Obfuscator - key: myobfuscate - name: My Obfuscate \ No newline at end of file + name: My Obfuscate diff --git a/_includes/highlight-js/styles/hljs-theme.css b/_includes/highlight-js/styles/hljs-theme.css new file mode 100644 index 0000000..17df0ab --- /dev/null +++ b/_includes/highlight-js/styles/hljs-theme.css @@ -0,0 +1 @@ +.hljs-comment,.hljs-quote{color:#969896}.hljs-variable,.hljs-template-variable,.hljs-tag,.hljs-name,.hljs-selector-id,.hljs-selector-class,.hljs-regexp,.hljs-deletion{color:#d54e53}.hljs-number,.hljs-built_in,.hljs-builtin-name,.hljs-literal,.hljs-type,.hljs-params,.hljs-meta,.hljs-link{color:#e78c45}.hljs-attribute{color:#e7c547}.hljs-string,.hljs-symbol,.hljs-bullet,.hljs-addition{color:#b9ca4a}.hljs-title,.hljs-section{color:#7aa6da}.hljs-keyword,.hljs-selector-tag{color:#c397d8}.hljs{display:block;overflow-x:auto;background:black;color:#eaeaea;padding:.5em}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:bold} \ No newline at end of file diff --git a/_includes/highlight-js/styles/tomorrow-night-bright.css b/_includes/highlight-js/styles/tomorrow-night-bright.css deleted file mode 100644 index e05af8a..0000000 --- a/_includes/highlight-js/styles/tomorrow-night-bright.css +++ /dev/null @@ -1,74 +0,0 @@ -/* Tomorrow Night Bright Theme */ -/* Original theme - https://github.com/chriskempson/tomorrow-theme */ -/* http://jmblog.github.com/color-themes-for-google-code-highlightjs */ - -/* Tomorrow Comment */ -.hljs-comment, -.hljs-quote { - color: #969896; -} - -/* Tomorrow Red */ -.hljs-variable, -.hljs-template-variable, -.hljs-tag, -.hljs-name, -.hljs-selector-id, -.hljs-selector-class, -.hljs-regexp, -.hljs-deletion { - color: #d54e53; -} - -/* Tomorrow Orange */ -.hljs-number, -.hljs-built_in, -.hljs-builtin-name, -.hljs-literal, -.hljs-type, -.hljs-params, -.hljs-meta, -.hljs-link { - color: #e78c45; -} - -/* Tomorrow Yellow */ -.hljs-attribute { - color: #e7c547; -} - -/* Tomorrow Green */ -.hljs-string, -.hljs-symbol, -.hljs-bullet, -.hljs-addition { - color: #b9ca4a; -} - -/* Tomorrow Blue */ -.hljs-title, -.hljs-section { - color: #7aa6da; -} - -/* Tomorrow Purple */ -.hljs-keyword, -.hljs-selector-tag { - color: #c397d8; -} - -.hljs { - display: block; - overflow-x: auto; - background: black; - color: #eaeaea; - padding: 0.5em; -} - -.hljs-emphasis { - font-style: italic; -} - -.hljs-strong { - font-weight: bold; -} diff --git a/_layouts/default.html b/_layouts/default.html index 67aa71d..1860734 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -1,5 +1,5 @@ - +
@@ -44,7 +44,6 @@' + source + ''; + source = '
' + source + ''; externalUrl = new Blob([source], { type: 'text/html' @@ -98,9 +115,7 @@ workerDecode, format = debounce(function () { - var source = output.value.trim(); - - if (source === '') return; + if (temp === '') return; if (!workerFormat) { workerFormat = new Worker('{{ "/assets/js/worker/format.js" | relative_url }}'); @@ -114,8 +129,7 @@ startEffect(); workerFormat.postMessage({ - source: source, - beautify: beautify.checked + source: temp }); }, 250), @@ -146,15 +160,13 @@ }, decode = debounce(function () { - var source = input.value.trim(), - packer = document.bvDecode.encode.value; + if (temp === '') temp = input.value.trim(); + if (temp === '') return; - if (source === '') return; - if (auto.checked) packer = detect(source); + packer = isAuto ? detect(temp) : document.bvDecode.encode.value; if (packer === 'nicify') return; if (packer === '') { - output.value = source; format(); return; } @@ -162,61 +174,59 @@ if (!workerDecode) { workerDecode = new Worker('{{ "/assets/js/worker/decode.js" | relative_url }}'); workerDecode.addEventListener('message', function (e) { - output.value = e.data; + if (e.data !== temp) { + temp = e.data; - if (auto.checked && input.value !== output.value) { - redecode.onclick(); - } else { - format(); + if (isAuto) { + decode(); + return; + } } + + format(); }); } startEffect(); - output.value = ''; workerDecode.postMessage({ - source: source, + source: temp, packer: packer }); }, 250); - input.oninput = debounce(function () { + input.oninput = function () { + temp = input.value.trim(); decode(); - }); - for (var i = 0; i < encode.length; i++) { - encode[i].onchange = decode; } - beautify.onchange = format; + for (var i = 0; i < encode.length; i++) { + encode[i].onchange = function () { + decode(); + }; + } - auto.onchange = function () { - for (var i = 0; i < encode.length; i++) { - if (encode[i].value === 'nicify') continue; - encode[i].disabled = auto.checked; - } + autoBtn.onclick = function () { + isAuto = true; decode(); }; clipboard.on('success', function (e) { e.trigger.classList.add('copied'); e.clearSelection(); - timereset(e.trigger); + timeReset(e.trigger); }); clipboard.on('error', function (e) { e.trigger.classList.add('selected'); - timereset(e.trigger); + timeReset(e.trigger); }); - redecode.onclick = function () { - input.value = output.value; - decode(); - }; - clear.onclick = function () { - view.textContent = 'Please choose a right encoding type!'; + view.textContent = ''; + stopEffect(); - setTimeout(function() { - auto.onchange(); + setTimeout(function () { + input.value = ''; + temp = ''; }, 0); if (workerDecode) { @@ -231,7 +241,7 @@ preview.classList.remove('show'); }; - window.addEventListener('online', updateOnlineStatus); + window.addEventListener('online', updateOnlineStatus); window.addEventListener('offline', updateOnlineStatus); updateOnlineStatus(); diff --git a/assets/js/worker/format.js b/assets/js/worker/format.js index 2eccacd..ecf316a 100644 --- a/assets/js/worker/format.js +++ b/assets/js/worker/format.js @@ -12,19 +12,18 @@ self.addEventListener('message', function (e) { var source = e.data.source; - if (e.data.beautify) { - self._window = self.window; - self.window = {}; + self._window = self.window; + self.window = {}; - self.importScripts('{{ "/assets/js/lib/js-beautify/beautify.min.js" | relative_url }}'); + self.importScripts('{{ "/assets/js/lib/js-beautify/beautify.min.js" | relative_url }}'); - source = self.window.js_beautify(source, { - unescape_strings: true, - jslint_happy: true - }); + source = self.window.js_beautify(source, { + unescape_strings: true, + jslint_happy: true + }); + + self.window = self._window; - self.window = self._window; - } self.importScripts('{{ "/assets/js/lib/highlight-js/highlight.min.js" | relative_url }}'); diff --git a/package.json b/package.json index 52a5b0b..bcf7066 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,11 @@ { "name": "de4js", - "version": "1.3.2", + "version": "1.4.0", "description": "JavaScript Deobfuscator and Unpacker", "main": "/assets/js/main.js", "scripts": { + "start": "bundle exec jekyll serve --watch", + "build": "bundle exec jekyll build", "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { diff --git a/userscript/de4js_helper.user.js b/userscript/de4js_helper.user.js index 541641e..1be65a4 100644 --- a/userscript/de4js_helper.user.js +++ b/userscript/de4js_helper.user.js @@ -24,29 +24,35 @@ 'use strict'; var nicify = document.getElementById('nicify'), + none = document.getElementById('none'), input = document.getElementById('input'), - output = document.getElementById('output'), - view = document.getElementById('view'), - redecode = document.getElementById('redecode'); + view = document.getElementById('view'); function jsnice() { if (!isOnine()) return; - if (input.value.trim() === '') return; + var txt = view.textContent.trim() || input.value.trim(); + if (!txt) return; view.classList.add('waiting'); GM.xmlHttpRequest({ method: 'POST', url: 'http://jsnice.org/beautify?pretty=0&rename=1&types=0&packers=0&transpile=0&suggest=0', responseType: 'json', - data: input.value, + data: txt, onload: function (response) { - var source = input.value; + var source; - if (response.response && response.response.js && response.response.js.indexOf('// Error compiling input') !== 0) + if ( + response.response && response.response.js && + response.response.js.indexOf('// Error compiling input') !== 0 + ) source = response.response.js; - output.value = source; - document.getElementById('beautify').onchange(); + nicify.checked = false; + none.checked = true; + + input.value = source; + input.oninput(); }, onerror: function (e) { console.error(e); // eslint-disable-line no-console @@ -60,13 +66,16 @@ } nicify.disabled = false; - nicify.onchange = jsnice; input.addEventListener('input', function () { if (nicify.checked) jsnice(); }); - redecode.addEventListener('click', function () { + nicify.addEventListener('click', function () { + if (nicify.checked) jsnice(); + }); + + nicify.addEventListener('onchange', function () { if (nicify.checked) jsnice(); });