您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Extracts the data-pid value from a Google Business profile page
当前为
// ==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"); } }); })();