-
Notifications
You must be signed in to change notification settings - Fork 2
Home
Пример интеграции с другими скриптами:
Scripts integration example:
Новый метод (первый - отдельный скрипт, второй в поле jsPatch в менеджере SITEINFO):
Newer method (first separate script secod using jsPatch in SITEINFO manager):
// ==UserScript==
// @include https://example.com/*
// ==/UserScript==
function handleNewPageLoad(event) {
/* your code parsing event.detail.url or event.detail.htmlDoc or neither but before page appending*/
}
document.addEventListener('AutoPatchWork.load', handleNewPageLoad, false);
document.addEventListener('AutoPatchWork.pageloaded', function (event) { siteObject.loadThumbnails(); }, false);
Формат своих паттернов аналогичен оригинальному массиву SITEINFO в JSON:
Custom patterns are in JSON format that's similar to original SITEINFO array:
[
...
{
"pageElement":"id('test')/div[2]/table//tr",
"removeElement":"//nav[contains(concat(' ', @class, ' '), ' advertis ')]",
"url":"^http://test\\.net/(pages|catalog)/",
"nextLink":"//div[@class='test-pager']/a[text()='\\u00bb' or contains(., 'Next')]",
"prevLink":"//div[@class='test-pager']/a[contains(text(), 'Previous')]",
"alternatively_to_nextLink_-_nextMask": "http://test.net/pages/|1",
"disableSeparator":"true",
"forceAddressChange_comment":"this parameter inverts extension's global setting",
"forceAddressChange":true,
"forceIframe":false,
"paused": true,
"id": "1000000009",
"id_comment": "unique id is required for paused/reversed to work",
"reversed": true,
"cssPatch": ".page img { min-height:500px; }",
"jsPatch": "document.addEventListener('AutoPatchWork.pageloaded', function (event) { updThumbs(); }, false);"
},
...
]
All element path queries allow CSS selectors in them instead of XPath.
Q: Some site is not working, what to do?
A: Check if SITEINFO database accessible from the provided DB URLs then verify if rule for the site is present in it and that the rule is correct for the current version of the site.
Q: Why there are multiple URL access permissions in the manifest
file?
A: All of those sites are possible sources of SITEINFO database with the autopager patterns. They were added in case one of the sources goes offline. You can remove unused ones as well as clipboardWrite
manually without losing any actual functionality.
Q: cssPatch
and especially jsPatch
look insecure if taken from wedata database, aren't they?
A: Those SITEINFO fields are local! They are filtered out when updating local database from remote one so there is no security threat of 3rd party code unless you add the insecure code by yourself. cssPatch
/Stylish
field retrieval is local only by default but it can be allowed from remote from the extension's Options. If jsPatch
field is updated from a remote database (wedata or other) it is a bug, please report it.