Add context-senitivity to userscript.sh #2

Merged
merged 2 commits into from Jul 4, 2015

Conversation

Projects
None yet
2 participants

Adds an argument that can be passed to userscript.sh, specifying whether the
current context is document-start or document-end. Then within the uzbl config
the following can be done:

@on_event   LOAD_COMMIT    spawn @scripts_dir/userscripts.sh document-start
@on_event   LOAD_FINISH    spawn @scripts_dir/userscripts.sh document-end

Which allows userscripts to be run when they want. If the argument is ommited,
then userscript.sh runs on all scripts, preserving current behavior.


This feature appears to be a standard respected by Greasemonkey (see http://wiki.greasespot.net/Metadata_Block#.40run-at ). Certainly I've noticed a number of scripts on userscripts.org using it

arandomuser
Add context-senitivity to userscript.sh
Adds an argument that can be passed to userscript.sh, specifying whether the
current context is document-start or document-end.  Then within the uzbl config
the following can be done:

    @on_event   LOAD_COMMIT    spawn @scripts_dir/userscripts.sh document-start
    @on_event   LOAD_FINISH    spawn @scripts_dir/userscripts.sh document-end

Which allows userscripts to be run when they want.  If the argument is ommited,
then userscript.sh runs on all scripts, preserving current behavior.
Owner

singpolyma commented Nov 5, 2012

What is current_context all?

Owner

singpolyma commented Nov 5, 2012

Can you change the [ -z $2 ] to [ -z "$2" ] ?

Owner

singpolyma commented Nov 5, 2012

Actually, the if is not needed, just use "${2-all}"

Owner

singpolyma commented Nov 5, 2012

The current_context logic should be moved out of the function.

Owner

arandomuser commented on 2592b0a Nov 6, 2012

a current_context of "all" meant that userscript.sh would execute all userscripts, regardless of their @runs-at setting. I've reworded that value to be "document-any" to be more clear. I also moved default evaluation out of the function and used shorter bash default assignment syntax.

@singpolyma singpolyma merged commit 2592b0a into singpolyma:master Jul 4, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment