您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
auto load item detail when mouseover title
当前为
// ==UserScript== // @name v2ex+ // @namespace http://tampermonkey.net/ // @version 0.1 // @description auto load item detail when mouseover title // @author Silvio27 // @match https://www.v2ex.com/* // @icon https://www.google.com/s2/favicons?sz=64&domain=v2ex.com // @grant none // @license GPLv3 // ==/UserScript== (function() { 'use strict'; function load_item(ele, item_url) { // 先取消鼠标移动的事件绑定 ele.onmouseover = () => { } // 创建一个临时容器元素来容纳加载的内容 const tempContainer = document.createElement('div'); // 使用Ajax异步加载下一页的内容 const xhr = new XMLHttpRequest(); xhr.open('GET', item_url, true); xhr.onload = function () { if (xhr.status === 200) { tempContainer.innerHTML = xhr.responseText let details = tempContainer.querySelectorAll(".topic_content") let detail = document.createElement('div') details.forEach((e) => { detail.innerHTML += e.innerHTML }) // detail.id = item_url.replace("https://www.v2ex.com/", "") // detail.style.border = "1px solid rgba(255,255,0,0.5)"; // detail.style.borderRadius = "5px"; ele.parentElement.parentElement.appendChild(detail) } }; xhr.send(); } function show_detail(ele) { let item_url = ele.href load_item(ele, item_url) } let items = document.querySelectorAll(".item_title>a") items.forEach((element) => { element.onmouseover = function () { show_detail(element) } }) })();