使用JavaScript自动化Google Meet的”询问加入”页面
在本文中,我们将创建一个Chrome扩展程序,可以帮助我们使用JavaScript自动化Google Meet的”询问加入”页面。该扩展程序可以帮助我们自动关闭Google Meet中的音频和视频按钮,然后自动点击”询问加入”按钮。
让我们开始项目:
第1步: 首先,您需要为Chrome扩展程序创建一个manifest.json文件,让我们来创建它。
{
"name": "automatic class joiner",
"version": "1.0",
"manifest_version": 2,
"content_scripts": [{
"matches": [""],
"js": ["content.js"]
}],
"browser_action": {
"default_popup": "popup.html",
"default_title": "automatic class joiner"
}
}
现在我们完成了我们的清单文件。每当打开一个新的URL时,清单文件将运行名为content.js的脚本。
第2步: 现在让我们为我们的Chrome扩展程序创建一个简单的前端界面。我们创建一个名为popup.html的新HTML文件。
<!DOCTYPE html>
<html>
<head>
<title>Online class joiner</title>
<link rel="stylesheet" href="online.css"
type="text/css" />
</head>
<body>
<h2>Joiner Active</h2>
<p>
You will automatically join the
classes when this extension is ON.
</p>
</body>
</html>
现在我们已经完成了前端部分,让我们构建扩展的主要功能,即content.js脚本文件。
第3步: 现在我们需要创建一个名为content.js的新文件。
function start() {
url = location.href;
if (url.includes("meet.google.com")) {
its_meet();
}
}
function its_meet() {
items = document.getElementsByTagName('div');
setTimeout(function() {
try {
for (i = 0; i < items.length; i++) {
if (items[i].hasAttribute("aria-label")) {
if (items[i].getAttribute("aria-label")
.includes("microphone") ||
items[i].getAttribute("aria-label")
.includes("camera")) {
items[i].click();
}
}
}
} catch (err) {
console.log(err);
}
}, 5000)
setTimeout(function() {
for (i = 0; i < items.length; i++) {
if (items[i].hasAttribute("jsname")) {
if (items[i].getAttribute("jsname")
.includes("Qx7uuf")) {
items[i].click();
}
}
}
}, 8000);
}
start();
在完成了这么多的工作之后,我们的扩展程序已经完成了。
第4步: 让我们试着运行它。
首先,您需要将它添加到您的Google Chrome扩展程序中,然后放松一下,让扩展程序来完成工作。
输出:

对于GitHub repo,请点击https://github.com/Abhishek07Kalra/AutomaticClassJoiner
极客教程