Greasy Fork

Greasy Fork is available in English.

Facebook Profile ID Extractor (OSINT)

Extracts Facebook profile ID

目前为 2025-02-18 提交的版本,查看 最新版本

// ==UserScript==
// @name         Facebook Profile ID Extractor (OSINT)
// @version      1.0
// @description  Extracts Facebook profile ID
// @author       SH3LL
// @match        https://www.facebook.com/*
// @namespace http://greasyfork.icu/users/762057
// ==/UserScript==

(function() {
    'use strict';

    let popup = null; // Store the popup element
    let labelAdded = false;

    function createPopup() {
        popup = document.createElement('div');
        popup.style.cssText = `
            position: fixed;
            top: 65px;
            right: 43%;
            background-color: black;
            border: 1px solid #ccc;
            padding: 10px;
            border-radius: 5px;
            z-index: 9999; /* Ensure it's on top */
            font-weight: bold;
        `;
        document.body.appendChild(popup);
    }

    function extractInfo() {
        if (labelAdded) return;

        try {
            const userIdRegex = /"userID":"(\d+)"/;
            const userIdMatch = document.documentElement.outerHTML.match(userIdRegex);

            if (userIdMatch && userIdMatch[1]) {
                const userId = userIdMatch[1];
                const link = document.createElement('a'); // Create a link element
                link.href = "https://www.facebook.com/profile.php?id=" + userId; // Set the URL
                link.target = "_blank"; // Open in a new tab (optional)
                link.style.color = 'red';
                link.innerText = "User ID: " + userId;


                if (!popup) {
                    createPopup(); // Create popup if it doesn't exist
                }
                popup.appendChild(link); // Add the link to the popup
                labelAdded = true;
            } else {
                console.error("Facebook ID not found.");
                return;
            }
        } catch (e) {
            console.error("Error processing request: " + e.message);
            if (!popup) {
                createPopup();
            }
            return;
        }
    }

    const checkInterval = setInterval(() => {
        if (document.readyState === 'complete') { // Check if the page is fully loaded
            clearInterval(checkInterval);
            extractInfo();
        }
    }, 500);

})();