Scholar:快速「过去一年」筛选按钮
在搜索栏旁添加按钮,一键将结果限定为过去一年发表的论文。
可复制的代码
// Add a quick "Last year" filter button next to the search bar
(function () {
if (document.getElementById('jzSchLastYear')) { return; }
function host() {
return document.querySelector('#gs_ab, #gs_hdr_act, #gs_hdr');
}
var h = host();
if (!h) {
new MutationObserver(function (m, obs) {
if (host()) { obs.disconnect(); mount(); }
}).observe(document.body, { childList: true, subtree: true });
return;
}
mount();
function mount() {
var h2 = host();
if (!h2 || document.getElementById('jzSchLastYear')) { return; }
var btn = document.createElement('a');
btn.id = 'jzSchLastYear';
var y = new Date().getFullYear();
var params = new URLSearchParams(location.search);
params.set('as_ylo', String(y - 1));
params.set('scisbd', '1');
btn.href = location.pathname + '?' + params.toString();
btn.textContent = 'Last year';
btn.style.cssText = 'display:inline-block;margin:6px 10px;padding:6px 14px;background:#1a73e8;color:#fff;font-size:13px;font-weight:700;text-decoration:none;border-radius:4px;';
h2.appendChild(btn);
}
})();
如何使用此示例
- 用上方按钮复制代码。
- 安装 JustZix(2 分钟),在目标页面打开扩展。
- 添加一条匹配该页面的新规则。
- 将代码粘贴到规则的 JavaScript 面板并保存 — 每次访问页面时都会运行。
为此示例评分
暂无评分 — 成为第一个。