کاربر:Raamin/revert.js
از ویکیپدیا، دانشنامهٔ آزاد.
نکته: پس از ذخیرهسازی ممکن است برای دیدن تغییرات نیاز باشد که حافظهٔ نهانی مرورگر خود را خالی کنید. موزیلا / فایرفاکس / Safari: کلید Shift را نگهدارید و روی دکمهٔ Reload کلیک کنید، یا کلیدهای Ctrl-Shift-R را با هم فشار دهید (در رایانههای اپل مکینتاش کلیدهای Cmd-Shift-R)؛ اینترنت اکسپلورر: کلید Ctrl نگهدارید و روی دکمهٔ Refresh کلیک کنید، یا کلیدهای Ctrl-F5 را با هم فشار دهید؛ Konqueror: روی دکمهٔ Reload کلیک کنید و یا کلید F5 را فشار دهید؛ اُپرا: کاربران اُپرا ممکن است لازم باشد که بطور کامل حافظهٔ نهانی مرورگر را در منوی Tools→Preferences خالی کنند.
/*<pre>*/ //from: http://fa.wikipedia.org/w/index.php?title=%DA%A9%D8%A7%D8%B1%D8%A8%D8%B1:Behaafarid/revert.js&oldid=373103 //from: http://en.wikipedia.org/w/index.php? //title=Wikipedia:WikiProject_User_scripts/Scripts/Revert_tools&oldid=95500074 //On diff pages this script replaces ''(Difference between revisions)''with //different tools for reverting the edit and warning the user that made the edit. //For instructions see talk page. // Revert tools by Lorian function getElementsByClass(searchClass,node,tag) { // Function from http://www.dustindiaz.com/getelementsbyclass/ var classElements = new Array(); if ( node == null ) node = document; if ( tag == null ) tag = '*'; var els = node.getElementsByTagName(tag); var elsLen = els.length; var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)"); for (i = 0, j = 0; i < elsLen; i++) { if ( pattern.test(els[i].className) ) { classElements[j] = els[i]; j++; } } return classElements; } // _GET code from NoGray JS Library http://www.nogray.com/new_site/ var _GET = new Array(); var _uri = location.href; var _temp_get_arr = _uri.substring(_uri.indexOf('?')+1, _uri.length).split("&"); var _temp_get_arr_1 = new Array(); for(_get_arr_i=0; _get_arr_i<_temp_get_arr.length; _get_arr_i++){ _temp_get_arr_1 = _temp_get_arr[_get_arr_i].split("="); _GET[decodeURI(_temp_get_arr_1[0])] = decodeURI(_temp_get_arr_1[1]); } delete _uri; delete _temp_get_arr; delete _temp_get_arr_1; addOnloadHook(function (){ if (location.href.match(/diff=/)) { // 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')[3].innerHTML; document.getElementById('contentSub').innerHTML = '(<a href="http://fa.wikipedia.org/w/index.php?title=' + _GET['title'] + '&action=edit&oldid=' + _GET['oldid'] + '&revert=1&user1='+user1+'&user2='+user2+'">واگردانی</a>) (<a href="http://fa.wikipedia.org/w/index.php?title=' + _GET['title'] + '&action=edit&oldid=' + _GET['oldid'] + '&vandalism=1&user1='+user1+'&user2='+user2+'">خرابکاری</a>)'; } else if (location.href.match(/revert=1/)) { document.getElementById('wpSummary').value = 'به نسخهٔ ' + _GET['oldid']+' [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']] واگردانده شد.'; document.getElementById('editform'); } else if (location.href.match(/vandalism=1/)) { document.getElementById('wpSummary').value = 'خرابکاری [[Special:Contributions/'+_GET['user2']+'|'+_GET['user2']+']] به نسخهٔ ' + _GET['oldid']+' [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']] واگردانده شد.'; document.getElementById('editform'); } }); /*</pre>*/