How AdSense works.

Let's see what is happening when AdSense script runs in browser. Hope you are familiar with following code:
<script type="text/javascript">
google_ad_client = "pub-7777777777777";
google_ad_slot = "777777777777";
google_ad_width = 468;
google_ad_height = 60;
</script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
In general show_ads.js does the following tasks:
  1. script collects all available information about browser and OS (see: Browser fingerprint). This information includes: browser window size; display size; monitor color depth; plug-ins list; java version; checks if window has parent window; referrer;
  2. imports another 2 JS files - they are quite complicated to read because of obfuscation, but the main task they serve - make results more unpredictable and hard to mimic.
  3. creates IFRAME, which has main parameters (1) in URL - thus sending valuable espionage information back to Google.
  4. in the loaded IFRAME there are some scripts also, which IMHO are anti-bot watchers - they counts every mouse move over ads and then send this info to Google if ads link is clicked. I presume this helps detecting click-fraud bots.

Well, definitely principal weaknesses exist in the online ads model itself, allowing to perform "perfect" (i.e. undetectable) click-fraud attack, but implementation is quite tricky and expensive and bottlenecks are traffic to MFA sites and payouts.

Actually, advertisment networks may perfectly track users — every time you visit website with ads browser sends a little string - "cookie" to an advertisment server, next page — the same cookie, thus ad networks follow you. But don't think you are genious if you clear cookies (or restrict them in browser) — remember fingerprints while surfing internet.

Browser fingerprint

Do you know that it is VERY VERY difficult to hide your internet activity from "smart" servers? If they do well, web-servers can detect (or at least guess) your return visit, despite you have cleared borwser's cookies and anonymized with proxy. According to Electronic Frontier Foundation browsers have "digital fingerprints", the vast combination of many parameters available to servers over HTTP, javascript, browsers plugins (Flash, Java and etc.), network settings (IP, DNS). As for now EFF has counted 219 (more than 524000) combinations of browser settings — little possibility to have another visitor with the same "fingerprint". You are under a sight!

Test yourself on EFF's Panopticlick. They surprised even me! I didn't expect possibility to detect:

  • system fonts
  • DNS server i use
  • the same Flash cookie in all my browsers

With a little help of sociology, web statistic and CSS web-history exploit servers can guess your gender and age. Hasta la vista, anonymity!

I know nights are for passion

I know nights are for passion,
Birght sunny days are for wars
And heroes killed in action.
Nikolay Gumilyov, 1905
(RU => EN) Denis Kalinin, 2010
Я знаю, что ночи любви нам даны
И яркие, жаркие дни для войны.
Николай Гумилёв, 1905

Geolocating Google News

Suppose you want to get news depending on their location — the only tool i have found is (no surprise) Google News! It has almost unkown functionality of locating news articles, not perfect one, but IMHO quite sufficient. The Google's geo search parameter seems to work in US only.

Va bene! Monkey see, monkey do: to get news from Rome and Lazio region (Italy) use this RSS URL: http://news.google.com/news?output=rss&q=location:Roma+OR+location:Lazio. The "OR" parameter has reason here, because some sources are possibly marked as originating from Lazio (Rome itself is in Lazio region) but concern to Rome also.

Google.News request parameters:

q
query string,location — subparameter to define news location. In the example above i defined that i search news from either Rome OR Lazio. NB! Substitute white spaces and hyphens in geographical names with underline "_": Addis Abbaba → Addis_Ababa. This is the hack! The feature is not documented by Google. Уou can use national geographical names in your requests Odessa OR Одесса OR Одеса OR Одесская область: the second usefulness of "OR" operation — news source location is marked either in english or national language, you'd better search for both.
ned
national "news edition". See Googel News France
hl
means "human language" i presume. Forces to set news language in spite of ned parameter. News from Paris in ITALIAN language for english edition
as_scoring
News sorting order. Seems to be useful only when searching with keywords. as_scoring=n sort by date, as_scoring=n sort by relevance. Sorted by date News from Paris in italian

Bing maps driving directions

Bing Maps (formely VirtualEarth Maps) has a splendid driving direction service, covering the whole world — neither Google Maps no another webmaps do that.

As a GIS-web developer you can face a little problem - driving direction has limited API access and you cat get generalized route only (i.e. curve of few points VERouteItineraryItem instead of shape VEShape), because API property VERoute.ShapePoints is available with explicit permission from Microsoft, in other words — they encrypt shape data and if you subscribe the service will give you the key. I have figured out there are limitations for number of requests - 1000 per day for developer and $0.01 per request for enterprise.

Bing directions with OpenLayers

The idea:

  1. create Bing layer without tiles VEMapOptions.LoadBaseTiles=false
  2. get route with Bing API
  3. maximum zoom layer to get detailed shape
  4. parse SVG or VML poliline with pixel-to-LonLat function
It seems to be easier than breaking encrypted VERoute.ShapePoints data. In a couple of days i will upload working sample to OpenLayers sandbox.

Google AdSense keywords hack

AdSense is placed in iframe on webpage by adsenes's javascript. This fact has given me an idea to put adsense in my own iframe where i can define my own keywords, the result - ads will differ from top page content!! Cool - keyword hack! But adsense script checks for 'window.top' and if true - script will show adsense according to top page content. The trick is to set window.top=window.self before adsense script (may not work in some IE, because MSIE doesn't allow javascript to rewrite «window» - DOM object).

EXAMPLE (Topic: Online education)

OpenLayers and Yandex.Maps (Яндекс.Карты)

15 May 2009

FIXED version is available

Hello all! At last i have uploaded the fixed version of Yandex maps for openlayers. Look here: Yandex maps for OpenLayers (in sandbox). This fix removes latitude distortion because of ellipsoid globe model used in YandexMaps in contrast to spheroid in Google and Bing. I can't make these changes in simple version (beneath)— i have no idea about projection (EPSG) used in this webmap. If you have — send me description (see Spatialreference).

There are 2 files Yandex.html and OL_Yandex.js

OpenLayers is splendid opensource javascript framework for webmapping. "Yandex.Maps" (russian:Яндекс.Карты) - russian webmapping service (like Google Maps or VirtualEarth)

This is example map (up) and here is the code (down):

<script type="text/javascript" src="http://www.openlayers.org/api/OpenLayers.js"></script>
<div id="map" style="border: 1px solid lightgray; margin: 0pt 0pt 30px; padding: 0pt; width: 350px; height: 256px;"/>
<script type="text/javascript">
function yandex_getTileURL(bounds){
  var res = this.map.getResolution();
  var maxExtent = (this.maxExtent) ? this.maxExtent : yandexBounds;
  var tileW = (this.tileSize)?this.tileSize.w:256;
  var tileH = (this.tileSize)?this.tileSize.h:256;
  var x = Math.round((bounds.left - maxExtent.left)/(res * tileW));
  var y = Math.round((maxExtent.top - bounds.top)/(res * tileH));
  var z = this.map.getZoom();var limit = Math.pow(2, z);
  if (y <0>= limit) {
    return OpenLayers.Util.getImagesLocation() + "404.png";
  }else {
    x = ((x % limit) + limit) % limit;
    url = (this.url)?this.url:"http://vec02.maps.yandex.net/";
    return url+"tiles?l=map&v=2.2.3&x="+x+"&y="+y+"&z="+z;
  }
};

var yandexBounds = new OpenLayers.Bounds(-20037508,-20002151,20037508,20072865);

var map = new OpenLayers.Map('map', {
  projection: new OpenLayers.Projection("EPSG:900913"),
  displayProjection: new OpenLayers.Projection("EPSG:4326"),
  units: "m",
  maxResolution: 156543.0339,
  maxExtent:new OpenLayers.Bounds(-20037508,-20037508,20037508,20037508.34)
});

var yandexMaps =
  new OpenLayers.Layer.TMS("Yandex","http://vec02.maps.yandex.net/",
  {
    maxExtent:yandexBounds,
    type:"png",
    getURL:yandex_getTileURL,
    numZoomLevels:18,
    attribution:'<a href="http://beta-maps.yandex.ru/">Яндекс.Карты</a>',
    transitionEffect:'resize'
  });
map.addLayers([yandexMaps]);
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.zoomTo(4);
</script>