Thanks for UserScripts and browser plugins/extensions which can run them, we have a solution.
There are some famous online UserScript repositories where you can share your own UserScripts and find others created by other developers as well.
Some of these online repositories are:
Browser plugins/extensions allow you to set some configurations to control which UserScript runs on which Webpage once it is loaded in your browser. A part of these configurations is set in the UserScript itself as I would show you later.
Here is a list of the most famous plugins/extensions:
Therefore, depending on the type of your Web browser you can choose the plugin which suits you needs.
What does a UserScript look like?
A UserScript most probably consists of the following.
On the header you set some fields which configure the browser plugin/extension.
name: is the name of the UserScript. This is used inside the dashboard of the browser plugin/extension so that you can identify this specific UserScript.
namespace: is used to avoid naming collisions between scripts hosted on public online repositories. If you call your script
foobar and someone else did as well, then it would be so hard telling them apart. On the example above I am setting it to my LinkedIn profile as this is unique to me.
description: is the description to appear inside the dashboard of the browser plugin/extension.
match/include: is the pattern used to match the Webpage URL on which the UserScript should run. This could accept regular expressions or wildcards. For more info about what is acceptable or not, you need to check the browser plugin/extension you are using.
require: is where you set any external JS files required for your code to run successfully. In the code above, I included
jquery-3.3.1.min.js as I am using jQuery on my code.
author: is the author of the UserScript. In the code above it is me.
Finally, I encourage you to browse the internet for UserScripts and see samples of what you can do when you unleash the power of UserScripts. Then, you can try to develop your own UserScripts and share them with others.
Hope you found reading this story as interesting as I found writing it.
This article is originally published on Development Simply Put.