-
Notifications
You must be signed in to change notification settings - Fork 19
Activation and Prioritization
Infy Scroll can activate itself in a variety of ways because it supports multiple collections of URLs. Here's how you can tell how Infy activated itself and how it prioritizes the order of the collections and URLs in order to choose which one to activate on.
When you click on the toolbar icon, the UI Window will open, and if Infy has already activated itself, it will open in a minimal view as shown below. In the top-right corner, an icon indicates how it activated:
- A star icon indicates that it's from one of your saves
- A database icon indicates that it's from one of the databases
Save Activation Example (Star Icon)
Database Activation Example (Database Icon)
You can hover over the icon and see more information, such as the URL pattern, and if it's a save, its numerical ID (which allows you to identify it in the Options screen). If it's a database icon, you can also click on it to open a new tab that takes you to the original database website where you can see all its details in full view. Also note that if it's a Database URL, you'll always see a Blacklist/Whitelist button next to the Power button, allowing you to blacklist/whitelist it in one click.
If the UI Window opens in the full Setup view (or if you click the Pencil Icon), a message will appear at the bottom telling you what type of URL (Save or Database) it found and is prepared to activate itself on.
Infy checks the following collections in this order until it finds a match for the current URL:
- Saves
- InfyScroll Database
- AutoPagerize Database
In other words, Saved URLs have higher priority over Database URLs. This essentially allows you to override a Database URL with your own Saved URL, even if they both have the same exact URL pattern.
URLs inside each collection are sorted and checked by their length, with the longest URLs being checked first. This allows Infy to prioritize URLs based on how specific (or long) they are. This strategy also helps to ensure that the Generic Database URL patterns (for example, ^https?://.
) are checked last since they tend to have the shortest URL length.
If multiple saves have the same URL length, then they are sorted by ID from lowest to highest as a tie-breaker.
In order for Infy to activate itself (turn itself on), there's essentially three tests that need to pass validation:
- The URL pattern must match the URL you're on
- The action settings must validate
- The append mode settings must validate
For example, if the action is next
, then a next link must be found on the page. If the append mode is element
, then the page must have the specified page elements on the page.
However, it should be noted that certain actions and append modes don't have any settings that require any validation; for example, the list
action and page
, iframe
, media
, and none
append modes don't require validation on their settings.
If a website matches one of your saves by its URL pattern, but fails to match by its action or append mode settings (for example, the site got redesigned and the next link path changed), Infy will still recognize that save and try to at least bring it up for you in the UI Window so you can edit it to make it work again.
There's one "small" exception to this recognition rule: URL patterns that are 13 characters or smaller will never be recognized in the UI Window because those are assumed to be generic URL patterns and would otherwise always be recognized on every new URL you try to save. In order to provide a balanced approach for recognition, if you have shorter generic URL patterns, you should edit them in the Options screen if you need to make changes.
When possible, Saves use the same keys as Database items. For example, nextLink
, pageElement
, and url
are used by the Databases and are also the same keys used by Saves. The main difference between the two is that Save keys are all flat in one level (see below example), whereas the database items use a data
sub-object/key that contains the main properties. Saves and Database items may contain keys that are different from one another as shown below as well.
Example of a Database item:
{
"database_resource_url": "http://wedata.net/databases/AutoPagerize",
"name": "My Database Item",
"created_by": "infy",
"created_at": "2020-01-01T00:00:00+00:00",
"updated_at": "2020-01-01T00:00:00+00:00",
"resource_url": "http://wedata.net/items/1",
"data": {
"nextLink": "//*[@rel='next']",
"pageElement": "//body/*",
"url": "^https://www\\.example\\.com"
}
}
Here's an example of a Save:
{
"id": 1,
"name": "My Save",
"date": "2020-01-01T00:00:00.000Z",
"action": "next",
"append": "element",
"nextLink": "//*[@rel='next']",
"pageElement": "//body/*",
"url": "^https://www\\.example\\.com"
}
To keep things consistent, and to make it possible to literally copy/paste a database item into your saves, Infy internally converts and stores database items the same way as saves are stored: as a one-level flattened JSON object (removing the data
sub-object/key).