Site rules

🌰 has similar pronounciation as example in 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

We prefer JSON dataopen in new window because JSON can implement hot update. An example is shown at the end.

The basic composition of the rules

name

  • type: String JSJSON
  • description: name of the website

url

  • type: XPath StringJSJSON, XPathJS
  • description: regular expression to match the URL of the website

enable

  • type: Boolean Optional
  • default: true
  • description: set to false to disable both autopager and preloader

useiframe

  • type: Boolean Optional
  • default: false
  • description: user iframe to preload next page content and display it

exampleUrl Optional

  • type: String JSJSON
  • description: example of the URL

The script finds the URL of next page based on nextLink. We provide a variety of methods to acheive it:

  1. XPath selectoropen in new window: an element that has an href attribute and points to the next page or an element whose content is the URL of the next page

    • type: XPath String JSJSON, XPath JS
    • example: //div[@id="nav"]/a, //div[@id="nav"]/a/@href, both equivalent
  2. CSS selectoropen in new window

    • type: String JSJSON
    • content: css;${CSS selector}
    • example: css;div#nav>a
  3. The "auto;" the script will automatically find all text() elements containing "next page", "next page" and all a elements with href attribute.

    • type: String JSJSON
    • content: auto; no options
  4. function a JS function return the link of next page

    • type: JS function JS
    • content:
    Function(currentDocument, currentWindow, currentPageURL) {
      // **** your function is here ****
      Return urlOfNextPage
    }
    
  5. The Array script will iterate through all the elements and use above methods until the link of the next page link found

  6. Object complex mode, check the function hrefInc to learn moreJSJSON

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:

  1. XPath selectoropen in new window: The XPath selector of the element.

    • type: XPath String JSJSON, XPath JS
    • example: //div[@id="content]
  2. CSS selectoropen in new window

    • type: String JSJSON
    • content: css;${CSS selector}
    • example: css;div#content
  3. function a function returning HTMLCollectionopen in new window containing the elements. One example is the rule of WordPress. With the JS function we can determine whether a page is a post, if not, return null to 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 use pageElement to directly calculate the address of the next figure, so as to avoid loading useless content.

    • type: JS function JS
    • content:
    Function(currentDocument, currentWindow, currentPageURL) {
      // **** your function is here ****
      Return HTMLCollection
    }
    

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: Boolean JSJSON
  • default: true
  • description: enable autopager instead of preloadeder

useiframe

  • type: Boolean JSJSON
  • default: false
  • description: user iframe to load next page content instead of XHRopen in new window

iloaded

  • type: Boolean JSJSONuseriframe: 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: Number JSJSONuseriframe: true
  • default: 0
  • description: Delay when iloaded is false, in milliseconds

newIframe

  • type: Boolean JSJSONuseriframe: true
  • default: false
  • description: Whether to create a new iframe when flipping the current page +2, in some cases there is a miracle

reload

  • type: Boolean JSJSONuseriframe: true
  • default: false
  • description: Force overloading of iframe, which has some effects in some cases

force_enable

  • type: Boolean JSJSON 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: Object JSJSON
  • default: { Referer: <Link of current page> }
  • description: Customized headers to request next page

remain

  • type: Number JSJSON
  • default: 1 always 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 height x remain

maxpage

  • type: Number JSJSON
  • default: 99
  • description: Maximum page views

ipages

  • type: Array JSJSON
  • 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: Boolean JSJSON
  • default: true
  • description: Whether to display the page navigation bar

sepdivDom

  • type: JS function JS
  • description: For some pages, the navigation bar automatically added by the script may cause the page format to be garbled. sepdivDom defines 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 function JS
  • description: A js function that acts on the home page (i.e. current page) to fix the page. Receive currentDocument, currentWindow two parameters. For details, please see documentFilter (1)

documentFilter

  1. 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}
  2. "startFilter"

scriptFilter

  • type: String JSJSON
  • description: The script will delete all <script> nodes before inserting the preloaded content into the page. You can set scriptFilter as a Regex string to match the src or 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 in iframe mode

filter

  1. 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: String JSJSON
  • description: [CSS Style] for fixing pages (https://www.w3schools.com/css/)

replaceE

  • description: Similar to pageElement, select the node to replace the navigation bar.

example

https://github.com/machsix/Super-preloader/raw/master/dist/mydata.jsonopen in new window