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 7 of 7
  1. #1
    New Coder
    Join Date
    Jun 2010
    Posts
    23
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Hiding my javascript source

    I want to hide my JavaScript but when I checked the FAQ of this forum, I saw that it said that it isn't possible.

    But how did worldometers.info did it? Because I cant find the JavaScript source.

  • #2
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,076
    Thanks
    38
    Thanked 498 Times in 492 Posts
    Checkout some of these sites for an explanation:
    http://www.google.com/search?q=eval+...ient=firefox-a

  • #3
    Senior Coder Rowsdower!'s Avatar
    Join Date
    Oct 2008
    Location
    Some say it's everything.
    Posts
    2,027
    Thanks
    5
    Thanked 397 Times in 390 Posts
    It's not impervious. It will only stop the casual viewer...

    For example, the source from worldometers.info:
    Code:
    <script language="JavaScript" src="engine-en96540109.js" type="text/javascript"></script><script type="text/javascript">
    //(c) Copyright Worldometers.info. All rights reserved.
    
    function startClock() {
            timeRemaining();
    }
    
    function round_number(number,dec_places){
    //(c) Copyright 2008, Russell Walker, Netshine Software Limited. www.netshinesoftware.com
    var new_number='';var i=0;number=number.toString();dec_places=dec_places*1;dec_point_pos=number.lastIndexOf(".");if(dec_point_pos==0){number="0"+number;dec_point_pos=1}if(dec_point_pos==-1||dec_point_pos==number.length-1){if(dec_places>0){new_number=number+".";for(i=0;i<dec_places;i++){new_number+="0"}return new_number}else{return number}}var existing_places=(number.length-1)-dec_point_pos;if(existing_places==dec_places){return number}if(existing_places<dec_places){new_number=number;for(i=existing_places;i<dec_places;i++){new_number+="0"}return new_number}var end_pos=(dec_point_pos*1)+dec_places;var round_up=false;if((number.charAt(end_pos+1)*1)>4){round_up=true}var digit_array=new Array();for(i=0;i<=end_pos;i++){digit_array[i]=number.charAt(i)}for(i=digit_array.length-1;i>=0;i--){if(digit_array[i]=="."){continue}if(round_up){digit_array[i]++;if(digit_array[i]<10){break}}else{break}}for(i=0;i<=end_pos;i++){if(digit_array[i]=="."||digit_array[i]<10){new_number+=digit_array[i]}else{new_number+="0"}}if(dec_places==0){new_number=new_number.replace(".","")}return new_number}
    
    function string(number) {
            var tempnum;
    
            tempnum= Math.round(number)+" ";
            tempnum= tempnum.substring(0,tempnum.length-1);
    
            if (tempnum.length >3) {
            tempnum = tempnum.substring(0,tempnum.length-3) + "," + tempnum.substring(tempnum.length-3, 99);
            }
            if (tempnum.length >7) {
            tempnum = tempnum.substring(0,tempnum.length-7) + "," + tempnum.substring(tempnum.length-7, 99);
            }
            if (tempnum.length >11) {
            tempnum = tempnum.substring(0,tempnum.length-11) + "," + tempnum.substring(tempnum.length-11, 99);
            }
            if (tempnum.length >15) {
            tempnum = tempnum.substring(0,tempnum.length-15) + "," + tempnum.substring(tempnum.length-15, 99);
            }
            if (tempnum.length == 11) {
                    tempnum = "  " + tempnum;
            }
            if (tempnum.length == 10) {
                    tempnum = "   " + tempnum;
            }
            if (tempnum.length == 9) {
                    tempnum = "   " + tempnum;
            }
            if (tempnum.length == 7) {
                    tempnum = "      " + tempnum;
            }
            if (tempnum.length == 6) {
                    tempnum = "       " + tempnum;
            }
            if (tempnum.length == 5) {
                    tempnum = "        " + tempnum;
            }
            if (tempnum.length == 3) {
                    tempnum = "          " + tempnum;
            }
            if (tempnum.length == 2) {
                    tempnum = "           " + tempnum;
            }
            if (tempnum.length == 1) {
                    tempnum = "            " + tempnum;
            }
            return tempnum;
    }
    
    function timeRemaining() {
    
            var now = new Date();                                
            var newyears = new Date("January 1, 2000");
            var todaysdate = new Date("January 1, 2000");
            var may4 = new Date("May 4, 1999");
    		var ye = new Date("Dec 31, 2009");
             
            var currentPop;
            var BirthsInYear;
    
            newyears.setFullYear(now.getFullYear());
    
            secsSince = Math.round(now.getTime() - newyears.getTime())/1000;
            secsSincePop = Math.round(now.getTime() - may4.getTime())/1000;
    		secsSinceYearEnd = Math.round(now.getTime() - ye.getTime())/1000;
              
            todaysdate.setMonth(now.getMonth());
            todaysdate.setDate(now.getDate());
            todaysdate.setFullYear(now.getFullYear());
            secsToday = (now.getTime()-todaysdate.getTime())/1000;
    
    
    // test to see what page is loaded, then activate the appropriate worldometers
    // NOTE: if you startup more than 20, they go to slow
    
    switch (document.title) {
       case 'Worldometers - real time world statistics':
       {    
       
       
            // population
            current_population = string( Math.round( (secsSincePop) * 2.48573 + 5979540016 - (secsToday) * 2.48573)  + Math.round((secsToday) * 4.41461) - Math.round((secsToday) * 1.92888) ) ;
            births_this_year = string(Math.round( (secsSince) * 4.41461 - (secsToday) * 4.41461) + (secsToday) * 4.41461);
    		        births_today = string((secsToday) * 4.41461);
            dth1s_this_year = string(Math.round( (secsSince) * 1.92888 - (secsToday) * 1.92888) + (secsToday) * 1.92888);
            dth1s_today = string((secsToday) * 1.92888);
    		absolute_growth = string( Math.round((secsToday) * 4.41461) - Math.round((secsToday) * 1.92888) );
          
            document.worldometers.elements["current_population"].value = current_population;
            document.worldometers.elements["births_this_year"].value = births_this_year;
            document.worldometers.elements["births_today"].value = births_today;
            document.worldometers.elements["dth1s_this_year"].value = dth1s_this_year;
            document.worldometers.elements["dth1s_today"].value = dth1s_today;
    		document.worldometers.elements["absolute_growth"].value = absolute_growth;
    
         // govt & econ
    	 gov_expenditures_health = string((secsToday) * 100791);
         gov_expenditures_education = string((secsToday) * 78940);
         gov_expenditures_military = string((secsToday) * 43730);
         countries_un = string((secsSince) / (secsSince) * 192);
         automobile_produced_this_year = string((secsSince) * 1.648);
         bicycle_produced_this_year = string((secsSince) * 3.46);
         computers_sold_this_year = string((secsSince) * 9.069);
         
         document.worldometers.elements["gov_expenditures_health"].value = gov_expenditures_health;
    	 document.worldometers.elements["gov_expenditures_education"].value = gov_expenditures_education;
         document.worldometers.elements["gov_expenditures_military"].value = gov_expenditures_military;
         document.worldometers.elements["countries_un"].value = countries_un;
         document.worldometers.elements["automobile_produced_this_year"].value = automobile_produced_this_year;
         document.worldometers.elements["bicycle_produced_this_year"].value = bicycle_produced_this_year;
         document.worldometers.elements["computers_sold_this_year"].value = computers_sold_this_year;
    
         // society & media
         books_published = string((secsSince) * .03186);
         newspapers_circulated = string((secsToday) * 6317);
         tv = string((secsToday) * 6.64);
    	 cellular = string((secsToday) * 39.32);
    	 videogames = string((secsToday) * 1401);
         internet_users = string(secsSinceYearEnd * 8 + 1801171917);
         em = string((secsToday) * 3289352);
    	 blog_posts = string((secsToday) * 7);
    	 google_searches = string((secsToday) * 35112);
    
         document.worldometers.elements["books_published"].value = books_published;
         document.worldometers.elements["newspapers_circulated"].value = newspapers_circulated;
         document.worldometers.elements["tv"].value = tv;
    	 document.worldometers.elements["cellular"].value = cellular;
    	 document.worldometers.elements["videogames"].value = videogames;
         document.worldometers.elements["internet_users"].value = internet_users;
    	 document.worldometers.elements["em"].value = em;
    	 document.worldometers.elements["blog_posts"].value = blog_posts;
         document.worldometers.elements["google_searches"].value = google_searches;
    
    
    
         // environment
         forest_loss = string((secsSince) * .3571);
         soil_erosion = string((secsSince) * .1903);
         co2_emissions = string((secsSince) * 708);
    	 temperature = round_number(14.55 + (secsSince * .0230/31536000),9);
         desert_land_formed = string((secsSince) * .47);
    	 ext = string((secsSince) * .0044);
    	 tox_chem = string((secsSince) * .3105);
         earth_travel = string((secsSince) * 18.5 * 1.61);
         
         
         document.worldometers.elements["forest_loss"].value = forest_loss;
         document.worldometers.elements["soil_erosion"].value = soil_erosion;
         document.worldometers.elements["co2_emissions"].value = co2_emissions;
    	 document.worldometers.elements["temperature"].value = temperature;
         document.worldometers.elements["desert_land_formed"].value = desert_land_formed;
    	 document.worldometers.elements["ext"].value = ext;
    	 document.worldometers.elements["tox_chem"].value = tox_chem;
         document.worldometers.elements["earth_travel"].value = earth_travel;
    
    
         // food
         food_production = string((secsSince) * 166.47);
    	 undernourished = string(secsSincePop * .3171 + 914000000);
    	 overweight = string(secsSincePop * .43 + 1000000000);
    	 obese = string(secsSincePop * .121 + 300000000);
    	 obesity_spending = string((secsToday) * 2917.3);
    	 dth1_hunger = string((secsToday) * 0.33);
         spending_on_weight_loss = string((secsToday) * 1268.4);
         
         document.worldometers.elements["food_production"].value = food_production;
    	 document.worldometers.elements["undernourished"].value = undernourished;
    	 document.worldometers.elements["overweight"].value = overweight;
    	 document.worldometers.elements["obese"].value = obese;
    	 document.worldometers.elements["dth1_hunger"].value = dth1_hunger;
    	 document.worldometers.elements["obesity_spending"].value = obesity_spending;
         document.worldometers.elements["spending_on_weight_loss"].value = spending_on_weight_loss;
    	 
    	      // water
         water_consumed = string((secsSince) * .133);
    	      water_disax = string((secsSince) * 0.16);
    	  nowater_population = string(secsSince * 5.28 + 1300370016);
    
         
         document.worldometers.elements["water_consumed"].value = water_consumed;
    	 document.worldometers.elements["water_disax"].value = water_disax;
         document.worldometers.elements["nowater_population"].value = nowater_population;
         
            // energy
    		
    energy_used = string((secsToday) * 4928.58);
    energy_nonren = string((secsToday) * 4544.00);
    energy_ren = string((secsToday) * 374.57);
    solar_energy = string((secsToday) * 465594.88);
    oil_consumption = string((secsToday) * 972.22);
    oil_reserves = string(secsSince * -972.22 + 1317000000000);
    oil_days = string((secsSince * -972 + 1317000000000)/84000000);
    gas_reserves = string(secsSince * -219.91 + 1161000000000);
    gas_days = string((secsSince * -219.91 + 1161000000000)/19000000);
    coal_reserves = string(secsSince * -335.65 + 4416000000000);
    coal_days = string((secsSince * -335.65 + 4416000000000)/29000000);
    
    
    document.worldometers.elements["energy_used"].value = energy_used;
    document.worldometers.elements["energy_nonren"].value = energy_nonren;
    document.worldometers.elements["energy_ren"].value = energy_ren;
    document.worldometers.elements["solar_energy"].value = solar_energy;
    document.worldometers.elements["oil_consumption"].value = oil_consumption;
    document.worldometers.elements["oil_reserves"].value = oil_reserves;
    document.worldometers.elements["oil_days"].value = oil_days;
    document.worldometers.elements["gas_reserves"].value = gas_reserves;
    document.worldometers.elements["gas_days"].value = gas_days;
    document.worldometers.elements["coal_reserves"].value = coal_reserves;
    document.worldometers.elements["coal_days"].value = coal_days;
    
    
         // health
         dth1s_communicable_disaxs = string((secsSince) * .4281);
    	 dth1s_children = string((secsSince) * .35);
    	 ab = string((secsSince) * 1.46);
    	 abi = string((secsSince) * .04);
         dth1s_maternal = string((secsSince) * .02);
         infections_hiv = string((secsSince * .1)+30000000);
         dth1s_ads = string((secsSince * .0647));
         dth1s_cancer = string((secsSince) * .2410);
         dth1s_malarial = string((secsSince) * .032);
    	 cigarettes_smoked = string((secsToday) * 175514);
         dth1s_cigarettes = string((secsSince) * .2125);
         dth1s_alchool = string((secsSince) * .0571);
         sui = string((secsSince) * .0340);
         drug_spending = string((secsSince) * 12684);
    	 dth1s_cars = string((secsSince) * .0403);
    
    
         document.worldometers.elements["dth1s_communicable_disaxs"].value = dth1s_communicable_disaxs;
         document.worldometers.elements["dth1s_children"].value = dth1s_children;
    	  document.worldometers.elements["ab"].value = ab;
    	  document.worldometers.elements["abi"].value = abi;
         document.worldometers.elements["dth1s_maternal"].value = dth1s_maternal;
         document.worldometers.elements["infections_hiv"].value = infections_hiv;
         document.worldometers.elements["dth1s_ads"].value = dth1s_ads;
         document.worldometers.elements["dth1s_cancer"].value = dth1s_cancer;
         document.worldometers.elements["dth1s_malarial"].value = dth1s_malarial;
    	 document.worldometers.elements["cigarettes_smoked"].value = cigarettes_smoked;
         document.worldometers.elements["dth1s_cigarettes"].value = dth1s_cigarettes;
         document.worldometers.elements["dth1s_alchool"].value = dth1s_alchool;
         document.worldometers.elements["sui"].value = sui;
         document.worldometers.elements["drug_spending"].value = drug_spending;
         document.worldometers.elements["dth1s_cars"].value = dth1s_cars;
    
         
        
         break;
       }
    }
    
            timerID = setTimeout("timeRemaining()", 1);
            timerRunning = true;
    
    }
    </script>
    You can try the method here, if you like:
    http://www.webtoolkit.info/javascript-base64.html

    Or just go here and let the website do it for you:
    http://www.intelliwebtools.com/node/169
    The object of opening the mind, as of opening the mouth, is to shut it again on something solid. –G.K. Chesterton
    See Mediocrity in its Infancy
    It's usually a good idea to start out with this at the VERY TOP of your CSS: * {border:0;margin:0;padding:0;}
    Seek and you shall find... basically:
    validate your markup | view your page cross-browser/cross-platform | free web tutorials | free hosting

  • #4
    New Coder
    Join Date
    Jun 2010
    Posts
    23
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Ok nice. But i got a question now.

    1. How did you get the source ? I mean did u decode or something? And how did u do that.

  • #5
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,076
    Thanks
    38
    Thanked 498 Times in 492 Posts

    Question

    Quote Originally Posted by DieAntwoord` View Post
    Ok nice. But i got a question now.

    1. How did you get the source ? I mean did u decode or something? And how did u do that.
    Did you read the end of the last post?

  • #6
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,189
    Thanks
    75
    Thanked 4,341 Times in 4,307 Posts
    It's no wonder worldometers.info hides their source. They must be embarrassed that they use such crappy code and don't want the world to know it. <snicker />
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #7
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,296
    Thanks
    10
    Thanked 584 Times in 565 Posts
    the best way to hide it is to keep it on your local machine.
    the same origin policy prevents other users from seeing code on your own computer.
    it can still be found, that why i hide mine under the mattress when i go on vacation.
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/5/28) IE7:0.1, IE8:5.3, IE11:8.4, IE9:3.2, IE10:3.2, FF:18.2, CH:46, SF:7.9, NON-MOUSE:32%


  •  

    Posting Permissions

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