The design of all of these userscripts follows these general principles:
-
Preform simple, static DOM transformations/manipulations as much as possible to achieve the desired result.
-
Preform the smallest possible number of operations to achieve the desired result.
-
Refer to the site's original DOM elements in the most explicit, unambiguous and specific way possible.
-
If dynamic manipulation is necessary, use a
MutationObserver
for that, but still try to follow 2 and 3 as much as possible. -
Do as little as possible with the
MutationObserver
, and disconnect it as soon as (or, if it is) possible.
- For variable declaration,
const
is preferred tolet
which is preferred over everything else. - Arrow function syntax is used whenever possible.
"use strict";
is always used.
Clicking the buttons simply appends site:example.com
to the search query and repeats the search.
-
A mutation observer is set up to run a function that adds the search buttons to the target menu when that menu is shown.
-
The function that adds the custom search buttons simply adds to said menu some labels with links. These links have appropriately set query parameters to make it so that the result of pressing them is repeating the search with
site:example.com
appended to the search query.Since the mutation observer's code only needs to be run once, the observer is disconnected after its first run.
This works very similarly to the previous script.
Same as above.
-
A function is called to remove any elements we don't find useful.
This is best done as the very first step, since it potentially simplifies the remaining logic.
-
A function is called to add the "Utils" column to any "torrent table" that is displayed after the document has loaded.
If a page does not contain such a table, the function does nothing.
-
A function is called to split the catalog buttons.
This is applicable in every page, and need not be done exactly at this time.
-
A function is called to expand the
mediainfo
,files
, andnfo
detail sections in torrent detail pages.In other pages, this function does nothing.
-
A mutation observer is set up to call the function that adds the "Utils" column to torrent tables whenever torrent tables are shown in "TV browser pages".