Mancent Posted April 23, 2014 Share Posted April 23, 2014 (edited) Ok I been trying to make a traffic generator website but I ran into a problem with javascript And this page is the page that is giving me the problem https://gananciasexpress.com/rrodriguez/5.html when the loader is ready to load a new site this page send a alert message or some type of message trying to get the user to stay on his page, and no mater what button you click it redirects them to his page again.I do not want to disable javascript I just want to control the call..I thought I could just create a function for that callI thought it would be window.onbeforeunloadso I created a function for that w window.onbeforeunload = function() {};but I just can not stop it from taking control. Can any of you help me with thisThis is what code I am working with trying to solve this. <?php include "connect.php"; ?> <style type="text/css"> #progressBar { position : fixed; top:0px; right:0px; width:100%; height:50px; background:#000; z-index:999999999999998; overflow:hidden; } #status { position : fixed; top:0px; right:0px; width:100%; height:50px; color:#FFFFFF; font-size:24px; z-index:9999999999999999; overflow:hidden; } </style> <script type="text/javascript"> <!-- if (top.location!= self.location) { top.location = self.location.href } //--> </script> <script> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-50245319-1', 'nettys.co'); ga('send', 'pageview'); </script> <script type="text/javascript"> window.alert = function() {}; window.onbeforeunload = function() {}; // or simply alert = function() {}; var prevent_bust = 0 window.onbeforeunload = function() { prevent_bust++ } setInterval(function() { if (prevent_bust > 0) { prevent_bust -= 2 window.top.location = 'http://www.nettys.co/traffic.php' } }, 1) </script> <?php $sql = "SELECT * FROM Traffic ORDER BY RAND() LIMIT 1 "; $querys = mysql_query($sql) or trigger_error("Query Failed: " . mysql_error()); if (mysql_num_rows($querys) == 1) { $rows = mysql_fetch_assoc($querys); $domain = $rows['domain']; $variableee = readfile($domain); echo $variableee; } else { echo "we have a error some how!"; } ?> <progress id="progressBar" value="0" max="100"></progress> <span id="status"></span> <script type="text/javascript" language="javascript"> function progressBarSim(al) { var bar = document.getElementById('progressBar'); var status = document.getElementById('status'); status.innerHTML = "Please Wait While Loading Each Page "+al+"%"; bar.value = al; al++; var sim = setTimeout("progressBarSim("+al+")",250); if(al == 100){ status.innerHTML = "Please Wait While Loading Each Page 100%"; bar.value = 100; clearTimeout(sim); window.location.href = "traffic.php"; } } var amountLoaded = 0; progressBarSim(amountLoaded); </script> And you can test the site at http://nettys.co/traffic.php Edited April 23, 2014 by Mancent Quote Link to comment https://forums.phpfreaks.com/topic/287970-on-leave-page-help-stop-javascript-code/ Share on other sites More sharing options...
Psycho Posted April 23, 2014 Share Posted April 23, 2014 You cannot modify the JavaScript on an external page. Quote Link to comment https://forums.phpfreaks.com/topic/287970-on-leave-page-help-stop-javascript-code/#findComment-1477081 Share on other sites More sharing options...
Solution Mancent Posted April 23, 2014 Author Solution Share Posted April 23, 2014 Well this worksbut I have to set safe sites up to display and be able to use scripts.This is only a traffic system to get traffic. so scripts do not need to be used. But I want to let some scripts pass. like google and youtube <?php include "connect.php"; ?> <style type="text/css"> #progressBar { position : fixed; top:0px; right:0px; width:100%; height:50px; background:#000; z-index:999999999999998; overflow:hidden; } #status8husyhdyts { position : fixed; top:0px; right:0px; width:100%; height:50px; color:#FFFFFF; font-size:24px; z-index:9999999999999999; overflow:hidden; } </style> <script type="text/javascript"> <!-- if (top.location!= self.location) { top.location = self.location.href } //--> </script> <script> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-50245319-1', 'nettys.co'); ga('send', 'pageview'); </script> <script type="text/javascript"> window.alert = function() {}; window.onbeforeunload = function() {}; // or simply alert = function() {}; var prevent_bust = 0 window.onbeforeunload = function() { prevent_bust++ } setInterval(function() { if (prevent_bust > 0) { prevent_bust -= 2 window.top.location = 'http://www.nettys.co/traffic.php' } }, 1) </script> <progress id="progressBar" value="0" max="100"></progress> <span id="status8husyhdyts"></span> <script type="text/javascript" language="javascript"> function progressBarSim(al) { var bar = document.getElementById('progressBar'); var status = document.getElementById('status8husyhdyts'); status.innerHTML = "Please Wait While Loading Each Page "+al+"%"; bar.value = al; al++; var sim = setTimeout("progressBarSim("+al+")",250); if(al == 100){ status.innerHTML = "Please Wait While Loading Each Page 100%"; bar.value = 100; clearTimeout(sim); window.location.href = "traffic.php"; } } var amountLoaded = 0; progressBarSim(amountLoaded); </script> <?php $sql = "SELECT * FROM Traffic ORDER BY RAND() LIMIT 1 "; $querys = mysql_query($sql) or trigger_error("Query Failed: " . mysql_error()); if (mysql_num_rows($querys) == 1) { $rows = mysql_fetch_assoc($querys); $domain = $rows['domain']; $html = file_get_contents($domain); $h = explode('>', $html); foreach($h as $k => $v){ $v = trim($v);//clean it up a bit if(preg_match('/^(<script[.*]*)/ius', $v)){//my regex here might be questionable $counter = $k;//match opening tag and start counter for backtrace }elseif(preg_match('/([.*]*<\/script$)/ius', $v)){//but it gets the job done $script_length = $k - $counter; $counter = 0; for($i = $script_length; $i >= 0; $i--){ $h[$k-$i] = '';//backtrace and clear everything in between } } } for($i = 0; $i <= count($h); $i++){ if($h[$i] != ''){ $ht[$i] = $h[$i];//clean out the blanks so when we implode it works right. } } $html = implode('>', $ht);//all scripts stripped. echo $html; } else { echo "we have a error some how!"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/287970-on-leave-page-help-stop-javascript-code/#findComment-1477082 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.