Wikipedia:WikiProject User scripts/Scripts/Revert tools: Difference between revisions

Content deleted Content added
Usage: (Fixed spelling of vandalism)
m Protected Wikipedia:WikiProject User scripts/Scripts/Revert tools: protect against abuse - arbitrary code injection [edit=sysop:move=sysop] [cascading]
 
(4 intermediate revisions by 4 users not shown)
Line 1:
/*<pre>*/
On diff pages this script replaces ''(Difference between revisions)'' with different tools for reverting the edit and warning the user that made the edit.
//On diff pages this script replaces ''(Difference between revisions)''with
{|border="1" cellpadding="4" cellspacing="0" style="margin: 1em 1em 1em 0; background: #f9f9f9; border: 1px #aaa solid; border-collapse: collapse; font-size: 95%;"
On diff pages this script replaces ''(Difference between revisions)'' with //different tools for reverting the edit and warning the user that made the edit.
!Name
//For instructions see talk page.
!Version
!Description
!Skins
!Author
|-
|'''Revert tools'''
|1.0
|Displays links to revert an edit when viewing a diff page
|MonoBook
|[[User:Lorian|Lorian]]
|-
|
|1.1
|Edits by [[User:Konman72|Konman72]], see talk page
|MonoBook
|[[User:Konman72|Konman72]]
|}
 
==Installation instructions==
 
To install the script:
 
* Go to [[Special:Mypage/monobook.js]] and click on edit.
* Copy/Paste the following script into the edit box, and save. Follow the displayed instruction to bypass your browser cache.
 
==Code==
 
===JavaScript===
 
<pre>
// Revert tools by Lorian
function getElementsByClass(searchClass,node,tag) {
Line 76 ⟶ 47:
// Get username of submitter
var user1 = getElementsByClass('diff-otitle',null,'td'); user1 = user1[0].getElementsByTagName('a')[2].innerHTML;
var user2 = getElementsByClass('diff-ntitle',null,'td'); user2 = user2[0].getElementsByTagName('a')[23].innerHTML;
document.getElementById('contentSub').innerHTML = '(<a href="http://en.wikipedia.org/w/index.php?title=' + _GET['title'] + '&action=edit&oldid=' + _GET['oldid'] + '&revert=1&user1='+user1+'&user2='+user2+'">Revert</a> / <a href="javascript:var message = getMessage(\'revert\', \''+user1+'\', \''+user2+'\');">Message</a>) (<a href="http://en.wikipedia.org/w/index.php?title=' + _GET['title'] + '&action=edit&oldid=' + _GET['oldid'] + '&vandalism=1&user1='+user1+'&user2='+user2+'">Vandalism</a> / <a href="javascript:var message = getMessage(\'vandalism\', \''+user1+'\', \''+user2+'\');">Message</a>) (Warn: <a href="http://en.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit&section=new&warn=1">Test</a> / <a href="http://en.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit&section=new&warn=2">Blatant</a> / <a href="http://en.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit&section=new&warn=3">Nonsense</a> / <a href="http://en.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit&section=new&warn=4">Blanking</a>)';
} else if (___location.href.match(/revert=1/)) {
Line 108 ⟶ 79:
}
});
/*</pre>*/
 
==Usage==
 
Go to any diff page and these links will be placed at the top under "From Wikipedia, the free encyclopedia".
:(Revert / Message) (Vandalism / Message) (Warn: Test / Blatant / Nonsense / Blanking)
 
* '''Revert:''' Will revert the edit and put this in the edit summary: Reverted edits by [user] to version [version] by [user].
* '''Message:''' Displays a dialogue box for you to enter a message (Ie. Why you reverted it) and will put it in backets after the "Reverted edits..." bit.
 
* '''Vandalism/Message:''' Does the same as above but displays "Reverted vandalism" instead of "Reverted edits".
 
* '''Warnings:''' Will subst the relevant warnings on the editors talk page.