diff options
Diffstat (limited to '2015_locomotivebrowser/chrome/locomotive.js')
-rw-r--r-- | 2015_locomotivebrowser/chrome/locomotive.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/2015_locomotivebrowser/chrome/locomotive.js b/2015_locomotivebrowser/chrome/locomotive.js new file mode 100644 index 0000000..76b7e3c --- /dev/null +++ b/2015_locomotivebrowser/chrome/locomotive.js @@ -0,0 +1,30 @@ +document.addEventListener('DOMContentLoaded', init); + +function init(){ + var elem = document.getElementById('start'); + elem.addEventListener('click',func); + var elem2 = document.getElementById('stop'); + elem2.addEventListener('click',func2); +} + +var first = true; + +function func(){ + if(first == true){ + chrome.tabs.query({active: true, currentWindow: true}, function(tabs) { + chrome.tabs.executeScript(null, {file:"jquery.js"}); + chrome.tabs.executeScript(null, {file:"script.js"}); + }); + first = false; + } + chrome.tabs.query({active: true, currentWindow: true}, function(tabs) { + chrome.tabs.sendMessage(tabs[0].id, { greeting: "start" }); + }); +} +function func2(){ + chrome.tabs.query({active: true, currentWindow: true}, function(tabs) { + chrome.tabs.sendMessage(tabs[0].id, { greeting: "stop" }); + }); +} + + |