// ==UserScript== // @name 期刊论文查询助手 // @namespace http://tampermonkey.net/ // @version 1.0 // @description 集成期刊查询和论文跳转功能的助手 // @author Your name // @match *://*/* // @match https://www.ablesci.com/assist/create // @grant GM_xmlhttpRequest // @grant GM_addStyle // @grant GM_setValue // @grant GM_getValue // @downloadURL https://update.greasyfork.icu/scripts/522590/%E6%9C%9F%E5%88%8A%E8%AE%BA%E6%96%87%E6%9F%A5%E8%AF%A2%E5%8A%A9%E6%89%8B.user.js // @updateURL https://update.greasyfork.icu/scripts/522590/%E6%9C%9F%E5%88%8A%E8%AE%BA%E6%96%87%E6%9F%A5%E8%AF%A2%E5%8A%A9%E6%89%8B.meta.js // ==/UserScript== (function() { 'use strict'; // 添加样式 GM_addStyle(` #paper-helper-ball { position: fixed; right: 20px; bottom: 20px; width: 50px; height: 50px; background: #4CAF50; border-radius: 50%; color: white; display: flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 2px 5px rgba(0,0,0,0.2); z-index: 10000; transition: transform 0.3s; } #paper-helper-ball:hover { transform: scale(1.1); } #paper-helper-modal { display: none; position: fixed; right: 80px; bottom: 80px; width: 300px; background: white; border-radius: 8px; padding: 15px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); z-index: 10000; } .tab-buttons { display: flex; margin-bottom: 10px; gap: 5px; } .tab-button { flex: 1; padding: 8px; border: none; border-radius: 4px; cursor: pointer; background: #f0f0f0; } .tab-button.active { background: #4CAF50; color: white; } .tab-content { display: none; } .tab-content.active { display: block; } #paper-helper-modal input { width: 100%; padding: 8px; margin-bottom: 10px; border: 1px solid #ddd; border-radius: 4px; } #paper-helper-modal button { background: #4CAF50; color: white; border: none; padding: 8px 15px; border-radius: 4px; cursor: pointer; width: 100%; } #paper-helper-modal button:hover { background: #45a049; } #query-results { margin-top: 10px; padding: 10px; background: #f5f5f5; border-radius: 4px; display: none; } .loading { text-align: center; margin: 10px 0; display: none; } .error-message { color: red; margin-top: 10px; display: none; } `); // 检查当前是否在目标网站 const isTargetSite = window.location.href.includes('ablesci.com/assist/create'); if (isTargetSite) { // 在目标网站自动填充 const paperTitle = GM_getValue('paperTitle', ''); if (paperTitle) { // 等待页面加载完成 window.addEventListener('load', () => { setTimeout(() => { const input = document.getElementById('onekey'); if (input) { input.value = paperTitle; // 触发事件 input.dispatchEvent(new Event('input', { bubbles: true })); input.dispatchEvent(new Event('change', { bubbles: true })); // 清除存储的标题 GM_setValue('paperTitle', ''); // 点击搜索按钮 const searchButton = document.querySelector('.onekey-search'); if (searchButton) { searchButton.click(); } } }, 500); // 稍微延迟以确保元素已加载 }); } } else { // 在其他网站显示浮动球和模态框 const ball = document.createElement('div'); ball.id = 'paper-helper-ball'; ball.innerHTML = '📚'; document.body.appendChild(ball); const modal = document.createElement('div'); modal.id = 'paper-helper-modal'; modal.innerHTML = `
{indicator}: ${value}
`; } results.innerHTML = resultHtml; results.style.display = 'block'; } catch (error) { showError(error); } finally { loading.style.display = 'none'; } }); // 论文跳转按钮点击事件 document.getElementById('search-button').addEventListener('click', () => { const paperTitle = document.getElementById('paper-title').value.trim(); if (paperTitle) { // 保存标题到存储 GM_setValue('paperTitle', paperTitle); // 打开新窗口 window.open('https://www.ablesci.com/assist/create', '_blank'); } }); // 点击其他地方关闭模态框 document.addEventListener('click', (event) => { if (isModalVisible && !modal.contains(event.target) && !ball.contains(event.target)) { isModalVisible = false; modal.style.display = 'none'; } }); } })(); function showError(message) { const errorMessage = document.querySelector('.error-message'); errorMessage.textContent = message; errorMessage.style.display = 'block'; }