User:Yair rand/checktbotentries.js

From Wiktionary, the free dictionary
Jump to navigation Jump to search

Note: You may have to bypass your browser’s cache to see the changes. In addition, after saving a sitewide CSS file such as MediaWiki:Common.css, it will take 5-10 minutes before the changes take effect, even if you clear your cache.

  • Mozilla / Firefox / Safari: hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Command-R on a Macintosh);
  • Konqueror and Chrome: click Reload or press F5;
  • Opera: clear the cache in Tools → Preferences;
  • Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5.


function addchecktbotentrybuttons()
{
var q=(window.bodyContent||document.getElementById('bodyContent')).getElementsByTagName('div')
for(var i=0; i<q.length; i++){
  if(q[i].className == "tbot-entry"){
    var qq = q[i].getElementsByTagName('p')[0].appendChild(newNode('i',' [',newNode('a','check',{'style':'cursor:pointer;','click':function(){
      var qqqqq = this.parentNode, qqqq=this.parentNode.parentNode.parentNode;
      for(var qqq=qqqq; qqq&&!/h\d/i.test(qqq.nodeName); qqq=qqq.previousSibling);
      qqq = qqq.firstChild.getElementsByTagName('a')[0].href.split("&section=")[1]
      editor=new Editor();editor.addEdit({
        edit:function(wikitext){return ccc=wikitext.replace(RegExp("(((^|\n)=[\\s\\S]*?){" + qqq + "}[\\s\\S]*?)\\{\\{tbot entry[^\\}]+\\}\\}"),'$1').replace(/\n\n\n/g,'\n\n')},
        redo:function(){qqqq.style.border="2px dashed #FF0000";qqqq.style.opacity="0.6";qqqq.style.backgroundColor="#FFEEEE";qqqqq.style.display='none'},
        undo:function(){qqqq.style.border="";qqqq.style.opacity="1";qqqq.style.backgroundColor="#F0F0F0";qqqqq.style.display='inline'},
        summary:'check tbot entry',
        after_save:function(){qqqq.style.backgroundColor="#F00"; setTimeout(function(){qqqq.parentNode.removeChild(qqqq)}, 400)}
        })
      }}),']'))
    }
  }
}

$(addchecktbotentrybuttons)