User:Chlod/Scripts/DirectPDFDownload.js: Difference between revisions
Appearance
< User:Chlod | Scripts
Content deleted Content added
add base |
rerun lock |
||
Line 9: | Line 9: | ||
$("li#coll-download-as-rl").on("mouseover", function (event) { |
$("li#coll-download-as-rl").on("mouseover", function (event) { |
||
var a = event.target.querySelector("a"); |
var a = event.target.querySelector("a"); |
||
if (!a || !a.getAttribute("href").includes("show-download-screen")) { |
|||
if (!a) { |
|||
return; |
return; |
||
} |
} |
Latest revision as of 05:01, 4 July 2024
// Direct PDF Download
// Author: Chlod
// Version: 1.0.1-REL
// Forces the "Download as PDF" button to directly download the PDF version of
// the article.
$(document).ready(function () {
$("li#coll-download-as-rl").on("mouseover", function (event) {
var a = event.target.querySelector("a");
if (!a || !a.getAttribute("href").includes("show-download-screen")) {
return;
}
a.setAttribute(
"href",
"https://en.wikipedia.org/api/rest_v1/page/pdf/" +
encodeURIComponent(
mw.util.wikiUrlencode(new URL(a.getAttribute("href"), window.location.href).searchParams.get("page"))
)
);
});
});