Wikipedia:User scripts/Guide: Difference between revisions
Content deleted Content added
update |
→portlets: adding examples for a few more arguments + giving a better example for the href (avoid hard-coding paths because of HTTPS). |
||
Line 214:
</div>
<br/><div style="border:1px solid gray">
<sup>''p-tb''</sup><br/>Upload
</div>
<br/><div style="border:1px solid gray">
Line 225:
<source lang="html4strict">
<div id="
<h5>Header</h5>
<div class="
<ul>
<li id="…"> <a …> //links
Line 241:
<source lang="javascript">
//Several examples of portlet links
addPortletLink ('p-tb', wgArticlePath.replace('$1', '
addPortletLink ('p-personal', wgScript + '?title=User:' + encodeURIComponent(wgUserName) + '/Notes&action=edit', 'My notes', 'pt-mynotes', 'Edit your personal notes');
addPortletLink ('p-tb', wgArticlePath.replace('$1', 'Special:Prefixindex/'+wgPageName), 'Prefixindex', 'tb-prefixindex');
addPortletLink ('p-personal', '/wiki/Special:Log/' + encodeURIComponent(wgUserName), 'My logs', 'pt-mylogs');
</source>
Last 4 arguments are optional; all arguments are explained in the code.
* <tt>id</tt> of your new link (in case you need to access it later with <tt>getElementById</tt>)
* <tt>tooltip</tt>
* <tt>accesskey</tt>
* <tt>nextnode</tt> — if you want to insert new link before another element, in our example this could be <code>document.getElementById('t-specialpages')</code>, i.e. «Special pages» link
=== Adding elements ===
|