User Tools

Site Tools


web_browsers:chrome_screen_scraper:chrome_screen_scraper

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
web_browsers:chrome_screen_scraper:chrome_screen_scraper [2016/07/11 09:19] peterweb_browsers:chrome_screen_scraper:chrome_screen_scraper [2020/04/15 11:46] (current) – removed peter
Line 1: Line 1:
-====== Web Browsers - Chrome Screen Scraper ====== 
- 
-===== index.html ===== 
- 
-<file html index.html> 
-<!DOCTYPE html> 
-<html> 
-<head> 
-  <meta charset="utf-8"> 
-  <link href="main.css" rel="stylesheet"> 
-</head> 
- 
-<body> 
-  <h3>Data Parser</h3> 
-  <label>Parser ID is <input id="appid" type="text"  readonly></input></label> 
-  <div> 
-    <label for="sendId">Destination ID</label> 
-    <input id="sendId" type="text"></input> 
- 
-    <button id="saveID">Save ID</button> 
-    <button id="process">Start Process</button> 
-  </div> 
-  <div id="log"></div> 
- 
-  <script src="index.js"></script> 
-</body> 
- 
-</html> 
-</file> 
- 
- 
-===== main.css ===== 
- 
-<file css main.css> 
-input[type="text"] { 
-  width: 240px; 
-} 
- 
-#log { 
-  background-color: rgb(226, 226, 250); 
-  padding: 10px 20px; 
-  margin-top: 10px; 
-  height: 300px; 
-  border: 1px solid black; 
-  overflow-y: scroll; 
-  overflow-x: hidden; 
-} 
-</file> 
- 
- 
-===== index.js ===== 
- 
-<file javascript index.js> 
-(function(context){ 
-  document.getElementById("appid").value=chrome.runtime.id; 
-  var remoteAppID =""; 
-  var action =""; 
-  var pageIndex=null; 
-  console.log('Starting'); 
-  var sendId; 
-  sendId=document.getElementById("sendId"); 
- 
-  chrome.storage.local.get('remoteappid',function (result) { 
-    console.log(result); 
-    remoteAppID=result.remoteappid; 
-    console.log('In Loop' +remoteAppID); 
-    sendId.value=remoteAppID; 
-  }); 
- 
-  var logField = document.getElementById("log"); 
-  var save=document.getElementById("saveID"); 
-  var process=document.getElementById("process"); 
-  save.addEventListener('click', function() { 
-    var remoteID=sendId.value; 
-    appendLog("Saved"); 
-    chrome.storage.local.set({'remoteappid': remoteID}); 
-  }); 
- 
-  process.addEventListener('click', function() { 
-    pageIndex=1; 
-    chrome.tabs.query( 
-      { currentWindow: true, active: true }, 
-      function (tabArray) { 
-        var activeTabId= tabArray[0]; 
-        chrome.tabs.sendMessage(activeTabId.id, {text: 'report_back',pageIndex: pageIndex}, doStuffWithDom); 
-      } 
-    ); 
-  }); 
- 
-  function doStuffWithDom(res) { 
-    var domContent=res.domContent; 
-    var pageIndex=res.pageIndex; 
- 
-    //console.log('I received the following DOM content:\n' + domContent); 
- 
-    chrome.runtime.sendMessage( 
-      sendId.value, 
-      {myCustomMessage: JSON.stringify(domContent),myAction : "save",myIndex : pageIndex}, 
-      function(response) { 
-        appendLog("Remote Message : " + response.result); 
-        if (response.Success=="false"){ 
-          console.log("Remote Error : " + response.result); 
-          appendLog("Remote Error : " + response.result); 
-        }else{ 
-          chrome.tabs.query( 
-            { currentWindow: true, active: true }, 
-            function (tabArray) { 
-              var activeTabId= tabArray[0]; 
-              chrome.tabs.sendMessage(activeTabId.id, {text: 'process_next'},dealWithNextButton); 
-            } 
-          ); 
-          console.log(response.result); 
-          appendLog(response.result); 
-        } 
-      }) 
-    } 
- 
-    chrome.runtime.onMessageExternal.addListener( 
-      function(request, sender, sendResponse) { 
-        appendLog("Remote Message : " + request.myResultAction); 
-        if (request.result=="false"){ 
-          console.log("Remote Error : " + request.myResultAction); 
-          appendLog("Remote Error : " + request.myResultAction); 
-        }else{ 
-          chrome.tabs.query( 
-            { currentWindow: true, active: true }, 
-            function (tabArray) { 
-              var activeTabId= tabArray[0]; 
-              chrome.tabs.sendMessage(activeTabId.id, {text: 'process_next'},dealWithNextButton); 
-            } 
-          ); 
-          console.log(request.result); 
-          appendLog(request.result); 
-        } 
-      } 
-    ); 
- 
-    function dealWithNextButton(res){ 
-      var result = res.success; 
-      if (result==false){ 
-        appendLog("Finished."); 
-        pageIndex=null; 
-      }else{ 
-        appendLog("Still Processing."); 
-      } 
-    } 
- 
-    chrome.webNavigation.onDOMContentLoaded.addListener(function (details) { 
-      if (pageIndex !=null){ 
-        pageIndex+=1; 
-        chrome.tabs.query( 
-          { currentWindow: true, active: true }, 
-          function (tabArray) { 
-            var activeTabId= tabArray[0]; 
-            chrome.tabs.sendMessage(activeTabId.id, {text: 'report_back',pageIndex: pageIndex}, doStuffWithDom); 
-          } 
-        ); 
-      } 
-    } 
-  ); 
- 
-  function doInCurrentTab(tabCallback) { 
-  } 
- 
- 
-  var appendLog = function(message) { 
-    logField.innerText+="\n"+message; 
-  }; 
- 
-  context.appendLog = appendLog; 
-})(window) 
-</file> 
  
web_browsers/chrome_screen_scraper/chrome_screen_scraper.1468228752.txt.gz · Last modified: 2020/07/15 09:30 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki