Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (typeof js_callback == 'undefined') {
- var js_callback = false;
- }
- var XD=function(){var e,g,h=1,f,d=this;return{postMessage:function(c,b,a){b&&(a=a||parent,d.postMessage?a.postMessage(c,b.replace(/([^:]+:\/\/[^\/]+).*/,"$1")):b&&(a.location=b.replace(/#.*$/,"")+"#"+ +new Date+h++ +"&"+c))},receiveMessage:function(c,b){if(d.postMessage)if(c&&(f=function(a){if("string"===typeof b&&a.origin!==b||"[object Function]"===Object.prototype.toString.call(b)&&!1===b(a.origin))return!1;c(a)}),d.addEventListener)d[c?"addEventListener":"removeEventListener"]("message",f,!1);
- else d[c?"attachEvent":"detachEvent"]("onmessage",f);else e&&clearInterval(e),e=null,c&&(e=setInterval(function(){var a=document.location.hash,b=/^#?\d+&/;a!==g&&b.test(a)&&(g=a,c({data:a.replace(b,"")}))},100))}}}();
- var src = 'http://b.jobaudience.com/tpl/v1/ja.html#' + encodeURIComponent(document.location.href);
- var div = document.createElement('div');
- div.setAttribute('style', 'visibility:hidden;position:absolute');
- var iframe = document.createElement('iframe');
- iframe.setAttribute('src', src);
- iframe.setAttribute('width', 1);
- iframe.setAttribute('height', 1);
- iframe.setAttribute('marginwidth', 0);
- iframe.setAttribute('marginheight', 0);
- iframe.setAttribute('scrolling', 0);
- iframe.setAttribute('frameborder', 0);
- div.appendChild(iframe);
- document.getElementsByTagName('body')[0].appendChild(div);
- var _is_good = false;
- XD.receiveMessage(function(message){
- if (message.data.act == 'status') {
- _is_good = true;
- } else if (message.data.act == 'uid') {
- if (message.data.uid) {
- uidIsGet(message.data.uid);
- } else {
- setJsUid(js_uid);
- }
- }
- }, 'http://b.jobaudience.com');
- var _check_ready = function() {
- if (!_is_good) {
- XD.postMessage({act : 'status'}, src, iframe.contentWindow);
- setTimeout(_check_ready, 100);
- } else {
- XD.postMessage({act : 'get', key : 'js_uid'}, src, iframe.contentWindow);
- }
- };
- setTimeout(_check_ready, 100);
- function setJsUid(uid) {
- window && window.localStorage && window.localStorage.setItem('js_uid', js_uid);
- XD.postMessage({act : 'set', key : 'js_uid', value : js_uid}, src, iframe.contentWindow);
- js_callback && js_callback(uid)
- }
- function uidIsGet(uid) {
- js_uid = uid;
- window && window.localStorage && window.localStorage.setItem('js_uid', uid);
- js_callback && js_callback(uid)
- }
Advertisement
Add Comment
Please, Sign In to add comment