Scholar: direct "Open PDF" button per result
Pulls the full-PDF link from the right side of each result and adds a prominent button next to the title for one-click access.
Code to copy
// Promote the right-side PDF link into a prominent "Open PDF" button on each result
(function () {
function decorate() {
document.querySelectorAll('div.gs_r.gs_or.gs_scl, div.gs_or').forEach(function (row) {
if (row.dataset.jzSchPdf) { return; }
var pdfLink = row.querySelector('div.gs_ggsd a[href$=".pdf"], div.gs_or_ggsm a[href$=".pdf"], a.gs_or_ggsm[href$=".pdf"]');
if (!pdfLink) {
pdfLink = Array.from(row.querySelectorAll('a')).find(function (a) {
return /\.pdf(\?|$)/i.test(a.getAttribute('href') || '');
});
}
if (!pdfLink) { return; }
var title = row.querySelector('h3.gs_rt');
if (!title) { return; }
row.dataset.jzSchPdf = '1';
var btn = document.createElement('a');
btn.href = pdfLink.href;
btn.target = '_blank';
btn.rel = 'noopener noreferrer';
btn.textContent = 'Open PDF';
btn.style.cssText = 'display:inline-block;margin-left:10px;padding:2px 10px;background:#0a7c3a;color:#fff;font-size:13px;font-weight:700;text-decoration:none;border-radius:4px;vertical-align:middle;';
title.appendChild(btn);
});
}
decorate();
new MutationObserver(function () {
clearTimeout(window.__jzSchPdf);
window.__jzSchPdf = setTimeout(decorate, 350);
}).observe(document.body, { childList: true, subtree: true });
})();
How to use this example
- Copy the code with the button above.
- Install JustZix (2 minutes) and open the extension on the target page.
- Add a new rule matching that page.
- Paste the code into the rule's JavaScript panel and save — it runs on every page visit.
Rate this example
No ratings yet — be the first.