How do I run custom scripts for a site in Safari?

I have created a user javascript script for one website. I would like my navigator to automatically detect when I am on this website and execute the script.

Is it possible to run the injected script only on a specific site?

+3


source to share


1 answer


Yes it is possible . Apple has written a travel guide. Pay attention to the highlighted part at the end.

Adding Script

To add the injected script, do the following:

  • Create an extension folder-open Extension Builder, click +, select New Extension, provide a name and location.
  • Drag the script file to the extension folder.
  • Click the "Generate" script under the "Injected Extension Content in Extension Builder" section, as shown in Figure 10-1:

Figure 10-1 Specifying injected content

You can inject a script as a start script or at the end of a Script. The end of the script is executed when the DOM is fully loaded - at the time when the onload attribute of the body element normally fires. Most scripts should be entered as End Scripts. The script is run when the document has been created but before the web page has been parsed. If your script is blocking unwanted content, it must be a "Start" script, so it is executed before the page is rendered.

Select your script file from the popup menu. You can have start and end scripts. You can have more than one script for each type.

In order for your scripts to be entered, you must specify either access for some or all of the websites for your extension. ... You can use your script for one web page, all web pages, or just for example some web pages from specific domains. For more information, see the description of whitelisting and blacklisting in Access and Permissions .



From this last link ( this one ), this is the important picture:

extension website access

This is what you want to use on blacklist / whitelist sites.

+7


source







All Articles