You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
#Chrome Extension Content Script Tools
1
+
#Chrome Extension Content Script Tools
2
2
3
3
The Chrome Extension APIs for interacting with tabs are great, but fall short on providing advanced tracking of tab state, change, and convenient event binding/listeners. Additionally, working with content scripts in a dynamic manner is possible but not as easy or convenient as would be ideal.
4
4
@@ -16,7 +16,7 @@ Internally, the script keeps a reference of the full set of tabs open in the bro
16
16
API
17
17
------
18
18
19
-
###.addTabChangedCallback( types, callback )
19
+
###.addTabChangedCallback( types, callback )
20
20
> This function allows you to bind a listener to change events on all tabs in the browser, including specificity for the change types you wish to listen for
21
21
22
22
> `types`_(string or array of strings)_ specific change events you wish to bind the listener to. Options include "_load_", "_close_", "_reload_", and "_hash_change_"
> This function allows you to setup advanced rules for loading resources (scripts & stylesheets) on a tab page, including callback functionality and namespace binding. You setup a group of resources and a set of matches for when those resources should be included on the page, with a callback function that's called when all resources are loaded.
36
36
37
37
> `matches` _(string, regex, function, or array of these) match conditions for determining if the resources should be loaded on the page. These can include simple strings that are matched to see if they are present in the tab URL, regexes that can match agains the tab URL, or functions that take a single parameter (tab) and return a boolean to determine if they resources should be loaded. You can mix/match these as needed for your use case. _NOTE_ that if an array of matches is provided, only 1 needs to return `true` for the content resources to be loaded.
> Execute contente resource watchers bound with _registerContentResourcesForTabUrls_ on existing tabs. This is needed because matches for the listeners are only evaluated on tab load/reload, so if you want your extensions functionality to work on existing pages right at install time you need to bind the watchers you want, then call this function.
84
84
85
85
> `namespace` _(string, optional)_ namespace of specific watchers you want to match
> This function allows you to load multiple scrips in an existing tab with various options. Under the hood it leverages [chrome.tabs.executeScript](https://developer.chrome.com/extensions/tabs#method-executeScript) but provides advanced functionality including callbacks.
97
97
98
98
> `scripts` _(string or array of strings)_ scripts you wish to load in the tab. _NOTE_ that these should be URLs relative to the extension root dir (and should all start with a leading slash). Also, array ordering is respected when the scripts are loaded on the page.
> This function loads stylesheet(s) into a specified tab.
132
132
133
133
> `stylesheets` _(string or array of strings)_ stylesheets you wish to load in the tab. _NOTE_ that these should be URLs relative to the extension root dir (and should all start with a leading slash). Also, array ordering is respected when the stylesheets are loaded on the page.
0 commit comments