Regarding the use of the property `"g"` (for gallery rules)
See original GitHub issueGreetings
For reference, the relevant lines the script are from line 933 to 974.
This property was not documented by the original MPIV author in his How to add more rules so I had asked a lot time ago in the greasyfork page https://greasyfork.org/en/forum/discussion/4551/x and someone had kindly described me the following:
Click to expand
kuehlschrank Probably didn’t get the time to do that so until then I’ll tell you few things I picked, mostly from wOxxOm :
"g"
rule is similar to"q"
rule plus the ability to return multiple photos- Have the variable text (raw HTTP response / source code of HTML page)
- Also you can manage to have the other two variables
node
anddoc
* *(Firefox only)Methods
Simple selectors
"g":{"entry":".main","title":".h1","caption":".info","image":".photo","fix":"return s"}
"entry"
: used to select main blocks that contain the photos and their captions"title"
: (pick text) would show up on the first photo"caption"
: (pick text) for each photo"image"
: photos"fix"
: used to clean the outputAll are optional except
"image"
Using array
"g":"g=[]; r=/regex/g; while(m=r.exec(text)) g.push({url:m}); return g"}
- Creating a regex and have it run on variable text then push photos to
g
On Firefox you can create a doc of the raw text doc=createDoc(text) to select from it by
doc.querySelector('')
Are the above still valid in this fork?
And, I have some more questions:
- He said that this
"g"
rule is similar to"q"
rule. Does this mean that this"g"
property is only applied to the remote page? Can we not use it in the currently loaded page, if it’s a gallery itself and contains all the next/previous full image URLs ? If yes, can this be done via the “array” syntax:"g":"g=[]; r=/regex/g; while(m=r.exec(text)) g.push({url:m}); return g"}
? - in the “simpler” syntax:
what is the{"d": "example.com", "g": { "entry": ".main", "title": ".h1", "caption": ".info", "image": ".photo", "fix": "return s" } }
s
in"fix"
? And, the"entry"
selector refers to the initial page holding the gallery thumbnail, while the"image"
selector, refers to the remote page? - Can I use
node
(element that triggered popup) anddoc
(dom tree of remote page) ? How? Is it still Firefox only?
Thank you
PS. Sorry for the lengthy post!
Issue Analytics
- State:
- Created 3 years ago
- Comments:43 (21 by maintainers)
Top GitHub Comments
You need to make
g
a function for MPIV so it’d be something likerule.g = "var g=.......; return g"
I’ve updated mpiv and now you can write it like this:
This works only if
index
is set to a URL that exactly equals to one of the items so in a more generic case you would have to determine the index using the standard JS array methods or any other means.