...

View Full Version : Hiding CSS using Unescape



Wardy118
09-26-2008, 12:18 PM
Hi Guys,

I have a CSS file which I was hoping to hide using the unescape function. Alot of people use this on eBay which I was also hoping to do. I know how to read unescape code, i.e. revert it using Alert, but i'm not sure exactly how you go about reverting from a file/link/css to unescape code.

Any help much appreciated

mic2100
09-26-2008, 01:15 PM
check out http://www.w3schools.com/jsref/jsref_unescape.asp

Wardy118
09-26-2008, 04:08 PM
I'm finding this very difficult...

Don't really know alot about javascript coding..i'm more of a designer so i'm a bit of a coding novice!


This is some code that someone else uses to hide some of their CSS on eBay:



<script type="text/javascript">
<!--
var client = "060058";
if (window.document.getElementById('ResultSet.CSS.View'))
{
client = '3col';
}

document.write("\u003C\u0073\u0063\u0072\u0069\u0070\u0074\u0020\u006C\u0061\u006E\u0067\u0075\u0061\u0067\u0065\u00 3D\u0022\u006A\u0061\u0076\u0061\u0073\u0063\u0072\u0069\u0070\u0074\u0022\u003E\u0064\u006F\u0063\u 0075\u006D\u0065\u006E\u0074\u002E\u0077\u0072\u0069\u0074\u0065\u0020\u0028\u0022\u003C\u0073\u0074 \u0079\u006C\u0065\u0020\u0074\u0079\u0070\u0065\u003D\u0027\u0074\u0065\u0078\u0074\u002F\u0063\u00 73\u0073\u0027\u003E\u0040\u0069\u006D\u0070\u006F\u0072\u0074\u0020\u0075\u0072\u006C\u0028\u0068\u 0074\u0074\u0070\u003A\u002F\u002F\u0067\u006C\u006F\u0062\u0061\u006C\u002E\u0066\u0072\u006F\u006F \u0069\u0074\u0069\u006F\u006E\u002E\u0063\u006F\u006D\u002F\u0065\u0062\u0061\u0079\u002F\u0070\u00 68\u0070\u002F\u0030\u0036\u005F\u0073\u0068\u006F\u0070\u005F\u0063\u006F\u0075\u006E\u0074\u0065\u 0072\u002E\u0070\u0068\u0070\u003F\u0063\u006C\u0069\u0065\u006E\u0074\u0072\u0065\u0066\u003D\u0022 \u002B\u0063\u006C\u0069\u0065\u006E\u0074\u0020\u002B\u0022\u0029\u003B\u003C\u002F\u0073\u0074\u00 79\u006C\u0065\u003E\u0022\u0029\u003B\u003C\u002F\u0073\u0063\u0072\u0069\u0070\u0074\u003E\u000A");

-->

</script>

Wardy118
09-29-2008, 11:06 AM
Can anyone help??

:confused:

rnd me
09-29-2008, 02:34 PM
why would anyone want tot do that? if makes the files 6X bigger, and slower to use, and unavailable if javascript is disabled.

it's easy enough to do, but what is the point?

Wardy118
09-29-2008, 02:59 PM
why would anyone want tot do that? if makes the files 6X bigger, and slower to use, and unavailable if javascript is disabled.

it's easy enough to do, but what is the point?

Loads of people do it on eBay to stop people from stealing CSS. The CSS is really important on eBay as this is what people use when designing custom shops.

How do I go about doing it then? :confused:

rnd me
09-29-2008, 05:20 PM
Loads of people do it on eBay to stop people from stealing CSS. The CSS is really important on eBay as this is what people use when designing custom shops.

How do I go about doing it then? :confused:

that's crazy. i had no idea css was valuable. you own a legal copyright for whatever code you create, and there's no way to really stop someone from stealing css, no matter how well you hide it.

you can view the stylesheet in firebug, even kinda cut and paste it.

that being said, you probably still want to do it.

since i was bored, and i think its a cool idea, i pounded out this handy little app:


<html>
<head>
<title>dan's code disguiser</title>
</head>
<body> <h2>Enter HTML:</h2>

<input type='button' value='generate javascript equivalent' onclick="gen()" /> <br />

<textarea rows='20' cols='320' id='text1'>
<style type='text/css'>
tr { border: 1px solid black;}
tr:hover { border: 1px solid red;}
td:hover { background-color: rgb(215, 215, 255); }
</style>
</textarea>
<script type='text/javascript'>

function gen(){
function charEsc(a){ return a.charCodeAt(0); }
var t = el("text1").value.split("").map(charEsc);
el("text1").value = "document.write(String.fromCharCode("+t+"));"
}

if (!Array.prototype.map) {
Array.prototype.map = function (fun) {var len = this.length;if (typeof fun != "function") {throw new TypeError;}var res = new Array(len);var thisp = arguments[1];for (var i = 0; i < len; i++) {if (i in this) {res[i] = fun.call(thisp, this[i], i, this);}}return res;};}
function el(tid) {return document.getElementById(tid);}

</script></body></html>

example output:

document.write(String.fromCharCode(32,32,116,114,32,123,32,98,111,114,100,101,114,58,32,49,112,120,3 2,115,111,108,105,100,32,98,108,97,99,107,59,125,10,32,32,116,114,58,104,111,118,101,114,32,123,32,9 8,111,114,100,101,114,58,32,49,112,120,32,115,111,108,105,100,32,114,101,100,59,125,10,32,32,116,100 ,58,104,111,118,101,114,32,123,32,32,98,97,99,107,103,114,111,117,110,100,45,99,111,108,111,114,58,3 2,114,103,98,40,50,49,53,44,32,50,49,53,44,32,50,53,53,41,59,32,125));



the resulting data should be more compact than the sample you posted:
"\u003C" = 6 chars per char.

with mine it varies:
9,60,115 = 2,3, or 4 chars per char.

speed should be about the same.

you don't need any code other than the results of clicking the button.

enjoy and let me know if it works out for you.

Wardy118
09-29-2008, 05:48 PM
Amazing stuff!

Thank you soooooooo much Dan that works a treat.

:thumbsup:

rnd me
09-29-2008, 06:36 PM
Amazing stuff!

Thank you soooooooo much Dan that works a treat.

:thumbsup:

you are welcome.

here is a version with more format options, though i still think charCode encoding is the best...



<html>
<head>
<title>dan's code disguiser</title>
</head>
<body>
<input type='button' id='' value='charCodes' onclick="genCC()" />
<input type='button' id='' value='UTF8' onclick="genUTF()" />
<input type='button' id='' value='HEX (hack)' onclick="genHEXhack()" />
<input type='button' id='' value='HEX (valid)' onclick="genHEX()" />
<input type='button' id='' value='URL' onclick="genURL()" />
<input type='button' id='' value='escape' onclick="escape3()" />



<h2>Enter HTML:</h2>
<textarea rows='20' cols='320' id='text1' onchange="this.old=this.value;" onfocus="this.select();">
</textarea>


<script type='text/javascript'>

function start(name){
start.size = T.value.length;
document.title = "Encoding: "+ name.callee.name +" : "+ start.size +" bytes..."
setTimeout(finish, 1300);
}

function finish(){
document.title= T.value.length + " bytes, was: "+ start.size +" bytes";
}

function genCC(){ start(arguments);
function charEsc(a){ return a.charCodeAt(0); }
var t = T.value.split("").map(charEsc);
T.value = "document.write(String.fromCharCode("+t+"));"
}

function genUTF(){ start(arguments);
function charEsc(a){ return "&#"+a.charCodeAt(0)+";"; }
var t = T.value.split("").map(charEsc);
T.value = "document.write('"+t.join("")+"');"
}

function genHEX(){ start(arguments);
function charEsc(a){ return "&#x"+a.charCodeAt(0).toString(16)+";"; }
var t = T.value.split("").map(charEsc);
T.value = "document.write('"+t.join("")+"');"
}


function genURL(){ start(arguments);
function charEsc(a){ var b = a.charCodeAt(0).toString(16); return b[1] ? b : "0"+b; }
var t = T.value.split("").map(charEsc);
T.value = "document.write(unescape('&#37;"+t.join("%")+"'));"
}


function genHEXhack(){ start(arguments);
function charEsc(a){ return "&#x"+a.charCodeAt(0).toString(16); }
var t = T.value.split("").map(charEsc);
T.value = "document.write('"+t.join("")+"');"
}



function escape3(){ start(arguments);
var t = escape(T.value);
T.value = "document.write(unescape('"+t+"'));"
}


if (!Array.prototype.map) {
Array.prototype.map = function (fun) {var len = this.length;if (typeof fun != "function") {throw new TypeError;}var res = new Array(len);var thisp = arguments[1];for (var i = 0; i < len; i++) {if (i in this) {res[i] = fun.call(thisp, this[i], i, this);}}return res;};}
function el(tid) {return document.getElementById(tid);}; var T = el("text1");

</script></body></html>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum