您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Extract name, location, and username from Facebook profile pages and update the title
当前为
// ==UserScript== // @name Facebook PageTitle updater // @version 1.0 // @description Extract name, location, and username from Facebook profile pages and update the title // @match https://www.facebook.com/* // @grant none // @namespace https://gf.qytechs.cn/users/1409709 // ==/UserScript== (function() { 'use strict'; // Function to extract name, location, and username function extractInfo() { // Extract name const nameElement = document.querySelector('h1.html-h1'); let name = ''; if (nameElement && nameElement.textContent) { name = nameElement.textContent.trim(); console.log('Name:', name); } // Extract "Lives in" location const livesInElement = Array.from(document.querySelectorAll('div[role="main"] span[dir="auto"]')).find(el => el.textContent.includes('Lives in')); let livesIn = ''; if (livesInElement) { const livesInLocation = livesInElement.querySelector('a span'); if (livesInLocation && livesInLocation.textContent) { livesIn = livesInLocation.textContent.trim(); console.log('Lives in:', livesIn); } } // Extract "From" location const fromElement = Array.from(document.querySelectorAll('div[role="main"] span[dir="auto"]')).find(el => el.textContent.includes('From')); let from = ''; if (fromElement) { const fromLocation = fromElement.querySelector('a span'); if (fromLocation && fromLocation.textContent) { from = fromLocation.textContent.trim(); console.log('From:', from); } } // Extract username from URL const url = window.location.href; let username = ''; const usernameMatch = url.match(/facebook\.com\/([^/?&]+)/); if (usernameMatch && usernameMatch[1] && !usernameMatch[1].includes('profile.php')) { username = usernameMatch[1]; console.log('Username:', username); } // Update the title const titleElement = document.querySelector('title'); if (titleElement) { // Only keep the "Facebook" part of the original title let newTitle = 'Facebook'; // Append name if (name) { newTitle += ` - ${name}`; } // Append "Lives in" location only if it exists if (livesIn) { newTitle += ` - Lives in ${livesIn}`; } // Append "From" location only if it exists if (from) { newTitle += ` - From ${from}`; } // Append username only if it exists if (username) { newTitle += ` - ${username}`; } titleElement.textContent = newTitle; console.log('Title:', newTitle); } } // Function to monitor URL changes function monitorURLChanges() { let lastURL = window.location.href; setInterval(() => { const currentURL = window.location.href; if (currentURL !== lastURL) { lastURL = currentURL; extractInfo(); } }, 1000); } // Run the function when the page is fully loaded window.addEventListener('load', () => { extractInfo(); monitorURLChanges(); }); })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址