Jump to content

User:Pediapress/collection.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.
function addArticle() {
  window.location.href = 'http://pediapress.com/api/add-article/?return=1&base_url=' + mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '&title=' + mw.config.get('wgTitle');
}

function addCategory() {
  window.location.href = 'http://pediapress.com/api/add-category/?return=1&base_url=' + mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '&title=' + mw.config.get('wgTitle');
}  
 
function addPediaPressLinks() {
  if (mw.config.get('wgNamespaceNumber') == 14) {
     addPortletLink ('p-personal', 'javascript:addCategory()', 'add category');
  }  else {
     addPortletLink ('p-personal', 'javascript:addArticle()', 'add article');
  }
  addPortletLink ('p-personal', 'http://pediapress.com/collection/', 'my collection');
}
 
addOnloadHook(addPediaPressLinks);