Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New Coder
    Join Date
    Jul 2006
    Posts
    81
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Hiding CSS using Unescape

    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

  • #2
    Regular Coder mic2100's Avatar
    Join Date
    Feb 2006
    Location
    Scunthorpe
    Posts
    562
    Thanks
    15
    Thanked 28 Times in 27 Posts

  • #3
    New Coder
    Join Date
    Jul 2006
    Posts
    81
    Thanks
    4
    Thanked 0 Times in 0 Posts
    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:

    Code:
    <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\u003D\u0022\u006A\u0061\u0076\u0061\u0073\u0063\u0072\u0069\u0070\u0074\u0022\u003E\u0064\u006F\u0063\u0075\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\u0073\u0073\u0027\u003E\u0040\u0069\u006D\u0070\u006F\u0072\u0074\u0020\u0075\u0072\u006C\u0028\u0068\u0074\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\u0068\u0070\u002F\u0030\u0036\u005F\u0073\u0068\u006F\u0070\u005F\u0063\u006F\u0075\u006E\u0074\u0065\u0072\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\u0079\u006C\u0065\u003E\u0022\u0029\u003B\u003C\u002F\u0073\u0063\u0072\u0069\u0070\u0074\u003E\u000A");
    
    -->
    
    </script>

  • #4
    New Coder
    Join Date
    Jul 2006
    Posts
    81
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Can anyone help??


  • #5
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,373
    Thanks
    11
    Thanked 592 Times in 572 Posts
    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?
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/9/03) IE7:0.1, IE8:4.6, IE11:9.1, IE9:3.1, IE10:3.0, FF:17.2, CH:46, SF:11.4, NON-MOUSE:38%

  • #6
    New Coder
    Join Date
    Jul 2006
    Posts
    81
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by rnd me View Post
    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?

  • #7
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,373
    Thanks
    11
    Thanked 592 Times in 572 Posts
    Quote Originally Posted by Wardy118 View Post
    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?
    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:
    Code:
    <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:
    Code:
    document.write(String.fromCharCode(32,32,116,114,32,123,32,98,111,114,100,101,114,58,32,49,112,120,32,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,98,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,32,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.
    Last edited by rnd me; 09-29-2008 at 04:25 PM.
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/9/03) IE7:0.1, IE8:4.6, IE11:9.1, IE9:3.1, IE10:3.0, FF:17.2, CH:46, SF:11.4, NON-MOUSE:38%

  • Users who have thanked rnd me for this post:

    Wardy118 (09-29-2008)

  • #8
    New Coder
    Join Date
    Jul 2006
    Posts
    81
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Amazing stuff!

    Thank you soooooooo much Dan that works a treat.


  • #9
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,373
    Thanks
    11
    Thanked 592 Times in 572 Posts
    Quote Originally Posted by Wardy118 View Post
    Amazing stuff!

    Thank you soooooooo much Dan that works a treat.

    you are welcome.

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

    Code:
    <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>
    Last edited by rnd me; 09-29-2008 at 05:41 PM.
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/9/03) IE7:0.1, IE8:4.6, IE11:9.1, IE9:3.1, IE10:3.0, FF:17.2, CH:46, SF:11.4, NON-MOUSE:38%


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •