Site rules
🌰 has similar pronounciation as
examplein Chinese
😂 I didn't finish the manual translation yet.
🇯🇵 users: I would like to provide one for you but I don't speak Japanese. PR is welcomed
Site rules can be
- JavaScript object stored in file https://github.com/machsix/Super-preloader/blob/master/src/rules/jsSiteRule.js. You need to submit pull request through Github
- JSON data stored in https://github.com/machsix/Super-preloader/blob/master/dist/mydata.json. You can add it into
Custom rulestextarea in theGlobal Settings
We prefer JSON data because JSON can implement hot update. An example is shown at the end.
The basic composition of the rules
name
- type:
StringJSJSON - description: name of the website
url
- type:
XPath StringJSJSON,XPathJS - description: regular expression to match the URL of the website
enable
- type:
BooleanOptional - default:
true - description: set to false to disable both autopager and preloader
useiframe
- type:
BooleanOptional - default:
false - description: user iframe to preload next page content and display it
exampleUrl Optional
- type:
StringJSJSON - description: example of the URL
nextLink
The script finds the URL of next page based on nextLink. We provide a variety of methods to acheive it:
XPath selector: an element that has an
hrefattribute and points to the next page or an element whose content is the URL of the next page- type:
XPath StringJSJSON,XPathJS - example:
//div[@id="nav"]/a,//div[@id="nav"]/a/@href, both equivalent
- type:
- type:
StringJSJSON - content:
css;${CSS selector} - example:
css;div#nav>a
- type:
The "auto;" the script will automatically find all
text()elements containing "next page", "next page" and allaelements withhrefattribute.- type:
StringJSJSON - content:
auto;no options
- type:
function a
JSfunction return the link of next page- type:
JS functionJS - content:
jsFunction(currentDocument, currentWindow, currentPageURL) { // **** your function is here **** Return urlOfNextPage }- type:
The Array script will iterate through all the elements and use above methods until the link of the next page link found
Object complex mode, check the function
hrefIncto learn moreJSJSON
prevLink Optional
It serves the same function as nextLink but is designed for previous page. Usually you don't need it 😂
pageElement
The script finds the elements that are joined together automatically when the page is flipped. For example 🌰 a search engine like Google, pageElement should be the searching result. We also provide different methods:
XPath selector: The
XPath selectorof the element.- type:
XPath StringJSJSON,XPathJS - example:
//div[@id="content]
- type:
- type:
StringJSJSON - content:
css;${CSS selector} - example:
css;div#content
- type:
function a function returning HTMLCollection containing the elements. One example is the rule of
WordPress. With theJSfunction we can determine whether a page is a post, if not, returnnullto jump out of the logic of the script, and if so, return the contents of the post. One more 🌰 is some comic websites, we can usepageElementto directly calculate the address of the next figure, so as to avoid loading useless content.- type:
JS functionJS - content:
jsFunction(currentDocument, currentWindow, currentPageURL) { // **** your function is here **** Return HTMLCollection }- type:
Rules enhancements
In addition to the basic elements, the rule can also contain an Object with key as autopager for enhanced functionality. autopager can contain the following key. All key are Optional
enable
- type:
BooleanJSJSON - default:
true - description: enable autopager instead of preloadeder
useiframe
- type:
BooleanJSJSON - default:
false - description: user iframe to load next page content instead of XHR
iloaded
- type:
BooleanJSJSONuseriframe: true - default:
false - description: Whether to operate after the iframe is fully loaded.. otherwise the script will start after the DOM is loaded.
itimeout
- type:
NumberJSJSONuseriframe: true - default:
0 - description: Delay when
iloadedisfalse, in milliseconds
newIframe
- type:
BooleanJSJSONuseriframe: true - default:
false - description: Whether to create a new
iframewhen flipping the current page +2, in some cases there is a miracle
reload
- type:
BooleanJSJSONuseriframe: true - default:
false - description: Force overloading of
iframe, which has some effects in some cases
force_enable
- type:
BooleanJSJSON Not Recommend - default:
false - description: If it is really difficult to find pageElement, turning this option on will make the entire page spliced up.
headers
- type:
ObjectJSJSON - default:
{ Referer: <Link of current page> } - description: Customized headers to request next page
remain
- type:
NumberJSJSON - default:
1always pre-turns a page - description: The script will decide whether to turn the page according to the remaining height of the current page.
When the remaining height<=page heightxremain
maxpage
- type:
NumberJSJSON - default:
99 - description: Maximum page views
ipages
- type:
ArrayJSJSON - default:
[false,2] - description: Turn the page immediately. The first item is to control whether the second item (must be smaller than maxpage) is turned off immediately when the script is loaded, such as
[true,3]. That is to say, after JS is loaded. . Turn 3 pages immediately. For the map station you can have: the experience of joy:
separator
- type:
BooleanJSJSON - default:
true - description: Whether to display the page navigation bar
sepdivDom
- type:
JS functionJS - description: For some pages, the navigation bar automatically added by the script may cause the page format to be garbled.
sepdivDomdefines a function to generate the appropriate navigation bar that will be inserted after the last pageElement. An example is小木虫-posts - example
Function(currentDocument, sepdiv) {
// currentDocument: read the next page of DOM
// sepdiv: the navigation bar generated by the script, the tag is div
Const td = doc.createElement("td");
td.appendChild(sepdiv);
Const tr = doc.createElement("tr");
td.setAttribute("colspan", 2);
tr.appendChild(td);
Const tbody = doc.createElement("tbody");
Return tbody;
},startFilter
- type:
JS functionJS - description: A js function that acts on the home page (i.e. current page) to fix the page. Receive
currentDocument,currentWindowtwo parameters. For details, please see documentFilter (1)
documentFilter
- JS function JS
- description: A js function for prefetching content that can be used to correct prefetched content (such as csdn), remove ads (such as many nsfw), generate page content based on XHR results, and avoid using iframes (such as bl -novel) even generate new content (like m-team). In theory, you can use js to modify the static content of DOM.
- content:
function (currentDocument, nextPageLink) {return newDocument}
- "startFilter"
- description: Reuse startFilter
scriptFilter
- type: String JSJSON
- description: The script will delete all
<script>nodes before inserting the preloaded content into the page. You can setscriptFilteras a Regex string to match thesrcor inline content of the<script>node to keep some nodes. In this way, you can use these inline js scripts in the filter. This only take effect iniframemode
filter
- JS function JS
- description: a js function to manipulate with the preloaded content once it is inserted into the page
- content:
function (pageElements) {return null}
stylish
- type:
StringJSJSON - description: [CSS Style] for fixing pages (https://www.w3schools.com/css/)
replaceE
- description: Similar to pageElement, select the
nodeto replace the navigation bar.
example
https://github.com/machsix/Super-preloader/raw/master/dist/mydata.json
