User:Js/markZeroEdits.js
From Wikipedia, the free encyclopedia
< User:Js
Note: After saving, you have to bypass your browser's cache to see the changes. In Internet Explorer and Firefox, hold down the Ctrl key and click the Refresh or Reload button. Opera users have to clear their caches through Tools→Preferences, see the instructions for Opera. Konqueror and Safari users can just click the Reload button.
//see [[user:js/markZeroEdits]] addOnloadHook(markZeroEdits) function markZeroEdits(){ var i = 0, j, k, entry, plusminus, isHRDone var rows, td, aa, sp, step var firstEditor, thisEditor, isRevert mzRevertRegExp = window.mzRevertRegExp || /^(BOT[ -]*)?Reverted|^Reverting|^Undid revision / mzCSS = window.mzCSS || 'table.revert-edit * {color:#777799; }\ table.revert-edit td {text-decoration: line-through}\ table.zero-edit * {color:#777799}' addCSS(mzCSS) while (entry=document.getElementById('RCM'+(i++))){//loop through all multiple edits //check if this is a 0 size diff while ((entry=entry.parentNode) && entry.nodeName!='TR'); plusminus = entry.cells[1].getElementsByTagName('span')[0] if (!plusminus || plusminus.className!='mw-plusminus-null') continue //get all collapsed edits inside hidden DIV rows = document.getElementById('RCI' + (i-1)).firstChild.rows //some initial values firstEditor = '' //first editor (who is possibly reverted later) //check all edits from bottom, i.e. by the timeline for (j=rows.length-1; j>=0; j--){ //find editor td = rows[j].cells[1] aa = td.getElementsByTagName('a') for (k=0; k<aa.length && /&oldid=/.test(aa[k].href); k++); thisEditor = aa[k].href //compare with previous editor if (!firstEditor){ //this is a beginning of possible edit-revert block firstEditor = thisEditor isRevert = false continue }else if (thisEditor==firstEditor && j>0){ //first editor keeps making several edits continue } //we now have either a different editor of the last edit //find edit summary sp = aa[k] while ((sp=sp.nextSibling) && sp.nodeName!='SPAN'); //check if this was a revert if (!sp) break if (!mzRevertRegExp.test(pickUpText(sp).substring(1))) break //by default do not trust self reverts and reverts by unregs if (thisEditor==firstEditor && !window.mzTrustSelfRv) break if (/Special:Contributions/.test(thisEditor) && !window.mzTrustUnregRv) break //all checks done, this looks like a revert after all isRevert = true firstEditor = '' //get ready for the next block of edits } //categorize the entry while ((entry=entry.parentNode) && entry.nodeName!='TABLE'); if (isRevert){ entry.className += 'revert-edit' if (window.mzMoveReverts) do{ step = entry.nextSibling; entry.parentNode.appendChild(entry); entry = step }while (entry && entry.nodeName != 'TABLE' && entry.nodeName != 'HR') }else{ entry.className += 'zero-edit' } }//while function addCSS(text){ //could use createStyleSheet for IE as well var s = document.createElement('style') s.setAttribute('type', 'text/css') if (s.styleSheet) s.styleSheet.cssText = text //IE else s.appendChild(document.createTextNode(text)) document.getElementsByTagName('head')[0].appendChild(s) } }