Skip to content

Instantly share code, notes, and snippets.

@firedfox
Created February 3, 2012 08:28
Show Gist options
  • Save firedfox/1729012 to your computer and use it in GitHub Desktop.
Save firedfox/1729012 to your computer and use it in GitHub Desktop.
sampling code for zhidao
var isPicked = function(rate) {
var id = baidu.cookie.get('BAIDUID');
if (!id) { return false; }
id = id.replace(/:.*/, '');
for (var i = 0, l = id.length, sum = 0; i < l; i++) {
sum += id.charCodeAt(i);
}
return (sum % 100 < rate);
};
if (isPicked(30)) {
var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3Fced1e79e7fa08b57cae5394a93748264' type='text/javascript'%3E%3C/script%3E"));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment