Misplaced Pages

User:PrimeHunter/Pageviews.js: Difference between revisions

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
< User:PrimeHunter Browse history interactively← Previous editNext edit →Content deleted Content added
Revision as of 14:01, 6 February 2021 view sourcePrimeHunter (talk | contribs)Administrators79,172 edits update url, add "Massviews" link on disambiguation pages← Previous edit Revision as of 21:59, 5 June 2023 view source MusikAnimal (talk | contribs)Edit filter managers, Autopatrolled, Interface administrators, Administrators120,542 edits update domain to avoid redirectNext edit →
Line 12: Line 12:
mw.util.addPortletLink( mw.util.addPortletLink(
'p-tb', 'p-tb',
'https://pageviews.toolforge.org/?project=en.wikipedia.org&pages=' + 'https://pageviews.wmcloud.org/?project=en.wikipedia.org&pages=' +
encodeURIComponent(mw.config.get( 'wgPageName' )), encodeURIComponent(mw.config.get( 'wgPageName' )),
'Page views', 'Page views',
Line 23: Line 23:
mw.util.addPortletLink( mw.util.addPortletLink(
'p-tb', 'p-tb',
'https://pageviews.toolforge.org/massviews/?source=wikilinks&' + 'https://pageviews.wmcloud.org/massviews/?source=wikilinks&' +
'target=https://en.wikipedia.org/' + 'target=https://en.wikipedia.org/' +
encodeURIComponent(mw.config.get( 'wgPageName' )), encodeURIComponent(mw.config.get( 'wgPageName' )),

Revision as of 21:59, 5 June 2023

/* This script adds a "Page views" link under "Tools" in the sidebar.
   The link goes to the external tool https://pageviews.toolforge.org.
   On disambiguation pages the script also adds a "Mass views" link to
   page views for all pages linked on the page.
   To use the script, add the following line to Special:MyPage/common.js:
 
importScript('User:PrimeHunter/Pageviews.js'); // Linkback: ]

*/
 
mw.loader.using(, function () {
  mw.util.addPortletLink(
    'p-tb',
    'https://pageviews.wmcloud.org/?project=en.wikipedia.org&pages=' +
    encodeURIComponent(mw.config.get( 'wgPageName' )),
    'Page views',
    'pt-pageviews',
    'Show page views for this page',
    null,
    '#t-info'
  );
  if ( document.getElementById( 'disambigbox' ) ) {
    mw.util.addPortletLink(
      'p-tb',
      'https://pageviews.wmcloud.org/massviews/?source=wikilinks&' +
      'target=https://en.wikipedia.org/' +
      encodeURIComponent(mw.config.get( 'wgPageName' )),
      'Massviews',
      'pt-massviews',
      'Show page views for pages linked on this disambiguation page',
      null,
      '#t-info'
    );
  }
});