Jump to content

User:Cuckooman4/favtab.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
//Made by cuckooman4
//
//See /doc for instructions
//<pre><nowiki>

addOnloadHook(
  function() {
    mw.util.addPortletLink('p-cactions','javascript:togglefavlist()','favorites','ca-fav')
    document.getElementById("ca-fav").innerHTML += "<div style='visibility:hidden;border-bottom:#aaa solid 1px;width:1px;' id='favlist'>" + writefavlist() + "</div>"
  }
)

function togglefavlist() {
  if(document.getElementById("favlist").style.visibility == "hidden") {
    document.getElementById("favlist").style.visibility = "visible"
  }
  else {
    document.getElementById("favlist").style.visibility = "hidden"
  }
}

function writefavlist() {
  var i = 0
  var strtoreturn = ""
  while(i < favlist.length) {
    strtoreturn += "<a href='http://en.wikipedia.org/wiki/" + favlist[i] + "' style='width:200px;'>" + favlist[i] + "</a><br>"
    i++
  }
  return(strtoreturn)
}
//</nowiki></pre>