Browse Source

项目初始化

master
xyiege 1 year ago
commit
1341bae562
  1. 24
      douyin/background.js
  2. 16
      douyin/manifest.json
  3. 38
      douyin/popup.html
  4. 24
      douyin/popup.js
  5. 1
      readme.md

24
douyin/background.js

@ -0,0 +1,24 @@
console.log('抖音扩展背景脚本已加载');
chrome.runtime.onInstalled.addListener(() => {
console.log("抖音扩展已安装");
});
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
if (request.action === 'openIncognitoDouyin') {
chrome.windows.create({
incognito: true,
url: "https://www.douyin.com"
}, function(window) {
console.log('抖音隐身窗口已打开');
// 这里可以添加自动登录的逻辑
});
} else if (request.action === 'openLiveIncognito') {
chrome.windows.create({
incognito: true,
url: request.url
}, function(window) {
console.log('直播隐身窗口已打开');
});
}
});

16
douyin/manifest.json

@ -0,0 +1,16 @@
{
"manifest_version": 3,
"name": "抖音圣火",
"version": "1.0",
"description": "控制浏览器打开抖音隐身窗口和指定直播窗口的扩展",
"permissions": [
"tabs",
"storage"
],
"background": {
"service_worker": "background.js"
},
"action": {
"default_popup": "popup.html"
}
}

38
douyin/popup.html

@ -0,0 +1,38 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>抖音圣火</title>
<style>
body {
width: 200px;
padding: 10px;
}
input, button {
width: 100%;
margin-top: 5px;
margin-bottom: 10px;
}
label {
display: block;
margin-top: 10px;
font-weight: bold;
}
</style>
</head>
<body>
<label for="username">账号:</label>
<input type="text" id="username" placeholder="输入账号">
<label for="password">密码:</label>
<input type="password" id="password" placeholder="输入密码">
<button id="openIncognito">打开抖音隐身窗口</button>
<label for="liveId">直播间ID:</label>
<input type="text" id="liveId" placeholder="输入直播间ID">
<button id="openLive">打开直播窗口</button>
<script src="popup.js"></script>
</body>
</html>

24
douyin/popup.js

@ -0,0 +1,24 @@
document.addEventListener('DOMContentLoaded', function() {
var openIncognitoButton = document.getElementById('openIncognito');
var usernameInput = document.getElementById('username');
var passwordInput = document.getElementById('password');
openIncognitoButton.addEventListener('click', function() {
const username = usernameInput.value;
const password = passwordInput.value;
chrome.runtime.sendMessage({
action: 'openIncognitoDouyin',
username: username,
password: password
});
});
document.getElementById('openLive').addEventListener('click', () => {
const liveId = document.getElementById('liveId').value;
if (liveId) {
const liveUrl = `https://live.douyin.com/${liveId}`;
chrome.runtime.sendMessage({ action: 'openLiveIncognito', url: liveUrl });
}
});
});

1
readme.md

@ -0,0 +1 @@
chrome 插件
Loading…
Cancel
Save