User:Goldenshimmer/WSExportForMinerva.js

// Provides the WSExport gadget for the Minerva skin

// Based on https://en.wikisource.org/w/load.php?lang=en&modules=ext.gadget.WSexport&skin=vector&version=01fx33l

if ($.inArray(mw.config.get('wgNamespaceNumber'), [0, 114]) !== -1) { // See https://phabricator.wikimedia.org/T229298 for why I'm not using "let"-scoped variables var container=document.createElement('div'); container.style.position='absolute'; container.style.backgroundColor='rgba(255,255,255,0.9)'; container.style.width='100vw'; container.style.height='1.3rem'; container.style.zIndex='1000'; container.style.top='2rem'; container.style.width='33vw'; container.style.left='50vw'; container.style.transform='translateX(-50%)'; container.style.border='0.2rem dashed blue'; container.style.textAlign='center';

document.body.appendChild(container); function createWSexportLink(unknownA,linkTarget,linkLabel,linkId,linkTitle,unknownB,unknownC) { // Replace for mw.util.addPortletLink var elem=document.createElement('a'); elem.href=linkTarget; elem.innerHTML=linkLabel; elem.title=linkTitle; elem.style.padding='0.5rem'; container.appendChild(elem); }

$(function {       createWSexportLink('p-coll-print_export', '//tools.wmflabs.org/wsexport/tool/book.php?' + $.param({            lang: 'en',            format: 'epub-3',            page: mw.config.get('wgPageName')        }), 'Download as EPUB', 'n-epubExport', 'Download an EPUB version of this page', , '#t-print');        createWSexportLink('p-coll-print_export', '//tools.wmflabs.org/wsexport/tool/book.php?' + $.param({            lang: 'en',            format: 'mobi',            page: mw.config.get('wgPageName')        }), 'Download as MOBI', 'n-mobiExport', 'Download a MOBI version of this page', , '#t-print');        createWSexportLink('p-coll-print_export', '//tools.wmflabs.org/wsexport/tool/book.php', 'Choose format', 'n-toolExport', 'Download a version of a work in other formats', '', '#t-print');    }); }