您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
在知乎回答中显示作者IP属地
// ==UserScript== // @name 知乎显示IP属地 // @namespace http://tampermonkey.net/ // @version 0.3 // @description 在知乎回答中显示作者IP属地 // @author You // @match https://www.zhihu.com/* // @grant GM_xmlhttpRequest // @license MIT // ==/UserScript== (function() { 'use strict'; // 添加CSS样式 const style = document.createElement('style'); style.textContent = ` .ip-location { font-size: 14px; color: #8590a6; margin-top: 8px; display: block; line-height: 1.5; clear: both; } `; document.head.appendChild(style); // 获取作者主页链接并添加IP属地信息 function addIPLocation() { const authorLinks = document.querySelectorAll('.UserLink-link'); authorLinks.forEach(link => { if(link.dataset.processed) return; link.dataset.processed = true; const authorUrl = link.href; // 修改为查找发布时间元素 const contentItem = link.closest('.ContentItem'); if(!contentItem) return; const timeDiv = contentItem.querySelector('.ContentItem-time'); if(!timeDiv) return; if(timeDiv.querySelector('.ip-location')) return; // 创建IP属地显示元素 const ipDiv = document.createElement('div'); ipDiv.className = 'ip-location'; // 将IP信息插入到时间元素后面 timeDiv.appendChild(ipDiv); GM_xmlhttpRequest({ method: 'GET', url: authorUrl, onload: function(response) { const parser = new DOMParser(); const doc = parser.parseFromString(response.responseText, 'text/html'); const ipElement = doc.querySelector('.css-1xfvezd'); if(ipElement) { const ipMatch = ipElement.textContent.match(/IP 属地[^}]+/); if(ipMatch) { ipDiv.textContent = ipMatch[0]; } } } }); }); } // 监听页面变化 const observer = new MutationObserver(addIPLocation); observer.observe(document.body, { childList: true, subtree: true }); // 初始执行 addIPLocation(); })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址