您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
获取账户名称并修改浏览器标签页的title
// ==UserScript== // @name 头条标签页显示账户名称 // @namespace http://tampermonkey.net/ // @version 2024-09-10 // @description 获取账户名称并修改浏览器标签页的title // @author Star // @match https://ad.oceanengine.com/promotion/promote-manage/* // @icon https://www.google.com/s2/favicons?sz=64&domain=oceanengine.com // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; const token=window.location.href.slice(-16); var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver if(localStorage.getItem(token)==null){ const container = document.getElementById('root-common-header') const options = { childList: true, subtree: true, } // 创建MutationObserver实例,返回一个观察者对象 const mutation = new MutationObserver(function(mutationRecoards, observer) { if(document.getElementsByClassName("navigator-user-button")[0]!==undefined&&localStorage.getItem(token)==null){ var str=document.getElementsByClassName("oc-typography-value-int")[0].innerText document.title=str localStorage.setItem(token,str) } }) // 对观察者添加需要观察的元素,并设置需要观察元素的哪些方面 mutation.observe(container, options); }else{ const target = document.querySelector('title'); const mutation = new MutationObserver(function(mutationRecoards, observer){ if(target.innerText=="推广管理"){ document.title=localStorage.getItem(token); } console.log("推广管理") }) mutation.observe(target, { childList: true, subtree: true, characterData: true, }); document.title=localStorage.getItem(token); } })();