Wikipedia:WikiProject User scripts/Scripts/Edit Top: Difference between revisions

Content deleted Content added
Pile0nades (talk | contribs)
No edit summary
 
No edit summary
Tags: Mobile edit Mobile web edit
 
(38 intermediate revisions by 20 users not shown)
Line 1:
Ever want to just change something at the top of a fairly long article, but don't feel like loading the entire page again like the "Edit this page" link does? Well, now you can do just that, using this wiki user scrip border: 1px #aaa solid; border-collapse: collapse; font-size: 95%;"
<pre><nowiki>
!Name
// This will add an [edit top] link at the top of all pages except preview pages
!Version
// by User:Pile0nades
!Description
!Skins
!Author
|-
|'''Edit Top'''
|1.1.1
|Allows you to edit just the first section of an article.
|MonoBook
|[[User:pile0nades|pile0nades]]
|}
 
==Installation instructions==
To install the script:
* Go to [[Special:Mypage/skin.js]] and click "Edit this page"
* Add the line<br><code style="margin-left:2em;line-height:3em;padding:1em;border: 1px dashed #2f6fab;">importScript("[[Wikipedia:WikiProject User scripts/Scripts/Edit Top.js]]");</code><br>to your skin script and save
* [[WP:BYPASS|Bypass your browser cache]]
 
A slightly modified version is also available at [[User:Gerbrant/edit/top.js]].
// Add an [edit top] link to pages
function editTopLink() {
// if this is preview page or generated page, stop
if(document.getElementById("wikiPreview") || window.___location.href.indexOf("w/index.php?title=Special:") != -1) return;
 
==Usage==
// get the page title
Now go to any page on Wikipedia and the [edit intro] link will appear at the top right. This link will load only the "zeroth" section of the article into the edit page.
var pageTitle = document.title.split(" - ")[0].replace(" ", "_");
 
[[Category:Wikipedia toolsscripts]]
// create div and set innerHTML to link
var divContainer = document.createElement("div");
divContainer.innerHTML = '<div class="editsection" style="float:right;margin-left:5px;margin-top:3px;">[<a href="/w/index.php?title='+pageTitle+'&amp;action=edit&amp;section=0" title="'+document.title.split(" - ")[0]+'">edit top</a>]</div>';
 
// insert divContainer into the DOM before the h1
document.getElementById("content").insertBefore(divContainer, document.getElementsByTagName("h1")[0]);
 
if(window.___location.href.indexOf("&action=edit&section=0") != -1) {
document.getElementById("wpSummary").value = "/* Intro */ ";
}
setTimeout("editTopLink();", 250);
 
</nowiki></pre>
 
[[Category:Wikipedia tools]]