UNPKG

jscrewit

Version:

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

1 lines 14.1 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 l(e){e.removeAttribute("tabindex")}function N(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=F[e];F(document,e("mousemove",n),e("mouseout",o))}var c=F("SPAN",{className:"button focusable",get disabled(){return r()},set disabled(e){(e=!!e)!==r()&&(e?(F(c,l),i()&&(document.releaseCapture(),a("off")),c.blur()):F(c,N),c.className="",c.className="button focusable")}},N,F.on("click",function(e){r()&&e.stopImmediatePropagation(),e.preventDefault()}),F.on("keydown",function(e){13===e.keyCode&&(c.click(),e.preventDefault())}),F.on("keyup",function(e){32===e.keyCode&&(c.click(),e.preventDefault())}),F.on("mouseup",function(e){0===e.button&&i()&&(document.releaseCapture(),t())}),F("SPAN",e),F("SPAN"));return c.setCapture&&(c.firstChild.setAttribute("unselectable","on"),F(c,F.on("mousedown",function(e){0!==e.button||r()||i()||(c.setCapture(),c.className="active button focusable",a("on"))}))),c}function T(e,t){function n(){var e=document.body;e.removeChild(c),F(e,F.off("keydown",r),F.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=F("DIV",{style:{borderRadius:"25px",display:"inline-block",maxWidth:"500px",width:"100%"}},N,F("DIV",{className:"focusable",id:"modalBox",style:{background:"whitesmoke",border:"10px solid blue",borderRadius:"23px",margin:"2px"}},F("DIV",{style:{margin:"1.5em 1.5em .25em",overflow:"hidden"}},e,F("DIV",{style:{margin:"1.25em 0"}},F(E("OK"),{style:{maxWidth:"5em",width:"100%"}},F.on("click",n)))))),c=F("DIV",{style:{background:"rgba(0, 0, 0, .25)",overflow:"auto",position:"fixed",textAlign:"center",left:"0",top:"0",bottom:"0",width:"100%"}},F("DIV",{style:{display:"table",tableLayout:"fixed",width:"100%",height:"100%"}},F("DIV",{style:{display:"table-cell",verticalAlign:"middle"}},a)));F(document.body,c,F.on("focus",i,!0),F.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"):String(e)}catch(e){}return t}function t(){(O=new Worker(y)).onmessage=x}function n(){URL.revokeObjectURL(y),y=void 0}function D(){var e,t=r();try{e=JScrewIt.encode(inputArea.value,t)}catch(e){return u(),void d(String(e))}p(e)}function L(){var e=r(),e={input:inputArea.value,options:e};v&&(O.terminate(),t(),e.url=m),O.postMessage(e),u(),s(!0),inputArea.onkeyup=null}function r(){return{features:C.canonicalNames}}function k(e){9!==e.keyCode&&L()}function q(e){var t;P(e)&&(e=outputArea.value.length,0===outputArea.selectionStart&&outputArea.selectionEnd===e||(outputArea.selectionStart=0,outputArea.selectionEnd=e,"scrollTopMax"in outputArea&&(t=outputArea.scrollTop,F(outputArea,F.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 z(){var e,t,n,o;try{t=(0,eval)(outputArea.value)}catch(e){n=F("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?F("DIV",F("P",t?"Evaluation result is "+t+":":"Evaluation result is"),F("P",{style:{overflowX:"auto"}},F("DIV",{style:{display:"inline-block",textAlign:"left",whiteSpace:"pre"}},e))):F("DIV",F("P","Evaluation result is "+t+"."))),null!=n&&(o=this,T(n,function(){o.focus()}))}function x(e){var e=e.data,t=e.error;t?d(t):p(e.output),s(!1)}function P(e){var t=2<=e.detail&&0===e.button;return t&&e.preventDefault(),t}function e(){function n(){var e=+new Date;0<=((d=l+(e-u)*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,F(outputArea,F.on("mousedown",q),F.on("mouseup",P),F.on("input",M)),F(stats.parentNode,F(E("Run this"),{style:{bottom:"0",fontSize:"10pt",position:"absolute",right:"0"}},F.on("click",z))),e=J.COMPACT,C=J.AUTO.includes(e)?e:J.BROWSER,compMenu.value=C.name,compMenu.previousIndex=compMenu.selectedIndex,O?(h=L)():(e=F(E("Encode"),F.on("click",D)),F(controls,e),h=H,outputArea.value=""),"undefined"!=typeof File&&(e=F("INPUT",{accept:".js",style:{display:"none"},type:"file"},F.on("change",B)),k=HTMLElement.prototype.click.bind(e),j=F(E("Load file…"),F.on("click",k)),F(controls,j,e)),inputArea.oninput=h;var t,i,r,a,c,l,u,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?J[t]:R.feature;!V&&J.areEqual(n,C)||(C=n,this()),e!==compMenu.previousIndex&&(compMenu.previousIndex=e,U.rollTo(+!t))}.bind(h);function w(e,t){return F("LABEL",{style:{display:"inline-table"}},F("SPAN",{style:{display:"table-cell",verticalAlign:"middle"}},F("INPUT",{style:{margin:"0 .25em 0 0"},type:"checkbox"},t)),F("SPAN",{style:{display:"table-cell"}},e))}function x(e){var t=F("DIV",{className:"help-text"});return t.innerHTML=e,F("SPAN",{className:"focusable",style:{background:"black",borderRadius:"1em",color:"white",cursor:"pointer",display:"inline-block",fontSize:"8pt",fontWeight:"bold",lineHeight:"10.5pt",position:"relative",textAlign:"center",top:"-1.5pt",width:"10.5pt"},title:"Learn more…"},"?",N,F.on("click",function(){T(t)}))}function S(){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))}F(compMenu,F.on("change",k)),R=F((e=F(w("Select/deselect all"),{style:{margin:"0 0 .5em"}},F.on("change",S),F.on(["keyup","mouseup"],function(){setTimeout(function(){p.indeterminate||S()})})),y=F("TABLE",{style:{borderSpacing:"0",width:"100%"}}),h=w("Generate strict mode code"),g=w("Support web workers"),A=F("FIELDSET",{className:"engine-selection-box",get feature(){return f}},F("DIV",F("P",{style:{margin:".25em 0 .75em"}},"Select the engines you want your code to support."),e,y,F("HR"),F("DIV",g," ",x("<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.")),F("DIV",h," ",x('<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.')),F.on("change",function(){var e;I(),(e=document.createEvent("Event")).initEvent("input",!0,!1),A.dispatchEvent(e)}))),["Chrome","Edge","Firefox","Internet Explorer","Safari","Opera","Node.js"].forEach(function(e,t){for(var n,o,i=JScrewIt.Feature.FAMILIES[e],r=1&t?{className:"even-field"}:null,a=(i.length+2)/3^0,c=3*a,l=0;l<c;++l){var u,s,d=i[l],p=(l%3||(n=F("TR",r),l||F(n,F("TD",{rowSpan:a,style:{padding:"0 .5em 0 0"}},e)),F(y,n)),null);d&&(u=d.versions.map(function(e){var t;return"string"==typeof e?e:(t=e.from,null==(e=e.to)?t+"+":t+"–"+e)}).join(", "),p=w(null==(s=d.shortTag)?u:F("SPAN",u," (",(u=void 0,"W"!==(s=s)[0]?s:(o="http://www.w3.org/2000/svg",(u=document.createElementNS(o,"svg")).setAttribute("class","windows-logo-icon"),u.setAttribute("viewBox","0 0 88 88"),u.appendChild(document.createElementNS(o,"path")).setAttribute("d","M0 12.402l35.687-4.86.016 34.423-35.67.203zm35.67 33.529l.028 34.453L.028 75.48.026 45.7zm4.326-39.025L87.314 0v41.527l-47.318.376zm47.329 39.349l-.011 41.34-47.318-6.678-.066-34.739z"),F("SPAN",u,s.slice(1)))),")"),{checked:!0,featureName:d.featureName})),F(n,F("TD",{style:{padding:"0 0 0 .5em",width:"6em"}},p))}}),p=e.querySelector("INPUT"),m=y.querySelectorAll("INPUT"),b=h.querySelector("INPUT"),v=g.querySelector("INPUT"),I(),A),F.on("input",k)),d=s=0,e=F("DIV"),(r=e.style).display="none",t=F("DIV",e,{container:e,rollTo:function(e){var t;e===d?o():((t=d<e?1:-1)!==s&&(l=d,u=+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"))?(F(k,{open:!0},F("SUMMARY",{dir:"rtl"},F("SPAN",{style:{float:"left"}},g))),F.css("details.frame:not([open])>:first-child",{"margin-bottom":"initial"})):k=F("DIV",F("SPAN",g)),F(U.container,F(k,{className:"frame"},R)),F(controls.parentNode,U),inputArea.selectionStart=2147483647,inputArea.focus()}function c(){document.addEventListener("DOMContentLoaded",e)}function B(){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 H(){b&&M(!0)}function u(){b=!1,outputArea.value="",stats.textContent="…"}function s(e){v=e,outputArea.disabled=e}function d(e){T(F("P",e))}function p(e){outputArea.value=e,M()}function M(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,F=function(e){for(var t=e instanceof Node?e:"function"==typeof e?e.call(F):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(F,t):null!=i&&(i=document.createTextNode(i),t.appendChild(i))}return t},A=(F.off=function(e,t,n){return o(e,t,n,"removeEventListener")},F.on=function(e,t,n){return o(e,t,n,"addEventListener")},F.css=function(e,t){var n=t,t=e+"{"+g.keys(n).map(function(e){return e+":"+n[e]}).join(";")+"}";f||(e=F("STYLE"),F(document.head,e),f=e.sheet),f.insertRule(t,f.cssRules.length)},F.css(".button",{background:"#e0e0e0",color:"#212121",cursor:"default",display:"inline-block",position:"relative"}),F.css(".button, .button>:last-child",{"border-radius":".1em"}),F.css(".button.active, .button[tabindex]:active",{background:"#29b3e5"}),F.css(".button.active>:first-child, .button[tabindex]:active>:first-child",{left:".1em",top:".1em"}),F.css(".button.active>:last-child, .button[tabindex]:active>:last-child",{"border-color":"#0088b6"}),F.css(".button:not([tabindex])",{background:"#e9e9e9",color:"#707070"}),F.css(".button:not([tabindex])>:last-child",{"border-color":"#bababa"}),F.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"}),F.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"}),F.css(".button[tabindex]:hover:not(.active):not(:active)",{background:"#a3f4ff"}),F.css(".button[tabindex]:hover:not(.active):not(:active)>:last-child",{"border-color":"#189fdd"}),F.css("#modalBox p:first-child",{"margin-top":"0"}),F.css("#modalBox p:last-child",{"margin-bottom":"0"}),F.css(".engine-selection-box",{background:"#f0f0f0"}),F.css(".engine-selection-box .even-field",{background:"#fff"}),F.css(".help-text",{"font-size":"11pt","text-align":"justify"}),F.css(".help-text code",{"white-space":"pre"}),F.css(".help-text dfn",{"font-style":"normal","font-weight":"bold"}),F.css(".help-text li",{margin:".5em 0"}),F.css(".windows-logo-icon",{display:"inline-block",height:".8em",margin:"0 .05em","vertical-align":"-.1em",width:".8em"}),"application/javascript"),J=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()}();