first commit

master
Liu Chao 2023-07-30 21:34:25 +08:00
commit ec251e8d0e
5 changed files with 49 additions and 0 deletions

4
background.js 100644
View File

@ -0,0 +1,4 @@
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.tabs.create({ url: 'chrome://flags/#enable-force-dark' });
});

BIN
icon.png 100644

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

21
manifest.json 100644
View File

@ -0,0 +1,21 @@
{
"manifest_version": 2,
"name": "Auto Dark Mode Toggle",
"version": "1.0",
"description": "Toggle the 'Auto Dark Mode for Web Contents' flag in Chrome://flags",
"icons": {
"16": "icon.png",
"48": "icon.png",
"128": "icon.png"
},
"browser_action": {
"default_popup": "popup.html"
},
"permissions": [
"tabs"
],
"background": {
"scripts": ["background.js"],
"persistent": false
}
}

11
popup.html 100644
View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<title>Auto Dark Mode Toggle</title>
<script src="popup.js"></script>
</head>
<body>
<h1>Auto Dark Mode Toggle</h1>
<button id="toggleButton">Toggle Auto Dark Mode</button>
</body>
</html>

13
popup.js 100644
View File

@ -0,0 +1,13 @@
document.addEventListener('DOMContentLoaded', function() {
var toggleButton = document.getElementById('toggleButton');
chrome.tabs.query({ active: true, currentWindow: true }, function(tabs) {
var tab = tabs[0];
var url = tab.url;
toggleButton.addEventListener('click', function() {
chrome.tabs.update(tab.id, { url: 'chrome://flags/#enable-force-dark' });
});
});
});