Discussions » Development

Required userscripts containing their own requires

§
Posted: 2016-09-08
Edited: 2016-09-08

Required userscripts containing their own requires

Does this even work?

I have what is basically a personal library with functions common to a set of scripts I'm making, and this library contains @require directives for jQuery and jQueryUI. The problem seems to be that jQueryUI functions do not exist and I am receiving an Uncaught TypeError: $_(...).draggable is not a function error on line 220 of the script where I attempted to call the jQueryUI function draggable().

I'm getting the impression that the jQuery in this script is only working because it is already available from the domain (likely one of the aforementioned scripts in the set since they all contain jQuery @requires). I attempted earlier to remove all jQuery @requires in the child scripts and use the jQuery libraries that Mount Olympus was @requiring with no success, so I'm getting the impression that libraries do not have their @requires parsed.

So am I in the ballpark or is there an easy fix for all of this that I've missed?

woxxomMod
§
Posted: 2016-09-08

That IE icon in your message... Have you checked this in Tampermonkey/Greasemonkey?

§
Posted: 2016-09-08

Oh, don't mind my useragent. I use uMatrix and I enabled the useragent spoofer, so I get a random new one every 5 minutes.

I develop scripts on Linux Mint 13 using Chrome 48.0.2564.116 and TamperMonkey 4.1.10.

§
Posted: 2016-09-11
Edited: 2016-09-11

I posted this question in many places looking for an answer, and I got one from Stack Overflow: the userscript meta block inside any @required file is ignored as a comment. In short, what I wanted to do is impossible.

I posted the complete explanation and my solution to work around this to reddit.

Post reply

Sign in to post a reply.