// ==UserScript== // @name 期刊等级查询助手 // @namespace http://tampermonkey.net/ // @version 0.1 // @description 在网页上添加一个浮动球,用于查询期刊等级信息 // @author Your name // @match *://*/* // @grant GM_xmlhttpRequest // @grant GM_addStyle // @downloadURL none // ==/UserScript== (function() { 'use strict'; // 添加样式 GM_addStyle(` #journal-query-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; } #journal-query-ball:hover { transform: scale(1.1); } #journal-query-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; } #journal-query-modal input { width: 100%; padding: 8px; margin-bottom: 10px; border: 1px solid #ddd; border-radius: 4px; } #journal-query-modal button { background: #4CAF50; color: white; border: none; padding: 8px 15px; border-radius: 4px; cursor: pointer; } #journal-query-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 ball = document.createElement('div'); ball.id = 'journal-query-ball'; ball.innerHTML = '📚'; document.body.appendChild(ball); const modal = document.createElement('div'); modal.id = 'journal-query-modal'; modal.innerHTML = `
${indicator}: ${value}
`; } results.innerHTML = resultHtml; results.style.display = 'block'; } catch (error) { showError(error); } finally { loading.style.display = 'none'; } }); function showError(message) { const errorMessage = document.querySelector('.error-message'); errorMessage.textContent = message; errorMessage.style.display = 'block'; } // 点击其他地方关闭模态框 document.addEventListener('click', (event) => { if (isModalVisible && !modal.contains(event.target) && !ball.contains(event.target)) { modal.style.display = 'none'; isModalVisible = false; } }); })();