|
View:
New views
20 Messages
—
Rating Filter:
Alert me
|
| < Prev | 1 - 2 | Next > |
|
|
Including other JS files and using "class" and custom stylesHi all
I hope that, even if these are very basic questions, someone could give me some hints. 1. Does it work including an external Javascript script inside a GM script? For instance, if I want to include some "AJAX effects" and want to use one of the Open Source javascript libraries out there... 2. In my GM script I am programmatically creating ALL the widgets that I need. Is there a way where I could use some "static HTML" to shortcut the development time? If yes, does someone have an example? 3. one of the issues related to my poor knowledge of JS is that, when programmatically creating my widgets, I do not know how to set a custom CSS class (the equivalent of saying <div class="myclass"> ..... how can I specify in Javascript this?) 4. associated to the latter. If I create my own CSS classes, can I store their definition in a CSS style sheet file and "import" it in the GM script? If yes, how? 5. Final one. Can I use XUL inside a GM script? Thanks a lot for your help and patience /Stefano _______________________________________________ Greasemonkey mailing list Greasemonkey@... http://mozdev.org/mailman/listinfo/greasemonkey |
|
|
Re: Including other JS files and using "class" and custom stylesOn 8/4/2006 4:18 AM, Stefano POGLIANI wrote:
> 1. Does it work including an external Javascript script inside a GM > script? The only straightforward way is to copy and paste the source in. There's no "include" statement like in some other languages. > 2. Is there a way where I could use some "static HTML" to shortcut > the development time? If yes, does someone have an example? There's a number of ways. For example: http://www.arantius.com/article/dollar-e > 3. one of the issues related to my poor knowledge of JS is that, when > programmatically creating my widgets, I do not know how to set a > custom CSS class (the equivalent of saying <div class="myclass"> > ..... how can I specify in Javascript this?) Since "class" is a reserved word in JavaScript, you have to use something else. In this case, className. > 4. associated to the latter. If I create my own CSS classes, can I > store their definition in a CSS style sheet file and "import" it > in the GM script? If yes, how? Yes. http://diveintogreasemonkey.org/patterns/add-css.html > 5. Final one. Can I use XUL inside a GM script? That question is a bit too open ended for me to understand fully; I can't be sure, because I don't know what you're really trying to do, but I suspect the answer is no. _______________________________________________ Greasemonkey mailing list Greasemonkey@... http://mozdev.org/mailman/listinfo/greasemonkey |
|
|
Re: Including other JS files and using "class" and custom stylesThanks Anthony!
Do you have an example of use of "className" in Javascript? also, as I read the "Dive into GM" page, it seems that if the newly defined "class" gets added an "! important;" at the end, the definition overrides the previous one. Could this approach be used to "sort of" RESET any stylesheet attribute that would apply to the elements I am defining in my page? The issue here is to avoid that page-specific stylesheets affect the display of my widgets in the page (so that on one page my DIV will paint in one way and, on a different page, it will paint in a different way). As to the XUL question. I was wondering if, for instance, with GM I could create a little XUL container which could, then, be embedded in soething like the "All-in-One Sidebar" extension. Thanks /Stefano Anthony Lieuallen wrote: > On 8/4/2006 4:18 AM, Stefano POGLIANI wrote: >> 1. Does it work including an external Javascript script inside a GM >> script? > > The only straightforward way is to copy and paste the source in. > There's no "include" statement like in some other languages. > >> 2. Is there a way where I could use some "static HTML" to shortcut >> the development time? If yes, does someone have an example? > > There's a number of ways. For example: > http://www.arantius.com/article/dollar-e > >> 3. one of the issues related to my poor knowledge of JS is that, when >> programmatically creating my widgets, I do not know how to set a >> custom CSS class (the equivalent of saying <div class="myclass"> >> ..... how can I specify in Javascript this?) > > Since "class" is a reserved word in JavaScript, you have to use > something else. In this case, className. > >> 4. associated to the latter. If I create my own CSS classes, can I >> store their definition in a CSS style sheet file and "import" it >> in the GM script? If yes, how? > > Yes. > http://diveintogreasemonkey.org/patterns/add-css.html > >> 5. Final one. Can I use XUL inside a GM script? > > That question is a bit too open ended for me to understand fully; I > can't be sure, because I don't know what you're really trying to do, > but I suspect the answer is no. > _______________________________________________ > Greasemonkey mailing list > Greasemonkey@... > http://mozdev.org/mailman/listinfo/greasemonkey _______________________________________________ Greasemonkey mailing list Greasemonkey@... http://mozdev.org/mailman/listinfo/greasemonkey |
|
|
RE: Including other JS files and using "class" and custom stylesMaybe not "straightforward" by Anthony's standards, but it does "include"
library.js in libraryTest.user.js as desired. Here's the example, that works for the two files in the same directory on the server. Note that libraryTest.user.js @includes itself, so the URL construction won't make sense in the real world. File libraryTest.user.js: // ==UserScript== // @name LibraryTest // @namespace /phil // @description Library Test // @include http://*libraryTest.user.js // @exclude // ==/UserScript== GM_xmlhttpRequest( { method:'GET' , url:document.location.href.replace(/\/[^\/]*$/,'/library.js') , onload: onLoadLibrary } ); function onLoadLibrary(rsp) { eval(rsp.responseText); libraryAlert(); } File library.js: function libraryAlert() { alert('libraryAlert'); GM_log('libraryAlert'); } -- Regards, Phil Friedman - Auto Europe - 207-842-2069 |-----Original Message----- |From: greasemonkey-bounces@... |[mailto:greasemonkey-bounces@...] On Behalf Of Anthony Lieuallen |Sent: Friday, August 04, 2006 9:33 AM |To: greasemonkey@... |Subject: Re: [Greasemonkey] Including other JS files and using |"class" and custom styles | |On 8/4/2006 4:18 AM, Stefano POGLIANI wrote: |> 1. Does it work including an external Javascript script inside a GM |> script? | |The only straightforward way is to copy and paste the source in. |There's no "include" statement like in some other languages. | |> 2. Is there a way where I could use some "static HTML" to shortcut |> the development time? If yes, does someone have an example? | |There's a number of ways. For example: |http://www.arantius.com/article/dollar-e | |> 3. one of the issues related to my poor knowledge of JS is |that, when |> programmatically creating my widgets, I do not know how to set a |> custom CSS class (the equivalent of saying <div class="myclass"> |> ..... how can I specify in Javascript this?) | |Since "class" is a reserved word in JavaScript, you have to |use something else. In this case, className. | |> 4. associated to the latter. If I create my own CSS classes, can I |> store their definition in a CSS style sheet file and "import" it |> in the GM script? If yes, how? | |Yes. |http://diveintogreasemonkey.org/patterns/add-css.html | |> 5. Final one. Can I use XUL inside a GM script? | |That question is a bit too open ended for me to understand |fully; I can't be sure, because I don't know what you're |really trying to do, but I suspect the answer is no. |_______________________________________________ |Greasemonkey mailing list |Greasemonkey@... |http://mozdev.org/mailman/listinfo/greasemonkey | _______________________________________________ Greasemonkey mailing list Greasemonkey@... http://mozdev.org/mailman/listinfo/greasemonkey |
|
|
Re: Including other JS files and using "class" and custom stylesOn 8/4/2006 9:42 AM, Stefano POGLIANI wrote:
> Do you have an example of use of "className" in Javascript? Uh.. var div=document.createElement('div'); div.className='foo'; > also, as I read the "Dive into GM" page, it seems that if the newly > defined "class" gets added an "! important;" at the end, the definition > overrides the previous one. The "! important" clause relates to specificity: http://www.w3.org/TR/CSS21/cascade.html#specificity It makes that rule "more specific" than anything else. > Could this approach be used to "sort of" RESET any stylesheet attribute > that would apply to the elements I am defining in my page? There's a GM api to do this .. I think it's only in CVS versions at this point. I can't remember its name, but someone will come up with it. > As to the XUL question. I was wondering if, for instance, with GM I > could create a little XUL container which could, then, be embedded in > soething like the "All-in-One Sidebar" extension. Can't say, for sure. _______________________________________________ Greasemonkey mailing list Greasemonkey@... http://mozdev.org/mailman/listinfo/greasemonkey |
|
|
Re: Including other JS files and using "class" and custom stylesI can't remember what the status of this whole discussion is anymore.
Has anyone suggested another metadata statement, like "@library userscript_library.user.js". (since @include is already defined; the ".user.js" could be implied and auto-appended if absent) The desired file could be in the standard user script directory. This would be fairly easy to do and support. (relatively, I think) You could just "install" the library 'module', but not @include it to anything, just to get it into the directory for reference with the @library meta statement. As for XUL, no, that is chrome-only, which you could do if you compiled your GmScript into an extension and then added the XUL stuff. _______________________________________________ Greasemonkey mailing list Greasemonkey@... http://mozdev.org/mailman/listinfo/greasemonkey |
|
|
Re: Including other JS files and using "class" and custom styles> I can't remember what the status of this whole discussion is anymore.
> > Has anyone suggested another metadata statement, like "@library > userscript_library.user.js". It has been suggested, and there has even been floating around some code to implement it. Unfortunately it still has not made it into a released Greasemonkey version, for reasons I don't remember (they may not have been aired publicly yet, for instance). -- / Johan Sundström, http://ecmanaut.blogspot.com/ _______________________________________________ Greasemonkey mailing list Greasemonkey@... http://mozdev.org/mailman/listinfo/greasemonkey |
|
|
Re: Including other JS files and using "class" and custom stylesOn 8/5/06, Johan Sundström <oyasumi@...> wrote:
> It has been suggested, and there has even been floating around some > code to implement it. Unfortunately it still has not made it into a > released Greasemonkey version, for reasons I don't remember (they may > not have been aired publicly yet, for instance). No particular reason, except that nobody has had time to do it. We should not be adding random code (no offense) to GM just because a patch exists. Anyway, yes I know this is a very popular request. It's near the top of the list of things to do. - a _______________________________________________ Greasemonkey mailing list Greasemonkey@... http://mozdev.org/mailman/listinfo/greasemonkey |
|
|
Re: Including other JS files and using "class" and custom stylesOn 8/6/06, Aaron Boodman <zboogs@...> wrote:
> On 8/5/06, Johan Sundström <oyasumi@...> wrote: > > It has been suggested, and there has even been floating around some > > code to implement it. Unfortunately it still has not made it into a > > released Greasemonkey version, for reasons I don't remember > > (they may not have been aired publicly yet, for instance). > > No particular reason, except that nobody has had time to do it. We > should not be adding random code (no offense) to GM just because > a patch exists. Certainly not; code review and working it in the right way is never optional. Is there anything one can do as a non-committer to help the cause? (It's a very high up wishlist item of mine, too, since it would reduce most of my everyday GM scripting code payloads to fewer lines than the GM script documentation and header itself.) -- / Johan Sundström, http://ecmanaut.blogspot.com/ _______________________________________________ Greasemonkey mailing list Greasemonkey@... http://mozdev.org/mailman/listinfo/greasemonkey |
|
|
Re: Including other JS files and using "class" and custom stylesThe easiest way to do it without having to worry about any complexity and
such would be to just read the library file and insert it into the injected script right before injection. The only "problem" with this is that the code would have multiple instances, which is only a "memory space thing". They would all be sandboxed, so it wouldn't matter that there were multiple instances of the library code. (not optimal, but it would be easy, and would work) Alternately, I was thinking on a way to treat each library as an object, with each function a method of that object, with Gm being the (initial) link between the scripts and calls to the object methods, since there would be a timing issue of when the library was injected itself and available for calls. So, initially, when you make a call to the object method, you might actually get "caught" by Gm, which would finish the call once the library code (object) was available, and would then modify the calling script's object value so that calls to the methods would be direct after that. This may or may not work or be viable or optimal, I was just mulling it over. I think with anything other than my first idea, you have to be careful because of security concerns and the like, which makes implementation more complex. Unless someone has already worked out something better that I don't remember. _______________________________________________ Greasemonkey mailing list Greasemonkey@... http://mozdev.org/mailman/listinfo/greasemonkey |
|
|
Re: Including other JS files and using "class" and custom stylesBill
how would you do for the first suggestion? Is this "pasting" the external script code inside the current GM script or is there a coolest way to do? I just tried the GM_xmlhttpRequest approach from Philip but in my case it did not work as the "eval" seems not to return. Thanks Best regards /Stefano Bill Donnelly wrote: > The easiest way to do it without having to worry about any complexity and > such would be to just read the library file and insert it into the > injected > script right before injection. The only "problem" with this is that the > code would have multiple instances, which is only a "memory space thing". > They would all be sandboxed, so it wouldn't matter that there were > multiple > instances of the library code. (not optimal, but it would be easy, and > would work) > > Alternately, I was thinking on a way to treat each library as an > object, with > each function a method of that object, with Gm being the (initial) > link between > the scripts and calls to the object methods, since there would be a > timing issue > of when the library was injected itself and available for calls. > > So, initially, when you make a call to the object method, you might > actually > get "caught" by Gm, which would finish the call once the library code > (object) > was available, and would then modify the calling script's object value > so that > calls to the methods would be direct after that. This may or may not > work or > be viable or optimal, I was just mulling it over. > > I think with anything other than my first idea, you have to be careful > because > of security concerns and the like, which makes implementation more > complex. > > Unless someone has already worked out something better that I don't > remember. > > _______________________________________________ > Greasemonkey mailing list > Greasemonkey@... > http://mozdev.org/mailman/listinfo/greasemonkey _______________________________________________ Greasemonkey mailing list Greasemonkey@... http://mozdev.org/mailman/listinfo/greasemonkey |
|
|
Re: Including other JS files and using "class" and custom stylesWhat I'm talking about has to be done down inside Gm and be a supported
feature. There is no easy or good way to do it, imo, otherwise. Stefano POGLIANI wrote: > Bill > > how would you do for the first suggestion? Is this "pasting" the > external script code inside the current GM script or is there a coolest > way to do? > > I just tried the GM_xmlhttpRequest approach from Philip but in my case > it did not work as the "eval" seems not to return. > > Thanks > Best regards > /Stefano > > Bill Donnelly wrote: >> The easiest way to do it without having to worry about any complexity and >> such would be to just read the library file and insert it into the injected >> script right before injection. The only "problem" with this is that the >> code would have multiple instances, which is only a "memory space thing". >> They would all be sandboxed, so it wouldn't matter that there were multiple >> instances of the library code. (not optimal, but it would be easy, and would work) _______________________________________________ Greasemonkey mailing list Greasemonkey@... http://mozdev.org/mailman/listinfo/greasemonkey |
|
|
Greasemonkey and venkmanIs it possible to use venkman to debug a gm user.js script? James _______________________________________________ Greasemonkey mailing list Greasemonkey@... http://mozdev.org/mailman/listinfo/greasemonkey |
|
|
Re: Greasemonkey and venkmanOn Aug 11, 2006, at 3:30 AM, James Cowan wrote:
> > Is it possible to use Venkman to debug a gm user.js script? Did you ever get an answer to this question? Dave _______________________________________________ Greasemonkey mailing list Greasemonkey@... http://mozdev.org/mailman/listinfo/greasemonkey |
|
|
Re: Greasemonkey and venkmanGM scripts are executed in greasemonkey.js, more exactly, in the
evalInSandbox method, which in turns calls the native function Components.utils.evalInSandbox [1]: (greasemonkey.js, 223) Components.utils.evalInSandbox(code, sandbox); Being written in C++, this cannot be debugged with Venkman. Maybe there is way to slightly modify greasemonkey.js in order to substitute the native evalInSandbox with something else that can be debugged? Incidentally, while searching for information regarding this possibility, I came across Mozilla Security Advisory 2006-31 [2]. I'm more than a bit surprised that this, being critical for GM, hasn't been mentioned in this list till now. This should be discussed in another thread, though. [1] http://developer.mozilla.org/en/docs/Components.utils.evalInSandbox [2] http://www.mozilla.org/security/announce/2006/mfsa2006-31.html 2006/8/21, Dave Land < land@...>: > On Aug 11, 2006, at 3:30 AM, James Cowan wrote: > > > > > Is it possible to use Venkman to debug a gm user.js script? > > Did you ever get an answer to this question? > > Dave > _______________________________________________ > Greasemonkey mailing list > Greasemonkey@... > http://mozdev.org/mailman/listinfo/greasemonkey > Greasemonkey mailing list Greasemonkey@... http://mozdev.org/mailman/listinfo/greasemonkey |
|
|
Re: Greasemonkey and venkmanOn 8/21/2006 3:27 PM, esquifit wrote:
> Incidentally, while searching for information regarding this > possibility, I came across Mozilla Security Advisory 2006-31 [2]. I'm > more than a bit surprised that this, being critical for GM, hasn't > been mentioned in this list till now. This should be discussed in > another thread, though. > > [2] http://www.mozilla.org/security/announce/2006/mfsa2006-31.html Here's my take. The linked page specifically mentions that "... a malicious userscript could gain enough privilege to install malware, but even when Greasemonkey is working as designed a malicious userscript can make life miserable. Only install userscripts from sources you can trust." The purpose of evalInSandbox, for GreaseMonkey, is to separate the user script from the content page. If a mozilla bug makes *that* not happen, then it is a big problem. The threat of a user script acting malicious is smaller, if only because the number of user scripts you run is surely smaller than the number of web sites you visit. It was also fixed 2 patch levels (minor revisions?) ago =) _______________________________________________ Greasemonkey mailing list Greasemonkey@... http://mozdev.org/mailman/listinfo/greasemonkey |
|
|
Re: Greasemonkey and venkman2006/8/21, esquifit <esquifit@...>:
> Incidentally, while searching for information regarding this > possibility, I came across Mozilla Security Advisory 2006-31 [2]. I'm > more than a bit surprised that this, being critical for GM, hasn't > been mentioned in this list till now. Oh, I see: "Fixed in: Firefox 1.5.0.4". Sorry. Forget it. _______________________________________________ Greasemonkey mailing list Greasemonkey@... http://mozdev.org/mailman/listinfo/greasemonkey |
|
|
Re: Greasemonkey and venkmanOn 8/21/06, esquifit <esquifit@...> wrote:
> 2006/8/21, esquifit <esquifit@...>: > > Incidentally, while searching for information regarding this > > possibility, I came across Mozilla Security Advisory 2006-31 [2]. I'm > > more than a bit surprised that this, being critical for GM, hasn't > > been mentioned in this list till now. > > Oh, I see: "Fixed in: Firefox 1.5.0.4". Sorry. Forget it. Well, I noticed it, but only when looking at the release notes for 1.5.0.4. It's not a moot point-- you have to wonder if there are other ways of escaping the sandbox-- but it certainly isn't easily done. _______________________________________________ Greasemonkey mailing list Greasemonkey@... http://mozdev.org/mailman/listinfo/greasemonkey |
|
|
[Greasemonkey] javascript scope between browsersHi
I am puzzled by javascript scope within greasemonkey/firefox extensions. In normal web app, I can open a window (wdw = window.open(...) and then within the parent call the child using wdw.someFunction() or within the child execute a function in the parent using window.opener.someFunction. Within a greasemonkey script or firefox extension, I want to open a window and then make calls from parent and child to functions within the extension. The standard web technique does not work - I guess because the functions are not in the scope of the window but of the browser. Is there any way around this? James _______________________________________________ Greasemonkey mailing list Greasemonkey@... http://mozdev.org/mailman/listinfo/greasemonkey |
|
|
Re: [Greasemonkey] javascript scope between browsersOn 10/19/2006 9:07 AM, James Cowan wrote:
> I am puzzled by javascript scope within greasemonkey... > Is there any way around this? (Not intentionally rude but...) Learn how greasemonkey works. A good place to start: http://www.oreillynet.com/pub/a/network/2005/11/01/avoid-common-greasemonkey-pitfalls.html _______________________________________________ Greasemonkey mailing list Greasemonkey@... http://mozdev.org/mailman/listinfo/greasemonkey |
| < Prev | 1 - 2 | Next > |
| Free embeddable forum powered by Nabble | Forum Help |