UNPKG

jscrewit

Version:

Converts plain JavaScript into JSFuck code, which consists of only six different characters: ! ( ) + [ ]

1 lines 13.7 kB
!function(){function a(e){var t=typeof e;return"object"==t&&null!==e||"undefined"==t&&void 0!==e}function o(n,o,i,r){return function(t){function e(e){t[r](e,o,i)}Array.isArray(n)?n.forEach(e):e(n)}}function u(e){e.removeAttribute("tabindex")}function T(e){e.setAttribute("tabindex",0)}function E(e){function t(){c.className="button focusable",a("off")}function n(e){e.target!==c&&i()&&t()}function o(e){!e.relatedTarget&&i()&&t()}function i(){return/\bactive\b/.test(c.className)}function r(){return!c.hasAttribute("tabindex")}function a(e){e=B[e];B(document,e("mousemove",n),e("mouseout",o))}var c=B("SPAN",{className:"button focusable",get disabled(){return r()},set disabled(e){(e=!!e)!==r()&&(e?(B(c,u),i()&&(document.releaseCapture(),a("off")),c.blur()):B(c,T),c.className="",c.className="button focusable")}},T,B.on("click",function(e){r()&&e.stopImmediatePropagation(),e.preventDefault()}),B.on("keydown",function(e){13===e.keyCode&&(c.click(),e.preventDefault())}),B.on("keyup",function(e){32===e.keyCode&&(c.click(),e.preventDefault())}),B.on("mouseup",function(e){0===e.button&&i()&&(document.releaseCapture(),t())}),B("SPAN",e),B("SPAN"));return c.setCapture&&(c.firstChild.setAttribute("unselectable","on"),B(c,B.on("mousedown",function(e){0!==e.button||r()||i()||(c.setCapture(),c.className="active button focusable",a("on"))}))),c}function N(e,t){function n(){var e=document.body;e.removeChild(c),B(e,B.off("keydown",r),B.off("focus",i,!0)),void 0!==t&&t()}function o(){a.focus()}function i(e){a.contains(e.target)||o()}function r(e){var t=e.keyCode;13!==t&&27!==t||!(t=document.activeElement).contains(a)&&t.contains(e.target)||(n(),e.preventDefault())}var a=B("DIV",{style:{borderRadius:"25px",display:"inline-block",maxWidth:"500px",width:"100%"}},T,B("DIV",{className:"focusable",id:"modalBox",style:{background:"whitesmoke",border:"10px solid blue",borderRadius:"23px",margin:"2px"}},B("DIV",{style:{margin:"1.5em 1.5em .25em",overflow:"hidden"}},e,B("DIV",{style:{margin:"1.25em 0"}},B(E("OK"),{style:{maxWidth:"5em",width:"100%"}},B.on("click",n)))))),c=B("DIV",{style:{background:"rgba(0, 0, 0, .25)",overflow:"auto",position:"fixed",textAlign:"center",left:"0",top:"0",bottom:"0",width:"100%"}},B("DIV",{style:{display:"table",tableLayout:"fixed",width:"100%",height:"100%"}},B("DIV",{style:{display:"table-cell",verticalAlign:"middle"}},a)));B(document.body,c,B.on("focus",i,!0),B.on("keydown",r)),setTimeout(o)}function i(e){var t,n=typeof e;try{t="string"==n?'"'.concat(e,'"'):0===e&&1/e<0?"-0":Array.isArray(e)?e.length?"[…]":"[]":"bigint"==n?"".concat(e,"n"):"symbol"!=n?String(e):e.toString()}catch(e){}return t}function t(){(O=new Worker(y)).onmessage=S}function n(){URL.revokeObjectURL(y),y=void 0}function D(){var e,t=r();try{e=JScrewIt.encode(inputArea.value,t)}catch(e){return l(),void d(String(e))}p(e)}function M(){var e=r(),e={input:inputArea.value,options:e};v&&(O.terminate(),t(),e.url=m),O.postMessage(e),l(),s(!0),inputArea.onkeyup=null}function r(){return{features:C.canonicalNames}}function k(e){9!==e.keyCode&&M()}function J(e){var t;L(e)&&(e=outputArea.value.length,0===outputArea.selectionStart&&outputArea.selectionEnd===e||(outputArea.selectionStart=0,outputArea.selectionEnd=e,"scrollTopMax"in outputArea&&(t=outputArea.scrollTop,B(outputArea,B.on("scroll",function(){outputArea.scrollTop=t},{once:!0})))))}function w(){j.disabled=!1;var e=this.result;null!=e&&(inputArea.value=e),inputArea.oninput(),inputArea.disabled=!1}function q(){var e,t,n,o;try{t=(0,eval)(outputArea.value)}catch(e){n=B("P",String(e))}void 0!==t&&(e=function(e){var t;if(Array.isArray(e))try{t="[".concat(e.map(i).join(", "),"]")}catch(e){}else t=i(e);return t}(t),t=function(e){var t;if(null!==e){var n=typeof e;if("function"==n||"object"==n||"undefined"==n){var o=Object.getPrototypeOf(e);if(o===Array.prototype)switch(e.length){case 0:t="an empty array";break;case 1:t="a one element array";break;default:t="an array"}else t=o===Date.prototype?"a date":o===RegExp.prototype?"a regular expression":"function"==n?"a function":"an object"}}return t}(t),n=e?B("DIV",B("P",t?"Evaluation result is "+t+":":"Evaluation result is"),B("P",{style:{overflowX:"auto"}},B("DIV",{style:{display:"inline-block",textAlign:"left",whiteSpace:"pre"}},e))):B("DIV",B("P","Evaluation result is "+t+"."))),null!=n&&(o=this,N(n,function(){o.focus()}))}function S(e){var e=e.data,t=e.error;t?d(t):p(e.output),s(!1)}function L(e){var t,n=e.target;return(n="runtimeStyle"in n?(t=n.lastMainMouseButtonEventTimeStamp,(n.lastMainMouseButtonEventTimeStamp=0===e.button?e.timeStamp:void 0)-t<=500):2<=e.detail&&0===e.button)&&e.preventDefault(),n}function e(){function n(){var e=+new Date;0<=((d=u+(e-l)*s/250)-a)*s&&(d=a,o()),i.height=1===d?"":t.scrollHeight*d+"px",r.display=0===d?"none":""}function o(){clearInterval(c),c=null,s=0}document.querySelector("main>div").style.display="block",inputArea.value=inputArea.defaultValue,B(outputArea,B.on("mousedown",J),B.on("mouseup",L),B.on("input",P)),B(stats.parentNode,B(E("Run this"),{style:{bottom:"0",fontSize:"10pt",position:"absolute",right:"0"}},B.on("click",q))),e=F.COMPACT,C=F.AUTO.includes(e)?e:F.BROWSER,compMenu.value=C.name,compMenu.previousIndex=compMenu.selectedIndex,O?(h=M)():(e=B(E("Encode"),B.on("click",D)),B(controls,e),h=W,outputArea.value=""),"undefined"!=typeof File&&(e=B("INPUT",{accept:".js",style:{display:"none"},type:"file"},B.on("change",H)),k=HTMLInputElement.prototype.click.bind(e),j=B(E("Load file…"),B.on("click",k)),B(controls,j,e)),inputArea.oninput=h;var t,i,r,a,c,u,l,s,d,p,f,m,b,v,e,y,h,g,A,k=function(){var e=compMenu.selectedIndex,t=compMenu.options[e].value,n=t?F[t]:R.feature;!V&&F.areEqual(n,C)||(C=n,this()),e!==compMenu.previousIndex&&(compMenu.previousIndex=e,U.rollTo(+!t))}.bind(h);function w(e,t){return B("LABEL",{style:{display:"inline-table"}},B("SPAN",{style:{display:"table-cell",verticalAlign:"middle"}},B("INPUT",{style:{margin:"0 .25em 0 0"},type:"checkbox"},t)),B("SPAN",{style:{display:"table-cell"}},e))}function S(e){var t=B("DIV",{className:"help-text"});return t.innerHTML=e,B("SPAN",{className:"focusable",style:{background:"black",borderRadius:"1em",color:"white",cursor:"pointer",display:"inline-table",fontSize:"8pt",fontWeight:"bold",lineHeight:"10.5pt",position:"relative",textAlign:"center",top:"-1.5pt",width:"10.5pt"},title:"Learn more…"},"?",T,B.on("click",function(){N(t)}))}function x(){var t=p.checked;Array.prototype.forEach.call(m,function(e){e.checked=t})}function I(){var t=JScrewIt.Feature,e=Array.prototype.filter.call(m,function(e){return e.checked}).map(function(e){return++n,t[e.featureName]}),n=e.length;p.checked=n,p.indeterminate=n&&n<m.length,f=t.commonOf.apply(null,e)||t.DEFAULT,v.checked&&(f=f.restrict("web-worker",e)),b.checked&&(f=f.restrict("forced-strict-mode",e))}B(compMenu,B.on("change",k)),R=B((e=B(w("Select/deselect all"),{style:{margin:"0 0 .5em"}},B.on("change",x),B.on(["keyup","mouseup"],function(){setTimeout(function(){p.indeterminate||x()})})),y=B("TABLE",{style:{borderSpacing:"0",width:"100%"}}),h=w("Generate strict mode code"),g=w("Support web workers"),A=B("FIELDSET",{className:"engine-selection-box",get feature(){return f}},B("DIV",B("P",{style:{margin:".25em 0 .75em"}},"Select the engines you want your code to support."),e,y,B("HR"),B("DIV",g," ",S("<p>Web workers are part of a standard HTML technology used to perform background tasks in JavaScript.<p>Check the option <dfn>Support web workers</dfn> only if your code needs to run inside a web worker. To create or use a web worker in your code, this option is not required.")),B("DIV",h," ",S('<p>The option <dfn>Generate strict mode code</dfn> instructs JScrewIt to avoid optimizations that don\'t work in strict mode JavaScript code. Check this option only if your environment disallows non-strict code. You may want to do this for example in one of the following circumstances.<ul><li>To encode a string or a number and embed it in a JavaScript file in a place where strict mode code is expected, like in a scope containing a <code>"use strict"</code> statement or in a class body.<li>To encode a script and run it in Node.js with the option <code>--use_strict</code>.<li>To encode an ECMAScript module. Note that module support in JSFuck is <em>very</em> limited, as <code>import</code> and <code>export</code> statements don\'t work at all. If your module doesn\'t contain these statements, you can encode it using this option.</ul><p>In most other cases, this option is not required, not even to encode a script that contains a top level <code>"use strict"</code> statement.')),B.on("change",function(){var e;I(),(e=document.createEvent("Event")).initEvent("input",!0,!1),A.dispatchEvent(e)}))),["Chrome","Edge","Firefox","Internet Explorer","Safari","Opera","Android Browser","Node.js"].forEach(function(e,t){for(var n,o=JScrewIt.Feature.FAMILIES[e],i=1&t?{className:"even-field"}:null,r=(o.length+2)/3^0,a=3*r,c=0;c<a;++c){var u,l,s=o[c],d=(c%3||(n=B("TR",i),c||B(n,B("TD",{rowSpan:r,style:{padding:"0 .5em 0 0"}},e)),B(y,n)),null);s&&(u=s.versions.map(function(e){var t;return"string"==typeof e?e:(t=e.from,null==(e=e.to)?t+"+":t+"–"+e)}).join(", "),null!=(l=s.shortTag)&&(u+=" ("+l+")"),d=w(u,{checked:!0,featureName:s.featureName})),B(n,B("TD",{style:{padding:"0 0 0 .5em",width:"6em"}},d))}}),p=e.querySelector("INPUT"),m=y.querySelectorAll("INPUT"),b=h.querySelector("INPUT"),v=g.querySelector("INPUT"),I(),A),B.on("input",k)),d=s=0,e=B("DIV"),(r=e.style).display="none",t=B("DIV",e,{container:e,rollTo:function(e){var t;e===d?o():((t=d<e?1:-1)!==s&&(u=d,l=+new Date,s=t),a=e,c=c||setInterval(n,0))}}),(i=t.style).height="0",i.overflowY="hidden",U=t,g="Custom Compatibility Selection","open"in(k=document.createElement("DETAILS"))?(B(k,{open:!0},B("SUMMARY",{dir:"rtl"},B("SPAN",{style:{float:"left"}},g))),B.css("details.frame:not([open])>:first-child",{"margin-bottom":"initial"})):k=B("DIV",B("SPAN",g)),B(U.container,B(k,{className:"frame"},R)),B(controls.parentNode,U),inputArea.selectionStart=2147483647,inputArea.focus()}function c(){document.addEventListener("DOMContentLoaded",e)}function H(){var e,t=this.files[0];t&&(inputArea.disabled=!0,inputArea.value="",j.disabled=!0,(e=new FileReader).addEventListener("loadend",w),e.readAsText(t))}function W(){b&&P(!0)}function l(){b=!1,outputArea.value="",stats.textContent="…"}function s(e){v=e,outputArea.disabled=e}function d(e){N(B("P",e))}function p(e){outputArea.value=e,P()}function P(e){var t=outputArea.value.length,t=1===t?"1 char":t+" chars";V=!!e,e&&(O&&(inputArea.onkeyup=k),t+=" – <i>out of sync</i>"),b=!0,stats.innerHTML=t}var f,C,R,m,j,V,b,U,v,O,y,h,g=Object,B=function(e){for(var t=e instanceof Node?e:"function"==typeof e?e.call(B):document.createElement(e),n=arguments.length,o=0;++o<n;){var i=arguments[o];i instanceof Node?t.appendChild(i):a(i)?function o(i,r){g.keys(r).forEach(function(e){var t,n=g.getOwnPropertyDescriptor(r,e);"value"in n?(t=n.value,e in i&&a(t)?o(i[e],t):i[e]=t):g.defineProperty(i,e,n)})}(t,i):"function"==typeof i?i.call(B,t):null!=i&&(i=document.createTextNode(i),t.appendChild(i))}return t},A=(B.off=function(e,t,n){return o(e,t,n,"removeEventListener")},B.on=function(e,t,n){return o(e,t,n,"addEventListener")},B.css=function(e,t){var n=t,t=e+"{"+g.keys(n).map(function(e){return e+":"+n[e]}).join(";")+"}";f||(e=B("STYLE"),B(document.head,e),f=e.sheet),f.insertRule(t,f.cssRules.length)},B.css(".button",{background:"#e0e0e0",color:"#212121",cursor:"default",display:"inline-block",position:"relative"}),B.css(".button, .button>:last-child",{"border-radius":".1em"}),B.css(".button.active, .button[tabindex]:active",{background:"#29b3e5"}),B.css(".button.active>:first-child, .button[tabindex]:active>:first-child",{left:".1em",top:".1em"}),B.css(".button.active>:last-child, .button[tabindex]:active>:last-child",{"border-color":"#0088b6"}),B.css(".button:not([tabindex])",{background:"#e9e9e9",color:"#707070"}),B.css(".button:not([tabindex])>:last-child",{"border-color":"#bababa"}),B.css(".button>:first-child",{display:"inline-block",margin:".15em .5em",position:"relative","user-select":"none","-moz-user-select":"none","-ms-user-select":"none","-webkit-user-select":"none"}),B.css(".button>:last-child",{"border-color":"#707070","border-style":"solid","border-width":"1px",display:"inline-block",position:"absolute",left:"0",right:"0",top:"0",bottom:"0"}),B.css(".button[tabindex]:hover:not(.active):not(:active)",{background:"#a3f4ff"}),B.css(".button[tabindex]:hover:not(.active):not(:active)>:last-child",{"border-color":"#189fdd"}),B.css("#modalBox p:first-child",{"margin-top":"0"}),B.css("#modalBox p:last-child",{"margin-bottom":"0"}),B.css(".engine-selection-box",{background:"#f0f0f0"}),B.css(".engine-selection-box .even-field",{background:"#fff"}),B.css(".help-text",{"font-size":"11pt","text-align":"justify"}),B.css(".help-text code",{"white-space":"pre"}),B.css(".help-text dfn",{"font-style":"normal","font-weight":"bold"}),B.css(".help-text li",{margin:".5em 0"}),"application/javascript"),F=JScrewIt.Feature;try{(h=new XMLHttpRequest).open("GET","lib/jscrewit.min.js",!0)}catch(e){h=void 0}if(h&&"undefined"!=typeof Worker){y=URL.createObjectURL(new Blob(["self.onmessage=function(t){var t=t.data,r=t.url,r=(null!=r&&importScripts(r),t.input);if(null!=r){try{e={output:JScrewIt.encode(r,t.options)}}catch(t){var e={error:String(t)}}postMessage(e)}};"],{type:A}));try{t()}catch(e){n()}}O?(h.onerror=function(){O.terminate(),O=void 0,n()},h.onload=function(){h.status<400?(m=URL.createObjectURL(h.response),O.postMessage({url:m})):this.onerror()},h.onloadend=function(){("loading"===document.readyState?c:e)()},h.overrideMimeType(A),h.responseType="blob",h.send()):c()}();