Jump to content

User:Smith609/toolbox.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Smith609 (talk | contribs) at 10:54, 14 April 2016 (Update to new stats tool per User:Le Deluge). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
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.
// if you are using the "expand citations" gadget, then you'll want to install toolbox2.js instead or the links will be duplicated
importScript("User:Smith609/citations.js");
function addToToolbox() {
  if (mw.config.get('wgCanonicalNamespace') != "Special") {

   var pTb = document.getElementById("p-tb");
   if( !pTb ) return;

   var pStats = pTb.cloneNode(true);

   pStats.id="p-stats";
   pStats.innerHTML = "<h3	>Statistics</h3><div class=pBody><ul></ul></div>";
   pTb.parentNode.insertBefore(pStats, pTb.nextSibling);

/*   var now = new Date();
   var month = now.getMonth();
   var year = now.getFullYear();
   var thisMonth = (now.getDay() > 6);
   if (thisMonth) month++;
   if (month == 0) {
      month = 12;
      year--;
   } else month = ((month <10)?'0':'') + month; */
   mw.util.addPortletLink("p-stats", "https://tools.wmflabs.org/pageviews/#project=en.wikipedia.org&platform=all-access&agent=user&range=latest-30&pages=" + encodeURI(mw.config.get('wgPageName')), 'Traffic stats', '', "Traffic to this page in the last month");
   mw.util.addPortletLink("p-stats", "https://wikidashboard.appspot.com/enwiki/wiki/" + encodeURI(mw.config.get('wgPageName')), 'Edit history stats', '', "Statistics about the edit history of this page");
   mw.util.addPortletLink("p-stats", "http://toolserver.org/~mzmcbride/watcher/?db=enwiki_p&titles=" + 	encodeURIComponent(mw.config.get('wgPageName')), 'Page watchers', "Number of people with this page on their watchlist");
    }
}
if( $.inArray( mw.config.get( 'skin' ), [ "myskin" , "simple" , "monobook" , "modern", "chick" , "vector" ] ) !== -1 ) {
  $( addToToolbox );
}