Monday 15 April 2013

jquery - How to change the default metadata in new Greasemonkey scripts? -


I want to add a default entry to the meta data for the new Greasemonkey script.

Currently, when you use the New Users ... menu, you get a dialog like this (I need Minimum-Required Field was filled in, and the clipboard was empty):

new GM script dialog < / P>


This gives a new script like this: // == Userscript == // @name _Sample Default Greasemonkey script // @ namespace _pc / / @ Included http://stackoverflow.com/questions/* // @ version1 // == / UserScript ==


But, I @require jquery and a @ author field on each default script, so it Default code will appear like this :

  // == Userscript == // @name _Sample Default Greasemonkey script // @ namespace _pc // @ contains http: // Stackoverflow.com/questions/* // @require http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js // @author me // @ version1 // == / Users ==   


How can I do this? When I edit greasemonkey.jar (in the folder extension), and add the line: @require http: // [link from jquery to google] This does not work and problems opening Greasemonkey Are (a ¿file?).

How do I change the default instructions?

I see, which is the right way to handle this long term.

To fix a quick and dirty, temporary - which will only work for you and only update to the next Greasemonkey, you can do the following:

  1. Turn off Firefox.
  2. Find Yourself
  3. To be extra safe, go to the profile folder.
  4. Find the Greasemonkey extension package. It will be in the extension sub folder and it is usually {e4a8a97b-f2ed-450b-b12d-ee082ba24781} .xpi .
  5. A ZIP is used - Open the file device, such as .xpi file.
  6. Find and remove content \ newscript.js .
  7. Just before line 124, script.push ("// @version 1"); , add the following lines:

      script.push ("//require http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery Min.js "); Script push ("// @ author"); Script.push ("// @grant GM_addStyle");   

    To prevent common problems with default GM scripts, GM_addStyle is bits - especially those that add jQuery.

  8. Update

    newscript.js to the .xpi file.

  9. Restart Firefox changes should be effective.


    Precautions:
    • Editing .xpi files such as you corrupt your Firefox profile If you are not careful!
    • In theory, you may have to uninstall and reinstall Firefox after some corrupts.
    • You

      A slightly less problematic approach, if you have the skills, then this is: (1) fork, (2) Change newscript.js , as I have described above, (3) change the extension ID, and (4) install your foky version

      this would be: Documented, less risky, more permanent, and will allow you to switch fast between GM and your own version.

      If you have even more skills, then you add a custom-metadata feature to the code, GM, and start a pull-request. It contains a little more. < / Html>

No comments:

Post a Comment