Wikipedia:User scripts/Guide: Difference between revisions
Content deleted Content added
Reverting edit by Alex Smotrov. You must have done some mistake, it works fine in my Opera 9.02 on WinME. But please add the way you load your localhost .js just in case. |
→CSS files: Reworking this section. More explanation, more examples. |
||
Line 253:
For example you could use [http://www.ritlabs.com/en/products/tinyweb/ TinyWeb] which is less than 100kbyte on disk and doesn't require installation. Save and unzip <tt>tinyweb.zip</tt> for example into <tt>c:\Program Files\Tinyweb</tt>, then create a shortcut to <tt>tiny.exe</tt>, in shortcut properties add an argument — path to your folder with <tt>wikipediatest.js</tt> and any file <tt>index.html</tt> (required). Start TinyWeb with this shortcut; unload it with Task Manager.
Instead you can load a CSS file from your local web server. (See previous section for an easy to install web server.) Put this string at the very top of your [[Special:Mypage/monobook.css|/monobook.css]]:
<source lang="css">
@import "http://localhost/wikipediatest.css";
</source>
'''Note!'''
Once you have finished the CSS code you either need to paste it into your <tt>/monobook.css</tt> if it is only for personal use. Or if it is for use by others then you should upload it to for instance [[Special:Mypage/yourscript.css|User:Yourname/yourscript.css]]. Then other users can import it by putting this line in their <tt>/monobook.js</tt>. Note, that is in their ".js", not their ".css".
<source lang="javascript">
importStylesheet( 'User:Yourname/yourscript.css' );
</source>
If the CSS should be used together with a user script written in JavaScript then you can make it easy for the users. Simply put the line above in the JavaScript code for your user script, then the users only need to "install" your JavaScript.
For completeness, in case someone wonders. You can import your <tt>User:Yourname/yourscript.css</tt> from your <tt>/monobook.css</tt> too, although that takes this rather messy line of code:
<source lang="css">
@import "/w/index.php?title=User:Yourname/yourscript.css&action=raw&ctype=text/css";
</source>
|