您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
帮助用户快速打开tapd详情
// ==UserScript== // @name 快速打开tapd详情 // @namespace l.r // @version 0.0.1 // @description 帮助用户快速打开tapd详情 // @author l.r // @match https://www.tapd.cn/* // @match http://www.tapd.cn/* // @grant none // @license GPLv3 License // ==/UserScript== (function() { 'use strict'; if (location.host !== 'www.tapd.cn') { return; } function dealTapdItem(mutationsList, observer) { observer.disconnect(); const titleAndUrlDoms = document.querySelectorAll('.board-main .card-head'); if (titleAndUrlDoms.length === 0) { return; } const pointDivStyle = { position: 'absolute', background: '#5d9bfc', height: '25px', width: '25px', borderRadius: '50%', bottom: '0', right: '-10px', textAlign: 'center', lineHeight: '23px', color: '#fff' }; function renderPointDivStyle(dom, style) { for (const key in style) { dom.style[key] = style[key]; } } function bindPointDivEvent(dom, eventType = 'click', handler) { dom.addEventListener(eventType, handler); } function addPointDiv(parentDom) { const urlReg = /(((ht|f)tps?):\/\/)+[\w-]+(\.[\w-]+)+([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?/g; const urlRegResult = urlReg.exec(String(parentDom.innerText)); if (!urlRegResult) { return; } const [url] = urlRegResult; parentDom.style.position = 'relative'; const pointDiv = document.createElement('div'); pointDiv.innerHTML = 'D'; renderPointDivStyle(pointDiv, pointDivStyle); bindPointDivEvent(pointDiv, 'click', event => { event.stopPropagation(); window.open(url); }); parentDom.append(pointDiv); } for (const titleAndUrlDom of titleAndUrlDoms) { addPointDiv(titleAndUrlDom); } } const targetNode = document.querySelector('.board-main'); const observerOptions = { childList: true, subtree: true }; const observer = new MutationObserver(dealTapdItem); observer.observe(targetNode, observerOptions); })();