google-chrome-extension 相关问题

Google Chrome网络浏览器的扩展开发。您可以使用HTML,JavaScript和CSS等Web技术编写它们。

找到一些方法来点击 youtube 屏蔽的跳过广告按钮

随着 YouTube 最近为阻止广告拦截器所做的努力,他们现在似乎已经转向了可以跳过广告的 Chrome 扩展。截至 2024 年 1 月 17 日,他们似乎已经完全

回答 1 投票 0

可以打开多个使用chrome.runtime.onMessage.addListener的Chrome扩展页面吗?

我遇到了一种奇怪的情况,其中一个内容页面似乎破坏了所有其他页面的后台脚本通信。 这很奇怪,因为我可以看到调用传入 De 中的后台脚本...

回答 1 投票 0

火狐浏览器122.0。扩展。当与协议 url 一起使用时,“chrome.scripting.executeScript”会从 url 中删除“:”(冒号)

以下 Firefox 扩展(插件)代码在 Firefox 122.0 版本之前都可以正常运行: 背景.js: 函数 openUrl(url) { window.open(url, '_self'); } 函数播放(网址){

回答 1 投票 0

错误:使用 chrome.scripting.executeScript 时无法加载文件:“script.ts”

我正在使用 Vite 与 React、Typescript 和 CRXJS 开发 chrome 扩展。这是我的第一个项目。我有一个脚本,当单击...中的按钮时,我想在当前选项卡上执行该脚本。

回答 1 投票 0

在内容脚本中读取Chrome扩展打包的文件

我正在开发一个 Chrome 扩展程序,需要打包 XML 文件(trie 数据结构)并能够从内容脚本读取该文件。所以内容脚本将实例化 trie...

回答 1 投票 0

如何在 Chrome 扩展中玩我的 Unity 游戏? (统一 2022 html)

我正在尝试在 google chrome 扩展中制作一个简单的统一游戏。 web gl 中的构建我已将其放入扩展中。 我已经更改了游戏的 html,以便 javascript 在 , ...

回答 1 投票 0

是否可以区分PDF上的Kami文本和普通文本

我正在为我的学校开展一个项目,我正在尝试创建一个工具,可以帮助教师使用作业评分器更快地评分作业。我正在考虑尝试找到一种方法来区分

回答 3 投票 0

尝试上传 Chrome 扩展

尝试上传 chrome 扩展以仅重写 yt URL 中的一个字母,但总是弹出 backround.js 文件无法读取。我无法找出错误。我尝试过人工智能,但当然人工智能...

回答 1 投票 0

为什么我的XMLHttpRequest的readystate是4但是status是0?

我的 Chrome 扩展中有一个内容脚本,它在某些 HTTPS 页面上运行。它试图将 POST 请求发送到 HTTP 页面(通过后台脚本),这是 API 的路由......

回答 4 投票 0

Chrome 扩展 - Manifest V3 URL 捕获

我在使用 regexFilter 捕获 URL 并将其重定向到扩展页面时遇到问题。在 Chrome 上,我最终遇到了损坏的 URL 和无限的重定向循环。在勇敢的情况下,我收到 ERR_BLOCKED_BY_CLIENT。我是...

回答 1 投票 0

首次打开网站时如何抓取Tab的URL?

我正在尝试制作一个扩展程序来阻止网络上的 YouTube 短片。 chrome.tabs.onUpdated.addListener((tabId, tab) => { if (tab.url && tab.url.includes("youtube.com/shorts"))...

回答 1 投票 0

Chrome 扩展是否可以使用网站已加载的模块?

我正在开发一个 Chrome 扩展程序,用于自动向网站填充信息。 但是,当我处理这个“flatpickr”元素时,我遇到了一些问题。我试图使用“setDate...

回答 1 投票 0

来自 javascript 的单击事件未在反应渲染页面的按钮元素上触发

我正在 chrome 扩展中编写一个脚本(内容脚本),用于 https://akhileshcoder.com/social 中的反应渲染页面。 但看起来反应并不有趣,并且点击触发了...

回答 1 投票 0

“MutationObserver”上的“观察”:参数 1 不是“Node”类型

我正在创建一个 Chrome 扩展程序,并尝试在 gMail 撰写框的“发送”按钮旁边包含一个小文本。 我正在使用 MutationObserver 来了解撰写框窗口何时出现。我是...

回答 5 投票 0

为什么cookies没有被删除

我正在尝试遵循这个答案,但它似乎对我不起作用。在对 https://https.api.pqr.com/folder/ 的请求中,我可以看到所有 cookie 仍然存在。 这是代码: chrome.cook...

回答 1 投票 0

Chrome 重复控制台条目

我正在尝试创建 YouTube 扩展程序,但在控制台中我收到重复的条目。 这使得调试变得更加困难,因为我必须不断查找所有控制台消息所在的条目

回答 1 投票 0

带有 React 的 Chrome 扩展 v3 - 通过带有 React 组件的内容脚本将 html 添加到网站

我尝试使用react和webpack实现chrome扩展(manifest v3)。 我想简单地向网站添加一个“Hello World”进行测试,但内容脚本不运行。甚至连公司...

回答 1 投票 0

Chromium 扩展来解析页面源中的关键字

我正在尝试创建一个 chromium 扩展,它将查找位于页面源中的关键字。它们将显示为““关键字”:[这些、是、关键字、示例等]”。我想解析...

回答 1 投票 0

Chrome扩展给出:“未检查的runtime.lastError:无法建立连接。接收端不存在。”

我正在开发一个 chrome 扩展,它将抓取网站并在其内页上执行点击功能。 这是我的文件及其各自的代码: popup.html 文件: 我正在开发一个 Chrome 扩展程序,它将抓取网站并在其内页上执行点击功能。 这是我的文件及其各自的代码: popup.html 文件: <link href="popup.css" rel="stylesheet" type="text/css" /> <script type="module" src="popup.js"></script> <div class="container"> <button class="btnStart" id="btnStart">Start</button> </div> popup.js 文件: import { getActiveTabURL } from "./utils.js"; document.addEventListener("DOMContentLoaded", async () => { const activeTab = await getActiveTabURL(); if (!activeTab.url.includes("example.com")) { const container = document.querySelector(".container"); container.innerHTML = '<div class="title">This is not a example website page.</div>'; return; } else { document.getElementById('btnStart').addEventListener('click', function () { chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) { const tabId = tabs[0].id; chrome.tabs.sendMessage(tabId, { action: "BEGIN", message: "BEGIN", urlPath: activeTab.url, tabId: tabId }, function (response) { // Handle the response here if needed console.log("0) outer response in popup.js main script file") console.log(response); chrome.runtime.sendMessage({ tabId: response.tabId, message: "START", urlPath: response.urlPath }, function (inner) { console.log("1) inner response in popup.js main script file") console.log(inner); }); }); }); }); } }); contentScript.js 文件: const tryConnect = () => { chrome.runtime.onMessage.addListener(async (msg, sender, sendResponse) => { if (msg.action === "scrapeAndClick") { console.log("Scraping and Clicking..."); const messageButtonParent = document.querySelector(".profile-action-compose-option"); const messageButton = messageButtonParent ? messageButtonParent.querySelector("button") : null; if (messageButton) { console.log(messageButton.innerText); } else { console.error("Button not found"); } sendResponse({ complete: true, result: "Scrape and click completed" }); } if (msg.action === "BEGIN") { const urlPath = msg.urlPath; const tabId = msg.tabId; const activeTabPageResultsContainer = document.getElementsByClassName("reusable-search__result-container"); let individualResultContainer; let individualProfileContainer; const profileLinks = []; for (var i = 0; i < activeTabPageResultsContainer.length; i++) { individualResultContainer = activeTabPageResultsContainer[i]; individualProfileContainer = individualResultContainer.querySelector('.app-aware-link'); profileLinks.push(individualProfileContainer.getAttribute("href")); } const item = profileLinks[0]; console.log("Profile links collected:", { complete: true, result: "Profile links collected", tabId: tabId, message: "START", urlPath: item }); sendResponse({ complete: true, result: "Profile links collected", tabId: tabId, message: "START", urlPath: item }); } }); }; setTimeout(tryConnect, 1000); background.js 文件: chrome.runtime.onMessage.addListener((obj, sender, sendResponse) => { const message = obj.message; const urlPath = obj.urlPath; if (message === "START") { chrome.tabs.create({ url: urlPath, active: false }, function (tab) { console.log(`new tab created dynamically with id: ${tab.id}`); return new Promise((resolve, reject) => { chrome.tabs.sendMessage(tab.id, { action: "scrapeAndClick", message: "scrapeAndClick", urlPath: urlPath, tabId: tab.id }, function (response) { if (response && response.complete) { console.log(response); // sendResponse(response); resolve(response); } else { console.error('Error in scraping and clicking or response is undefined:', response); reject(response); } }); }); }); // Return true to indicate that sendResponse will be called asynchronously return true; } // Ensure to resolve the promise even if not using it return Promise.resolve(); }); manifest.json 文件包含以下内容: { "name": "Example page scraping", "version": "0.0.1", "description": "Scraping and submitting forms", "permissions": [ "storage", "tabs" ], "host_permissions": [ "https://*.example.com/*" ], "externally_connectable": { "matches": [ "*://*.example.com/*" ] }, "background": { "service_worker": "background.js" }, "content_scripts": [ { "matches": [ "*://*.example.com/*" ], "js": [ "contentScript.js" ] } ], "web_accessible_resources": [ { "resources": [ "assets/icon-16_x_16.png", "assets/icon-24_x_24.png", "assets/icon-32_x_32.png" ], "matches": [ "https://*.example.com/*" ] } ], "action": { "default_icon": { "16": "assets/icon-16_x_16.png", "24": "assets/icon-24_x_24.png", "32": "assets/icon-32_x_32.png" }, "default_title": "Example Scaping and Submission", "default_popup": "popup.html" }, "manifest_version": 3 } 我不断收到以下错误: i) 端口已断开。内容脚本可能无法注入。 ii) “未检查的runtime.lastError:无法建立连接。接收端不存在。” 创建新选项卡,但之后我收到上述错误 我认为你在这里有一个误解,伙计,chrome.runtime.onMessage仅接收通过chrome.runtime.sendMessage方法发送的消息。因此,您的内容脚本中不会收到使用 port.postMessage 从后台发送的消息。同步后台和内容脚本之间的通信方法可能会解决这些问题。需要注意的是,端口连接将在 5 分钟后自动关闭,应予以处理。

回答 1 投票 0

Chrome contextMenus API ContextType

我在这里查看 chrome.contextMenu 的 API。 列出的上下文类型有: “全部” “页” “框架” “选择” “关联” “可编辑” “图像” “视频” “声音的” “启动器” “浏览器操作” “page_act...

回答 1 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.