您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
VOZ - Remove tag [HN] in the alert page
// ==UserScript== // @name VOZ - Remove tag [HN] // @version 0.1.7 // @namespace VOZ // @description VOZ - Remove tag [HN] in the alert page // @author N.Duong // @license MIT // @match https://voz.vn/* // @run-at document-start // @icon https://www.google.com/s2/favicons?sz=64&domain=voz.vn // @grant none // ==/UserScript== (function() { 'use strict'; function safeQuery(selector) { try { return document.querySelector(selector); } catch (err) { console.error(`Query failed for selector: ${selector}`, err); return null; } } function safeRemoveHNItems() { try { const items = document.querySelectorAll('li[data-alert-id]'); items.forEach(item => { try { const labelSpan = item.querySelector('span.label.label--green'); if (labelSpan && labelSpan.textContent.trim() === 'HN') { item.remove(); } } catch (err) { console.warn('Error checking/removing item:', err); } }); } catch (err) { console.error('Error removing HN items:', err); } } function tryInjectBadge() { let attempts = 0; const maxAttempts = 10; const intervalMs = 500; const retryInterval = setInterval(() => { attempts++; try { const alertLink = safeQuery('a[data-nav-id="ALERTS"]'); const numberOfAlert = safeQuery('a[href="/account/alerts"]'); if (alertLink && numberOfAlert) { clearInterval(retryInterval); const badgeValue = numberOfAlert.getAttribute('data-badge') || '0'; console.log("FOUND ALERTS link, badge =", badgeValue); const badge = document.createElement('span'); badge.textContent = badgeValue; badge.className = 'vn-alert-badge'; badge.style.cssText = ` background: red; color: white; border-radius: 21%; padding: 2px 6px; font-size: 12px; margin-left: 6px; `; alertLink.appendChild(badge); } if (attempts >= maxAttempts) { clearInterval(retryInterval); console.warn("ALERTS link not found after 10 attempts."); } } catch (err) { console.error('Error during badge injection attempt:', err); } }, intervalMs); } window.addEventListener('DOMContentLoaded', () => { try { safeRemoveHNItems(); tryInjectBadge(); } catch (err) { console.error('Unexpected error in main handler:', err); } }); })();