Problem on adsence they dont tell you which ads are showing and which not, because lots of ads i dont want them to show, because it has some content, which goes against our community policy, like bikini girls or vigra ads or many others.
Solution Idea i wanted to know if its possible to read what adsense ads showing on my website through javascript. well the reason i asked, is because they are using iframe for ads. all i want to do, is read there showing ads and log it. which i can later review it, if i need to block thous ads or no. i might even just put report ads link, which will auto names of the current ads showing.
Little Sample Code
var iframeID = jQuery('iframe').attr('id');
console.log(document.getElementById(iframeID).contentWindow.document.body.innerHTML);
output:
<script>(function(){window.ss=function(d,e){window.status=d;var c=document.getElementById(e);if(c){var a;a=c.href;var b=a.match("^(.*)([?|&]nm=)([^&]*)(.*)$");if(b){b[3]=(Number(b[3])||0)+1;b[0]="";a=b.join("")}else a=a+"&nm=1";c.href=a}return true};})();function su(id) {var a = document.getElementById(id);var b = (new Date()).getTime();if (a && a.myt && b) {var t = b - a.myt;var bi = a.href.indexOf("&clkt=");if (bi > 0) {var c = a.href.substring(0, bi+6); var d = a.href.substring(bi+6, a.href.length);var ei = d.indexOf("&");var r = '';if (ei >= 0)r = d.substring(ei, d.length);a.href = c + t + r; } else {a.href += "&clkt=" + t;}}return true;}function cs(){window.status='';} function jcc(a) {pha=document.getElementById(a); nc=pha.href.indexOf('&jca='); if(nc>=1) return; jca=(401)+(344)-(324); if (a=='aw0') {jca+=(6844);} else {jca=0;} phb=pha.href+'&jca='+jca; pha.href=phb;} function st(id) {var a = document.getElementById(id);if (a) {a.myt = (new Date()).getTime();}return true;}function ha(a){ var pha=document.getElementById(a);var nhi=pha.href.indexOf("&nh=");if(nhi < 1) {pha.href+="&nh=1";}su(a); jcc(a); }function ca(a) { var pha=document.getElementById(a);var nci=pha.href.indexOf("&nc=");if(nci < 1) {pha.href+="&nc=1";}su(a); jcc(a); top.location.href=document.getElementById(a).href;}function ga(o,e) {if (document.getElementById) {a=o.id.substring(1);p="";r="";g=e.target;if (g) {t=g.id;f=g.parentNode;if (f) {p=f.id;h=f.parentNode;if (h)r=h.id;}} else {h=e.srcElement;f=h.parentNode;if (f)p=f.id;t=h.id;}if (t==a||p==a||r==a)return true;var pha=document.getElementById(a);var nbi=pha.href.indexOf("&nb=");if(nbi < 1) {pha.href+="&nb=1";}su(a); jcc(a); top.location.href=document.getElementById(a).href;}}</script><script>document.close();</script>
when i preview the iframe code in console, then this above code is in the header and body has all the ads
following is the iframe code which i preview in console:
<html>
<head>
<style>
a:link,a:visited,a:hover,a:active {
color: #0000ff;
cursor: pointer;
}
body,table,div,ul,li {
font-size: 10px;
margin: 0px;
padding: 0px
}
body {
background-color: transparent;
font-family: verdana, arial, sans-serif;
height: 100%
}
#aus {
height: 250px;
width: 300px
}
#ads {
left: 0px;
position: absolute;
top: 0px;
width: 300px
}
#ads ul {
list-style: none;
}
#ads ul li {
clear: both;
float: left;
height: 232px;
margin: 0px 21px 0px 21px;
overflow: hidden;
width: 258px
}
.ad {
margin: 0px 0px
}
.adt {
font-size: 13px;
font-weight: bold;
}
.adb {
color: #000000;
display: block;
font-size: 13px;
}
.adu {
color: #009900;
font-size: 10px;
line-height: 12px;
overflow: hidden;
white-space: nowrap
}
.adus {
cursor: pointer;
}
.adc {
height: 232px;
overflow: hidden;
table-layout: fixed;
width: 100%
}
#ainw {
left: 3px;
position: absolute;
top: 235px
}
#abgi {
left: 202px;
position: absolute;
top: 233px
}
#aubg {
background-color: #ffffff;
border: 0px solid #ffffff;
height: 250px;
width: 300px
}
</style>
<script>(function(){window.ss=function(d,e){window.status=d;var c=document.getElementById(e);if(c){var a;a=c.href;var b=a.match("^(.*)([?|&]nm=)([^&]*)(.*)$");if(b){b[3]=(Number(b[3])||0)+1;b[0]="";a=b.join("")}else a=a+"&nm=1";c.href=a}return true};})();function su(id) {var a = document.getElementById(id);var b = (new Date()).getTime();if (a && a.myt && b) {var t = b - a.myt;var bi = a.href.indexOf("&clkt=");if (bi > 0) {var c = a.href.substring(0, bi+6); var d = a.href.substring(bi+6, a.href.length);var ei = d.indexOf("&");var r = '';if (ei >= 0)r = d.substring(ei, d.length);a.href = c + t + r; } else {a.href += "&clkt=" + t;}}return true;}function cs(){window.status='';} function jcc(a) {pha=document.getElementById(a); nc=pha.href.indexOf('&jca='); if(nc>=1) return; sv=String.fromCharCode(49,49,51,56,57,55,49,56,51); sv=sv.slice(开发者_如何学C0,4); jca=(4446)+parseInt(sv); if (a=='aw0') {jca+=(-929);} else {jca=0;} phb=pha.href+'&jca='+jca; pha.href=phb;} function st(id) {var a = document.getElementById(id);if (a) {a.myt = (new Date()).getTime();}return true;}function ha(a){ var pha=document.getElementById(a);var nhi=pha.href.indexOf("&nh=");if(nhi < 1) {pha.href+="&nh=1";}su(a); jcc(a); }function ca(a) { var pha=document.getElementById(a);var nci=pha.href.indexOf("&nc=");if(nci < 1) {pha.href+="&nc=1";}su(a); jcc(a); window.open(document.getElementById(a).href);}function ga(o,e) {if (document.getElementById) {a=o.id.substring(1);p="";r="";g=e.target;if (g) {t=g.id;f=g.parentNode;if (f) {p=f.id;h=f.parentNode;if (h)r=h.id;}} else {h=e.srcElement;f=h.parentNode;if (f)p=f.id;t=h.id;}if (t==a||p==a||r==a)return true;var pha=document.getElementById(a);var nbi=pha.href.indexOf("&nb=");if(nbi < 1) {pha.href+="&nb=1";}su(a); jcc(a); window.open(document.getElementById(a).href);}}</script>
</head>
<body>
<div id="aus">
<div id="aubg"></div>
<div id="ads">
<ul id="ads0">
<li onmouseover="ss('','aw0')" onfocus="ss('','aw0')" id="taw0">
<div class="ad">
<table cellspacing="0" cellpadding="0" border="0" class="adc">
<tbody>
<tr>
<td valign="middle"><a target="_blank"
onmouseover="return ss('','aw0')" onmousedown="st('aw0')"
onfocus="ss('','aw0')" onclick="ha('aw0')" id="aw0"
href="http://googleads.g.doubleclick.net/aclk?sa=L&ai=ByWWG079CTeSRJI2MsgaAx93rBaCluFLmxLGnBsCNtwHAqQcQARgBIL39zQo4AFDVluesBWDL9LQFsgEQYmFzaXQuaXJlc2FsYS5pbboBCjMwMHgyNTBfYXPIAQHaASNodHRwOi8vYmFzaXQuaXJlc2FsYS5pbS9wUDJFU3NBYUpocuABAqkCigtjQVkTpT7gAgDqAhtzb2NpYWxfbWVkaWFfZGV0YWlsXzMwMHgyNTCQA_wHmAOkA6gDAcgDF-gDhAf1AwAAAMTgBAE&num=1&sig=AGiWqty6HglfRNFl5bjFjEG438XjgFQw3w&client=ca-pub-&adurl=http://www.gepaelk.com"
class="adt"><span>Reaktif Güç Kont. Rölesi</span></a>
<div class="adb">Kompanzasyonda kesin çözüm. Klasik ve
Thiristörlü çözümler.</div>
<div class="adu"><span onmousedown="st(this.id.substr(1))"
onclick="ga(this,event)" id="uaw0" class="adus">www.gepaelk.com</span></div>
</td>
</tr>
</tbody>
</table>
</div>
</li>
</ul>
</div>
<img width="11" height="11"
src="http://pagead2.googlesyndication.com/pagead/images/ainw_000000.gif"
id="ainw" alt="">
<div id="abgi"><a target="_blank"
href="http://www.google.com/url?ct=abg&q=https://www.google.com/adsense/support/bin/request.py%3Fcontact%3Dabg_afc%26url%3Dhttp://basit.iresala.im/pP2ESsAaJhr%26hl%3Dtr%26client%3Dca-pub-%26adU%3Dwww.gepaelk.com%26adT%3DReaktif%2BG%25C3%25BC%25C3%25A7%2BKont.%2BR%25C3%25B6lesi%26gl%3DPK&usg=AFQjCNGXuz2ZcyVIMFSpO3el2DEDVHZQkw"><img
width="96" height="16" border="0"
src="http://pagead2.googlesyndication.com/pagead/abglogo/abg-tr-100c-000000.png"
alt="Google Reklamları"></a></div>
</div>
<script>document.close();</script>
</body>
</html>
so any ideas/solution please.
No matter how good your intentions, the Single Origin Policy will block any access to the ad. There is no way around it using pure JavaScript inside the page.
You might, however, be able to set something up using a dedicated computer, a browser and a automation solution like Selenium to record displayed ads. I expect it's going to be rather tough to implement, though.
its simple
console.log(jQuery('iframe').contents().find('#ads0').html());
精彩评论