Last active
          December 23, 2016 20:42 
        
      - 
      
- 
        Save hbt/fea81ed6001f28c87825731236ba7614 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // snippet to inject js code using chrome | |
| // gg.js | |
| // file should be in chrome directory to be accessed via extension | |
| Post({ | |
| action: "Tab.loadCustomJS3" | |
| }); | |
| // goes in main.js | |
| Post({ | |
| action: "Tab.loadCustomJS3" | |
| }); | |
| // goes in tab.js | |
| loadCustomJS3: function() { | |
| console.log('js3') | |
| }, | |
| loadCustomJS2: function() { | |
| // | |
| console.log('js2') | |
| var tab = arguments[arguments.length - 1]; | |
| chrome.tabs.executeScript(tab.id, { | |
| //code: "console.log('mm')", | |
| file: "gg.js" | |
| }) | |
| // | |
| // window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem; | |
| //window.requestFileSystem(window.TEMPORARY, 5*1024*1024, function(fs) { | |
| // fs.root.getFile("test.txt", {create: true}, function(e) { | |
| // console.log(e) | |
| // var fileEntry = e; | |
| // fileEntry.createWriter(function(fileWriter) { | |
| // fileWriter.onwriteend = function(e) { | |
| // console.log("Write successfully") | |
| // }; | |
| // fileWriter.onerror = function(e) { | |
| // console.log("Write error!") | |
| // }; | |
| // //content = base64ToBinary(imgUrl); | |
| // var bob = new Blob(["asd"]); | |
| // fileWriter.write(bob); | |
| // }); | |
| // }, function(ee) { | |
| // console.log(ee) | |
| // }) | |
| //}); | |
| // | |
| // | |
| // // var tab = arguments[arguments.length - 1]; | |
| // //chrome.tabs.highlight({ | |
| // // tabs: [0,2,3] | |
| // //}, function(){ | |
| // // | |
| // //}) | |
| // // | |
| // // | |
| // //chrome.tabs.query({ | |
| // // highlighted: true | |
| // //}, function (tabs) { | |
| // // console.log(tabs) | |
| // //}) | |
| // // | |
| // //chrome.tabs.captureVisibleTab(null, null, function(data){ | |
| // // //console.log(data) | |
| // // | |
| // // localStorage['data'] = data; | |
| // // chrome.runtime.getPackageDirectoryEntry(function(dir){ | |
| // // window.dir = dir; | |
| // // | |
| // // //dir.getFile('test.txt', {create: true}, function(e) { | |
| // // // console.log(e) | |
| // // //}, function(err) { | |
| // // // console.log(err) | |
| // // //}) | |
| // // | |
| // // //var reader = dir.createReader().readEntries(function(entries){ | |
| // // // _.each(entries, function(entry){ | |
| // // // console.log(entry) | |
| // // // }) | |
| // // //}) | |
| // // | |
| // // console.log(dir) | |
| // //}); | |
| // // | |
| // //}) | |
| // // | |
| }, | |
| loadCustomJS: function() { | |
| // console.log('hhjs') | |
| // var tab = arguments[arguments.length - 1]; | |
| //if(tab.id) | |
| //{ | |
| // console.log(tab) | |
| // | |
| // console.log('nnaaa') | |
| // | |
| // chrome.runtime.getPackageDirectoryEntry(function(dir){ | |
| // window.dir = dir; | |
| // var reader = dir.createReader().readEntries(function(entries){ | |
| // _.each(entries, function(entry){ | |
| // console.log(entry) | |
| // }) | |
| // }) | |
| // console.log(dir) | |
| // }); | |
| // //chrome.runtime.getUrl('gg.js') | |
| // | |
| // chrome.tabs.executeScript(tab.id, { | |
| // //code: "console.log('mm')", | |
| // file: "gg.js" | |
| // | |
| // | |
| // }) | |
| //} | |
| // | |
| // chrome.tabs.getCurrent(function(tab){ | |
| // console.log(tab) | |
| // }); | |
| } | |
| }; | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment