simple userscript engine aimed at power users

Add-ons for Pale Moon and other applications
General discussion, compatibility, contributed extensions, themes, plugins, and more.

Moderators: FranklinDM, Lootyhoof

User avatar
ketmar
Lunatic
Lunatic
Posts: 369
Joined: 2015-07-28, 11:10
Location: Earth

simple userscript engine aimed at power users

Unread post by ketmar » 2015-07-28, 15:51

WE ARE AT addons.palemoon.org NOW!
right here


here you can find the userscript engine, somewhat similar to GreaseMonkey and Scriptish. it named Guerilla Script (sorry for one "r" — sadly, it stuck now ;-).

what makes this different from GM and Scriptish? Guerilla Script was written with knowledgeable power user in mind, a user who has some js knowledge and want to write his/her userscripts without going thru GM interface of script management.

the idea was taken from Opera 12, where you can simply copy your userscript in userscript directory, and it will be immediately ready for use. or you can simply delete/change file extension with your file manager, and that script will not be available anymore.

please note that this is not a rip-off/fork/cleanup of GM or Scriptish (although i used some code from those addons to provide the similar GM_* API, and somewhat similar behavior), this is completely independent project.

also, PLEASE, PLEASE, PLEASE don't install GS without fully understanding it's README file first! while simply installing GS will certainly not do any harm to your browser or computer, and will not in any way violate your privacy, the addon is aimed to power users, and trying to add userscripts without full understanding of consequences CAN be harmful. actually, i don't think that you will be able to add any userscript at all if you didn't read and understand README in all it's glory, ;-) as addon has absolutely no GUI (it was designed like this from the start, it's not something that was overlooked or postponed).

if you already installed GS, and want to consult it's README (don't panic, nothing was broken yet!), you can do this by pressing shift+f2 to bring gcli command line, and type
guerilla about readme
there. browser will open a page with README for you.

feel free to ask me any questions — sometimes i even know what to answer.

GIT repository: http://repo.or.cz/w/guerillascript.git

WE ARE AT addons.palemoon.org NOW!
right here

=== changelog ===
0.0.3.5:
• hello, APMO!
• GS now have inline options page, where you can change alot of options, all three of them.

=== changelog ===
0.0.3.3:
• not beta anymore. no bug reports — no betas. ;-)
• GS now can be installed via internets, and it should update itself via internets too, if installed as such (see below).

=== changelog ===
0.0.3.2-beta:
• fixed major issue with multiple browser windows (everything was broken, heh...)

=== changelog ===
0.0.3.1-beta:
• GS is not restartless anymore. 'cmon, it never works properly!

=== changelog ===
0.0.3.0-beta:
• simple package manager (see README for details)
• GM_getResourceText() and GM_getResourceURL() should work for package scripts
known bugs:
• still not handling addon disable/enable properly, browser restart required
• XHR content updates not detected, so no injection on pjaxed pages

=== changelog ===
0.0.2.2-beta:
• new commands: "guerilla new" and "guerilla edit"
• GM_openInTab() now works (and has even more features than in GM)
• stubbed unimplemented GM API functions, so scripts will not fail
• added "@disabled" meta to disable scripts
• added THANKS file ;-)
• tested with current Goanna branch, everythings seems to work as expected
known bugs:
• still not handling addon disable/enable properly, browser restart required
• XHR content updates not detected, so no injection on pjaxed pages


good luck, and happy hacking!
Attachments
README.txt
READ ME FIRST, PLEASE! ;-)
(7.08 KiB) Downloaded 184 times
Last edited by ketmar on 2015-08-31, 06:50, edited 23 times in total.

squarefractal

Re: simple userscript engine aimed at power users

Unread post by squarefractal » 2015-07-28, 17:42

A fully PM-targeted userscript manager? Should be interesting... I will test this when I get some free time on my hands.

Edit: I tried Github Comment Enhancer with this, and it doesn't seem to have any effect :(

User avatar
ketmar
Lunatic
Lunatic
Posts: 369
Joined: 2015-07-28, 11:10
Location: Earth

Re: simple userscript engine aimed at power users

Unread post by ketmar » 2015-07-29, 03:52

squarefractal wrote:A fully PM-targeted userscript manager?
it's more like "userscript executor" than manager. ;-) it relies management tasks to the user.
squarefractal wrote:Edit: I tried Github Comment Enhancer with this, and it doesn't seem to have any effect :(
could you please provide a link to non-working script? GS is not fully compatible with GreaseMonkey, and if userscript relies on external libraries (like @requiring jquery, for example), there is nothing i can do except manually fixing the userscript, as GS cannot load script parts from internet. but if userscript simply relies on some missing API, i may be able to fix GS.

User avatar
ketmar
Lunatic
Lunatic
Posts: 369
Joined: 2015-07-28, 11:10
Location: Earth

Re: simple userscript engine aimed at power users

Unread post by ketmar » 2015-07-29, 05:20

squarefractal wrote:Edit: I tried Github Comment Enhancer with this, and it doesn't seem to have any effect :(
ok, i checked that script and found two issues with GS. first, the script is using "@grant none", which means "this script is unwrapped". that was easy, and i added processing of this case in GS.

the second is harder, as github seems to change pages with javascript, and when i click on issue in issue list, for example, page is not reloaded and GS isn't injecting the script. yet refresing the page with comment box with F5 afterwards should work.

sorry, i can't check if script is really does something, as i have no github account.

i updated the .xpi in the first post, please, try it if you are still interested.

squarefractal

Re: simple userscript engine aimed at power users

Unread post by squarefractal » 2015-07-29, 14:26

I tried a number of userscripts with the updated version as well:
  • Github Comment Enhancer does not often work, since the requests are often made through XHRs. But it does work with when the page is reloaded.
  • TS Blogger NCR works as expected.
  • Google Hit Hider isn't able to show the "block" button when the search request happens through XHR.
  • Online Docs Viewer also seems to work as expected. It might have the same issue as with XHR requests, I've not tested it thoroughly.
  • AntiAdware also fails to block the dynamically generated elements on d-h.st file download pages.
You can find the userscripts in the attachment below.
Attachments
userscripts.zip
(75.03 KiB) Downloaded 90 times

User avatar
ketmar
Lunatic
Lunatic
Posts: 369
Joined: 2015-07-28, 11:10
Location: Earth

Re: simple userscript engine aimed at power users

Unread post by ketmar » 2015-07-29, 15:49

thank you for testing, i'll take a look at the scripts. i don't know if i'll be able to intercept XHR requests for new pages, though — it should be possible, but i don't know yet how to do that. if someone has code snippet or some links to read, i'll be very grateful.

for now, i added "guerilla edit <filename>" and "guerilla new <filename>" commands to gcli, but i'll delay the update for some time to check if i can fix GS to run the given scripts correctly.

squarefractal

Re: simple userscript engine aimed at power users

Unread post by squarefractal » 2015-07-29, 16:05

BTW, you may want to contact Tobin about uploading your extension to addons.palemoon.org.

User avatar
ketmar
Lunatic
Lunatic
Posts: 369
Joined: 2015-07-28, 11:10
Location: Earth

Re: simple userscript engine aimed at power users

Unread post by ketmar » 2015-07-29, 16:20

it should get some more developement and user feedback before i consider it ready to uploading, that's why i created a topic here first. i don't want to trash palemoon addons site with half-working thing, which updates every day. after all, it's only three days old now! ;-)

and it needs a nice icon, as current one is "programmer art" in all it's glory.

at least i want to fix XHR issue first. i'm browsing mostly with js disabled, so it doesn't annoy me, but i don't think that other people will agree to adopt my browsing habits. ;-)

squarefractal

Re: simple userscript engine aimed at power users

Unread post by squarefractal » 2015-07-29, 16:26

BTW, since you are adding support for a few commands, why not add a command like: guerilla-get install {name} {url}, guerilla-get remove {name}, and guerilla-get update. Sorry, but I just love apt-get a bit too much ;)

You may also want to remove the "no internet connection" requirement. I guess many scripts will be broken if you're not doing anything with @require, which are often used to use jquery and such.

User avatar
ketmar
Lunatic
Lunatic
Posts: 369
Joined: 2015-07-28, 11:10
Location: Earth

Re: simple userscript engine aimed at power users

Unread post by ketmar » 2015-07-29, 17:31

GS is not a drop-in GM replacement, and it's @require is completely different too, no matter how hard one will try to write "https://example.com/myjs.js". ;-)

scripts that wants libraries from internet should be modified, and that's where "@library" meta comes into play. first user should download the necessary library and put it into "./libs/", and then change "@required" to "@library" in the script. i really don't want any automatic downloading of anything.

yet the idea of "install/remove/update" looks interesting. i may add that, along with automatic downloading of all libraries and fixing userscript headers, so "guerilla install {name} {url}" will download the userscript, all it's "@requires" things and autofix it to work with GS, rewriting the metas. as this command can be invoked only by user, i see no harm in adding that. "no interntets" doesn't mean that user can't ask to download something — our user is Knowledgeable Power User after all! ;-)

so thank you for your suggestion, i likely will implement some sort of it.

for now i see that some scipts doesn't request any @grants, and that may be an issue: GS will sandbox such scripts, while GM seems to unwrap 'em. i have mixed feelings about that, as my userscripts ported from opera doesn't have any @grant, yet i still want them to be sandboxed.

also, does github comment enhancer get injected on pjaxed pages in GM? from my observations, GM shouldn't run it without page reloading too, as i found no pjax workarounds in GM. but then maybe i simply missed it. ;-)

Axiomatic

Re: simple userscript engine aimed at power users

Unread post by Axiomatic » 2015-07-29, 22:54

This add-on is quite neat, I got most of my UserScripts to work with GS, with minimal editing. ^_^ However for one UserScript, it does not work. Due to its reliance on GM_openInTab, and I cannot figure out another way to do what it is doing.

When you say, "automatic downloading of all libraries" do you mean that, @library will act like, the meta @resource?

User avatar
ketmar
Lunatic
Lunatic
Posts: 369
Joined: 2015-07-28, 11:10
Location: Earth

Re: simple userscript engine aimed at power users

Unread post by ketmar » 2015-07-30, 05:12

>This add-on is quite neat, I got most of my UserScripts to work with GS, with minimal
>editing.

thank you, i'm glad to read that. ;-)

>Due to its reliance on GM_openInTab, and I cannot figure out another way to do what
>it is doing.

i'm not using this myself, so i made a stub for it to implement it later. i'll add it in next update, which i'm planning to upload today.

>When you say, «automatic downloading of all libraries» do you mean that, @library
>will act like, the meta @resource?

no. i mean that «guerilla pkg install» will download all the necessary files, copy files to appropriate directories and fix userscript to work correctly with GS. i.e. mostly automating the trivial things for user. but no further automatic downloads or updates will be done until user manually runs «guerilla pkg update».


p.s. current difference between "@require" and "@library" is loading order (libs first) and search path (lib path is not really hardcoded ;-), otherwise they works the same. i'm not planning to alter or extend that logic, as i believe that it is "good enough" (read: it suits my workflow ;-).

squarefractal

Re: simple userscript engine aimed at power users

Unread post by squarefractal » 2015-07-30, 06:30

ketmar wrote:i likely will implement some sort of it.
Looking forward to the implementation :)
ketmar wrote:does github comment enhancer get injected on pjaxed pages in GM?
Firefox Nightly + GM 3.3 performs the injection on pages loaded with AJAX. I have to do some more testing with PM and GM; version 3.2 does not seem to inject. However, do note that Google Hit Hider seems to work as expected with on PM, although it's mechanism may be fundamentally different than Github Comment Enhancer.

EDIT: Version 3.3 can't even be installed in Pale Moon. The installation always errors out with "unable to modify the needed file".

User avatar
ketmar
Lunatic
Lunatic
Posts: 369
Joined: 2015-07-28, 11:10
Location: Earth

Re: simple userscript engine aimed at power users

Unread post by ketmar » 2015-07-30, 06:44

>Looking forward to the implementation :)
this may take some time, though, so don't expect it to arrive tomorrow. ;-)

>Firefox Nightly + GM 3.3 performs the injection on pages loaded with AJAX.
hm. i'll try to find what they did there. for now i have some thoughts on how to intercept pjax queries (by hijacking some jQuery functions), and i'll try to implement it as a last resort if nothing else will work. but maybe there is a better way.

>do note that Google Hit Hider seems to work as expected with on PM
that userscript is using `GM_registerMenuCommand()` API, which neither implemented nor stubbed in GS, so script simply fails to compile, and i'm still not sure if i want to implement that API. i'll add noop stubs, though, so scripts that using unimplemented API can still work, at least partially.

User avatar
ketmar
Lunatic
Lunatic
Posts: 369
Joined: 2015-07-28, 11:10
Location: Earth

Re: simple userscript engine aimed at power users

Unread post by ketmar » 2015-07-30, 08:34

i uploaded a new version with some fixes. no XHR fix yet, sorry: i'm still investigating the possible solutions.

Axiomatic

Re: simple userscript engine aimed at power users

Unread post by Axiomatic » 2015-07-30, 21:03

Unsure if this is related to the update, or something else. Anyway let me describe the issue before I ramble. :-P When I tested Guerilla Script, I was running on a Microsoft Windows machine. Today when I tried installing Guerilla Script, on my Linux/OpenBSD machine, I came across the issue that none of my UserScripts worked. I am not sure whether it is related to the update, or the operating system. When I have some time I will check to see if it is related to the update, by installing the newer XPI on my Microsoft Windows machine, and see if my UserScripts still run. (Sorry I could not provide more information, when I have more time I will. ^_^)

Side note:
A UserScript that I used on Microsoft Windows that worked out of the box was:
YouTube Center: https://github.com/YePpHa/YouTubeCenter ... er.user.js

Perhaps try it, and see if it works for you?

User avatar
ketmar
Lunatic
Lunatic
Posts: 369
Joined: 2015-07-28, 11:10
Location: Earth

Re: simple userscript engine aimed at power users

Unread post by ketmar » 2015-07-31, 04:36

thank you for testing. the funny thing is that i don't even have a windows box and wasn't sure if GS will work as expected on windows. ;-)

now for the bugs: if you think that update somehow connected with non-working scripts, you're right! ;-) the provided info is more than enough for me to see what i did wrong. this line in changelog does it: "adding top line with any rubbish text also disables script". the script has license in comment section before "==UserScript==" part, and GS sees it as "rubbish text", disabling the script. oh, well, adding "@disabled" meta is not harder, so i removed that check and issued an immediate bugfix release. wow, i'm feeling like a Serious Developer!

squarefractal

Re: simple userscript engine aimed at power users

Unread post by squarefractal » 2015-07-31, 09:51

... and IMO this would be time to have a public repository of your code managed with a version control system :)

I believe it could lead to an increase to the number of contributors in the project.

User avatar
ketmar
Lunatic
Lunatic
Posts: 369
Joined: 2015-07-28, 11:10
Location: Earth

Re: simple userscript engine aimed at power users

Unread post by ketmar » 2015-07-31, 10:07

i'm very bad at teamwork, to the extend of rejecting patches with "IDC" notice ("i don't care"). ;-)

and now for something serious: sure, i'm using git to maintain my local code repository, but i'm not using github or such, and will never do. simply dumping the repository to my lovely repo.or.cz will change nothing, as repo.or.cz has no services like wiki, or bugtracker, or anything other. i.e. it will be not that different (for other people) from simply unpacking .xpi, changing the things and sending me diff by e-mail. ;-)

yet i can see another reason to make my repo public: to allow people simply do "git pull" and restart PM to test updates. so i think i'll dump the repo to repo.or.cz anyway. but i have to somehow move the things out of my huge "pale moon experiments" repository that keeps everything i'm doing with PM, including forks of other extensions and even some completely unrelated things. or simply start a new repo using the current code...

User avatar
ketmar
Lunatic
Lunatic
Posts: 369
Joined: 2015-07-28, 11:10
Location: Earth

Re: simple userscript engine aimed at power users

Unread post by ketmar » 2015-07-31, 10:11

ah, well, no sense of thinking about it anymore: added a repo URL to the first post.

Locked