Jump to content

User:Cuckooman4/favtab2.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.
//
//Same as original, (User:Cuckooman4/favtab.js) except it uses a dropdown list.
//<pre><nowiki>
addOnloadHook(
  function() {
    mw.util.addPortletLink('p-cactions','javascript:favgo()','Go!','ca-fav')
    document.getElementById("ca-fav").innerHTML = "<select id='favdropdown'>" + writefavlist() + "</select> " + document.getElementById("ca-fav").innerHTML
  }
)

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

function favgo() {
  location.href = "http://en.wikipedia.org/wiki/" + document.getElementById("favdropdown").all[document.getElementById("favdropdown").selectedIndex].innerText
}
//</nowiki></pre>