Bug 1516478 Comment 5 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

**Re: API Design ideas and notes**
Few ideas for consideration (that have been discussed previously)

- Provide a per tab (tabId) `register` and `unregister` method to inject|nuke contentScript|userScript without a need to refresh the tab.
  The APIs already have the method but they are not acessible to the extension.
- Add a break|abort method to `userScripts.onBeforeScript` to prevent userScript injection
- Add Add `cssOrigin` to contentScripts API (Bug 1679997)
- Add a standard method for some forced workarounds in `userScripts.onBeforeScript` (e.g.  process callback to defined functions)
  

💡It may be feasible to merge the 2 API into a single API `browser.contentScripts.register` and instead add a flag, if it makes it easier to maintain in the long run. e.g.

```js
browser.contentScripts.register({
  matches: [hosts],
  js: [{code}],
  userScript: true,
  runAt: 'document_idle'
});
```
**Re: API Design ideas and notes**
Few ideas for consideration (that have been discussed previously)

- Provide a per tab (tabId) `register` and `unregister` method to inject|nuke contentScript|userScript without a need to refresh the tab.
  The APIs already have the method but they are not acessible to the extension.
- Add a break|abort method to `userScripts.onBeforeScript` to prevent userScript injection
- Add Add `cssOrigin` to contentScripts API (Bug 1679997)
- Add a standard method for some forced workarounds in `userScripts.onBeforeScript` (e.g.  process callback to defined functions)
  

💡It may be feasible to merge the 2 API into a single API `browser.contentScripts.register` and instead add a flag, if it makes it easier to maintain in the long run. e.g.

```js
browser.contentScripts.register({
  matches: [hosts],
  js: [{code}],
  userScript: true,
  runAt: 'document_idle'
});
```

Also ....
```js
browser.tabs.executeScript([optional tabId], {
  file: "/content-script.js",
  userscript: true,
  allFrames: true
});
```
**Re: API Design ideas and notes**
Few ideas for consideration (that have been discussed previously)

- Provide a per tab (tabId) `register` and `unregister` method to inject|nuke contentScript|userScript without a need to refresh the tab.
  The APIs already have the method but they are not acessible to the extension.
- Add a break|abort method to `userScripts.onBeforeScript` to prevent userScript injection
- Add Add `cssOrigin` to contentScripts API (Bug 1679997)
- Add a standard method for some forced workarounds in `userScripts.onBeforeScript` (e.g.  process callback to defined functions)
  

💡It may be feasible to merge the 2 API into a single API `browser.contentScripts.register` and instead add a flag, if it makes it easier to maintain in the long run. e.g.

```js
browser.contentScripts.register({
  matches: [hosts],
  js: [{code}],
  userScript: true,
  runAt: 'document_idle'
});
```

Also ....
```js
browser.tabs.executeScript([optional tabId], {
  file: "/content-script.js",
  userScript: true,
  allFrames: true
});
```
**Re: API Design ideas and notes**
Few ideas for consideration (that have been discussed previously)

- Provide a per tab (tabId) `register` and `unregister` method to inject|nuke contentScript|userScript without a need to refresh the tab.
  The APIs already have the method but they are not acessible to the extension.
- Add a break|abort method to `userScripts.onBeforeScript` to prevent userScript injection
- Add Add `cssOrigin` to contentScripts API (Bug 1679997)
- ~~Add a standard method for some forced workarounds in `userScripts.onBeforeScript` (e.g.  process callback to defined functions)~~
  

💡It may be feasible to merge the 2 API into a single API `browser.contentScripts.register` and instead add a flag, if it makes it easier to maintain in the long run. e.g.

```js
browser.contentScripts.register({
  matches: [hosts],
  js: [{code}],
  userScript: true,
  runAt: 'document_idle'
});
```

Also ....
```js
browser.tabs.executeScript([optional tabId], {
  file: "/content-script.js",
  userScript: true,
  allFrames: true
});
```

Back to Bug 1516478 Comment 5