Търсене в помощните статии

Избягвайте измамите при поддръжката. Никога няма да ви помолим да се обадите или изпратите SMS на телефонен номер или да споделите лична информация. Моля, докладвайте подозрителна активност на "Докладване за злоупотреба".

Научете повече

How to Create a Script in Greasemonkey?

  • 11 отговора
  • 4 имат този проблем
  • 7 изгледи
  • Последен отговор от cor-el

more options

Hello all, I have a couple of things. One is a rather chronic problem with scrolling on Tumblr (pages with backgrounds that do not scroll have varying degrees of choppiness/stalling scrolling. Just look at my past questions to see a more detailed description), and the other is a script that fixes the problem (again, see past question replies for the script).

While it is a very small nitpick, I would like to know how to place that script in Greasemonkey, since it is a bit annoying to have to do it manually for every page that requires the script.

I tried looking at Greasemonkey to see if it was something I could do myself, but I decided I would go to those who (might) know, because with my luck I would mess up something crucial.

So...my two questions: 1) How does one make a Greasemonkey script? Or more like, how would one insert an existing script into Greasemonkey? 2) Is there a way to make said script automatically affect only the pages that would need it (for example, only tumblr pages with non-scrolling backgrounds? Since those with no/scrolling backgrounds are fine), or would I need to manually enter in the pages in question as I encountered them?

Hello all, I have a couple of things. One is a rather chronic problem with scrolling on Tumblr (pages with backgrounds that do not scroll have varying degrees of choppiness/stalling scrolling. Just look at my past questions to see a more detailed description), and the other is a script that fixes the problem (again, see past question replies for the script). While it is a very small nitpick, I would like to know how to place that script in Greasemonkey, since it is a bit annoying to have to do it manually for every page that requires the script. I tried looking at Greasemonkey to see if it was something I could do myself, but I decided I would go to those who (might) know, because with my luck I would mess up something crucial. So...my two questions: 1) How does one make a Greasemonkey script? Or more like, how would one insert an existing script into Greasemonkey? 2) Is there a way to make said script automatically affect only the pages that would need it (for example, only tumblr pages with non-scrolling backgrounds? Since those with no/scrolling backgrounds are fine), or would I need to manually enter in the pages in question as I encountered them?

Всички отговори (11)

more options

hello ponyparty, to answer your questions shortly...
1) when greasemonkey is installed and you go to the address of a script (commonly a file that ends in user.js) the extension will automatically prompt you to install this script
2) most userscripts are already site-specific, you can also tweak these settings within the greasemonkey extension.

you'll find more scripts and resources at http://userscripts.org/

more options

Hello philipp, The script given to me was not on a .js page. If you look in my past questions/replies, I was given the script to use/place into the bookmarks bar (https://support.mozilla.org/en-US/questions/976335#answer-501479 ).

As far as I know, this means it was not given to me as a userscript. I am asking how I can make it a userscript/put it into Greasemonkey, or if someone else would be able to do that for me. I do apologize if I did not make this clear in my original post.

Променено на от ponyparty

more options

yes, what jscher2000 has provided there was a bookmarklet - that's a special form of a bookmark that contains code that is executed on a page once the bookmark is clicked.

i'm not knowledgeable enough to know if and how that bookmarklet can be converted into a userscript, but i'd suggest that you post again in your original thread, where jscher200 might be able to help you out again...

more options

Alright, Though if anyone else knows how to do that, they are welcome to comment here. So, for anyone else reading this, does anyone know how one can convert a bookmarklet to a userscript, if that is even possible?

more options

Hi ponyparty, could I suggest posing that question on the userscripts.org Script development forum? In order to cleanly post code, this userscript adds a few editing controls to the forum there: http://userscripts.org/scripts/show/24464.

P.S. Don't bother offering payments, people are usually happy to help without that.

more options

@jscher2000 Thanks, did that...now just gonna have to wait I guess!

Jumping the gun a bit, but any ideas on what to do if I do not get a reply from anyone? It's not a huge problem, mind, but it is something I would like to know because it would make things run a lot smoother.

more options

@jscher2000: A bit of clarification by what I meant in my reply- I guess what I mean to say is that if there is no reply/nobody wants to do the script, is there anything else I can do/anyone else I can go to? Or would I just have to "deal with it" (which is doable..it's just a bit annoying to have to manually click for every single page. Having the process be more automatic would make things a bit smoother)?

more options

Note that such a script

You can also do this for specific domains (web pages) with code in userContent.css or with the Stylish Firefox/Tools > Add-ons > Extensions.
That would also work with frames that you probably can't reach with JavaScript code that adds a style sheet. If you ned more domains then add them separated by commas.

Add code to the userContent.css file.

@namespace url(http://www.w3.org/1999/xhtml); /* you can leave out this line in userContent.css */
@-moz-document
 domain(<enter the domain>),
 domain(<enter more domains>)
{
html, body {background-attachment: scroll !important}
}


The customization files userChrome.css (user interface) and userContent.css (websites) are located in the chrome folder in the Firefox profile folder.

You can use this button to go to the Firefox profile folder:

  • Help > Troubleshooting Information > Profile Directory: Show Folder (Linux: Open Directory; Mac: Show in Finder)
more options

@cor-el: Could you show me how to do this with screenshots? If that's too much, no need to do so.

more options

Edit: I read too fast. The rule in this thread is for content, and therefore goes into the userContent.css file. Please ignore this post for purposes of the above rule.

Here's how to manually create/edit the userChrome.css file:

(1) Find (or create) the chrome folder. This is a folder in your currently active Firefox settings folder, also known as your Firefox profile folder.

  • Open the your profile folder using: Help > Troubleshooting Information
    • Windows: Click the "Show Folder" button
    • Mac: Click the "Show in Finder" button
  • Check for a chrome folder.
    • If it exists: double-click it to open it.
    • If it does not exist: create a chrome folder, then double-click it to open it.

(2) Create or Edit a userChrome.css file by adding your style rule.

Note: spelling and capitalization are crucial. If Windows does not display file extensions such as .css, .js, .doc, and so forth, change that setting as described in this article: http://support.microsoft.com/kb/865219.

  • Check for a userChrome.css file in the chrome folder.
    • If it exists: open it in a text editor. Check that it has this first line:

      @namespace url(http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul);

      Then paste in the new style rule (not duplicating the above line).
       
    • If it does not exist: create a new text file named userChrome.css. (In Windows, right-click and choose New > Text Document and change the name to userChrome.css, making sure the file type ends up being CSS file and not Text Document.) Then see the previous step for what to place in the file.

The rule change should take effect the next time you start Firefox.

Note: I find it easier to use the Stylish extension, but if you don't want yet another extension, then userChrome.css makes the most sense.

Променено на от jscher2000 - Support Volunteer

more options

Note that the code I posted above [*] needs to go in the userContent.css file for CSS rules for web pages and not in the userChrome.css that is used to style the user interface.

The customization files userChrome.css (user interface) and userContent.css (websites) are located in the chrome folder in the Firefox profile folder.