initial draft

This commit is contained in:
Tobias Miesel
2018-10-14 13:47:59 +02:00
committed by Manuel Bouza
parent 8ff93423af
commit c163c23e7e
20 changed files with 25116 additions and 4370 deletions

21
src/js/background.js Normal file
View File

@@ -0,0 +1,21 @@
import DomainCheck from './services/DomainCheck'
chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
// inject files only after the page is fully loaded
if (changeInfo.status != 'complete') return
// inject files only for supported websites
const domainCheck = new DomainCheck(tab.url)
if (!domainCheck.hasMatch) return
// inject css + js
chrome.tabs.insertCSS(tabId, {file: "/styles.css"}, () => {
chrome.tabs.executeScript(tabId, {
code: "const div = document.createElement('div'); div.setAttribute('id', 'moco'); document.body.appendChild(div)"
}, () => {
chrome.tabs.executeScript(tabId, {file: "/popup.js"}, () => {
console.log("inejected /popup.js")
})
})
})
})