Google Business Data Extractor (v2)

Extracts the data-pid value from a Google Business profile page

目前为 2023-09-11 提交的版本。查看 最新版本

// ==UserScript==
// @name Google Business Data Extractor (v2)
// @namespace https://example.com/
// @version 0.1
// @description Extracts the data-pid value from a Google Business profile page
// @author sharmanhall
// @icon https://www.google.com/s2/favicons?sz=64&domain=google.com
// @match https://www.google.com/*
// @grant none
// @license MIT
// ==/UserScript==
(function() {
    'use strict';
    window.addEventListener("load", function() {
        let businessNameElement = document.querySelector('h2[data-attrid="title"]');
        if (businessNameElement) {
            let businessName = businessNameElement.textContent.trim();
            console.log('%cBusiness name:','font-size: 16px; font-weight: bold; color:green', businessName);
        } else {
            console.error("Could not find the business name element on the page");
        }
        let reviewButton = document.querySelector("#wrkpb");
        if (reviewButton) {
            let dataPid = reviewButton.getAttribute("data-pid");
            console.log('%cdata-pid:','font-size: 16px; font-weight: bold; color:green', dataPid);
            let dataPidElement = document.createElement('div');
            dataPidElement.innerText = `PID: ${dataPid}`;
            dataPidElement.style.fontSize = "14px";
            dataPidElement.style.color = "red";
            businessNameElement.append(dataPidElement);
        } else {
            console.error("Could not find the 'Write a Review' button on the page");
        }
        let searchResultLink = document.querySelector('a[jscontroller="wuU7pb"]');
        if (searchResultLink) {
            let dataCid = searchResultLink.getAttribute("data-rc_ludocids");
            console.log('%cdata-cid:','font-size: 16px; font-weight: bold; color:green',dataCid);
            let dataCidElement = document.createElement('div');
            dataCidElement.innerText = `CID: ${dataCid}`;
            dataCidElement.style.fontSize = "14px";
            dataCidElement.style.color = "blue";
            businessNameElement.append(dataCidElement);
        } else {
            console.error("Could not find the data-cid search result link on the page");
        }
    });
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址