child script
If the site blocks code eval, you can create a child script and expose functions under window.
Example 1: Single rule for current site
// ==UserScript==
// @name Rule for Pagetual
// @namespace hoothin
// @version 0.1
// @author You
// @match https://www.xxx.win/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
window.pagetualRule = {
name: "xxx",
pageElement: "#post-list > .card",
lazyImgSrc: "file",
css: "img.sl_lazyimg{opacity:1}",
pageAction: (doc, eles) => {
eles.forEach(ele => {
let img = ele.querySelector('img');
img.classList.remove('sl_lazyimg')
})
}
}
})();
You can omit url for a single rule because the script already includes filtering.
Example 2: Rules collection for multiple sites
// ==UserScript==
// @name Rules collection for Pagetual
// @namespace hoothin
// @version 0.1
// @author You
// @match *://*/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
window.pagetualRules = [
{
name: "xxx",
url: "^https://www\\.xxx\\.",
pageElement: "#post-list > .card",
lazyImgSrc: "file",
css: "img.sl_lazyimg{opacity:1}",
pageAction: (doc, eles) => {
eles.forEach(ele => {
let img = ele.querySelector('img');
img.classList.remove('sl_lazyimg')
})
}
},
{
name: "yyy",
url: "^http://yyy\\.",
pageElement: "#main > li",
pageAction: (doc, eles) => {
eles.forEach(ele => {
let img = ele.querySelector('img');
img.classList.remove('lazy')
})
}
}
]
})();