就是将logbook.qrz.com页面加载iframe到新增的标签页并自动查询

// ==UserScript==
// @name QRZ.com View QSO Logbook Records
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Add "与我的QSO" tab on QRZ callsign pages to show related logbook entries
// @author BG6QED
// @match https://www.qrz.com/db/*
// @match https://logbook.qrz.com/*
// ==/UserScript==
(function() {
'use strict';
// 处理QRZ呼号详情页
if (window.location.hostname === 'www.qrz.com' && /\/db\//.test(window.location.pathname)) {
// 提取呼号
const callsign = window.location.pathname.split('/db/')[1].toUpperCase().replace(/\/$/, '');
// 找到标签导航
const tabsNav = document.querySelector('ul.ui-tabs-nav');
if (!tabsNav) return;
// 创建并插入新标签和面板
const tabId = 't_qso';
tabsNav.insertBefore(
Object.assign(document.createElement('li'), {
className: 'ui-state-default ui-corner-top',
innerHTML: `<a href="#${tabId}" class="ui-tabs-anchor" id="ui-id-5">与我的QSO</a>`
}),
tabsNav.querySelector('li:has(input[onclick*="logbook.qrz.com/logbook/?op=add"])') || tabsNav.lastChild
);
const newPanel = Object.assign(document.createElement('div'), {
id: tabId,
className: 'ui-tabs-panel ui-widget-content ui-corner-bottom',
style: 'display: none',
innerHTML: `<iframe id="qsoIframe" style="width:100%;height:800px;border:none;"></iframe>`
});
tabsNav.parentNode.appendChild(newPanel);
// 标签切换处理
const handleTabClick = (tabLi, targetId, isNew) => e => {
e.preventDefault();
// 执行原始事件
if (!isNew) tabLi.querySelector('a').click();
// 更新标签和面板状态
tabsNav.querySelectorAll('li').forEach(li => {
const active = li === tabLi;
li.classList.toggle('ui-tabs-active', active);
li.classList.toggle('ui-state-active', active);
});
document.querySelectorAll('.ui-tabs-panel').forEach(panel => {
panel.style.display = panel.id === targetId ? 'block' : 'none';
});
// 加载iframe
if (isNew) {
newPanel.querySelector('iframe').src =
`https://logbook.qrz.com/?autosearch=${encodeURIComponent(callsign.toLowerCase())}`;
}
};
// 绑定事件
const newTab = tabsNav.querySelector(`li:has(a[href="#${tabId}"])`)
newTab.querySelector('a').addEventListener('click', handleTabClick(newTab, tabId, true));
tabsNav.querySelectorAll('li:not(:last-child)').forEach(li => {
const anchor = li.querySelector('a');
if (anchor) anchor.addEventListener('click', handleTabClick(li, anchor.getAttribute('href').slice(1), false));
});
}
// 处理日志页面自动搜索
else if (window.location.hostname === 'logbook.qrz.com') {
const searchTerm = new URLSearchParams(window.location.search).get('autosearch');
if (searchTerm) {
const interval = setInterval(() => {
const searchInput = document.getElementById('search');
if (searchInput && typeof goto === 'function') {
searchInput.value = searchTerm;
goto('search');
clearInterval(interval);
}
}, 500);
setTimeout(() => clearInterval(interval), 10000);
}
}
})();