Implement chrome.tabs.executeScript
This commit is contained in:
parent
db94121360
commit
31628abadc
3 changed files with 49 additions and 1 deletions
|
@ -1,6 +1,8 @@
|
|||
const {ipcRenderer} = require('electron')
|
||||
const url = require('url')
|
||||
|
||||
let nextId = 0
|
||||
|
||||
class Event {
|
||||
constructor () {
|
||||
this.listeners = []
|
||||
|
@ -113,6 +115,16 @@ exports.injectTo = function (extensionId, context) {
|
|||
}
|
||||
}
|
||||
|
||||
chrome.tabs = {
|
||||
executeScript (tabId, details, callback) {
|
||||
const requestId = ++nextId
|
||||
ipcRenderer.once(`CHROME_TABS_EXECUTESCRIPT_RESULT_${requestId}`, (event, result) => {
|
||||
callback([event.result])
|
||||
})
|
||||
ipcRenderer.send('CHROME_TABS_EXECUTESCRIPT', requestId, tabId, extensionId, details)
|
||||
}
|
||||
}
|
||||
|
||||
chrome.extension = {
|
||||
getURL: chrome.runtime.getURL
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue