mirror of
https://github.com/black7375/Firefox-UI-Fix.git
synced 2026-04-27 15:51:06 -07:00
Add: Web Extension - Prototype of AGENT/USER Sheet theme
Need copy `css/`, `icons` at addon
This commit is contained in:
parent
b634cd6ae5
commit
d3b9669221
10 changed files with 175 additions and 2 deletions
5
CREDITS
5
CREDITS
|
|
@ -209,6 +209,11 @@ W: https://github.com/mozilla/multi-account-containers
|
|||
C: Copyright (c) 1998–2021 The Mozilla Foundation
|
||||
L: MPL 2.0
|
||||
|
||||
N: Paxmod
|
||||
W: https://github.com/numirias/paxmod
|
||||
C: Copyright (c) 2017 numirias
|
||||
L: MIT
|
||||
|
||||
N: plyr
|
||||
W: https://github.com/sampotts/plyr
|
||||
C: Copyright (c) 2017 Sam Potts
|
||||
|
|
|
|||
7
addon/background.html
Normal file
7
addon/background.html
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<script type="module" src="background.js"></script>
|
||||
</head>
|
||||
</html>
|
||||
14
addon/background.js
Normal file
14
addon/background.js
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
const globalSheet = browser.runtime.getURL("css/leptonChrome.css");
|
||||
const contentSheet = browser.runtime.getURL("css/leptonContent.css");
|
||||
|
||||
// https://searchfox.org/mozilla-central/source/layout/base/nsIStyleSheetService.idl
|
||||
async function startup() {
|
||||
if (!("stylesheet" in browser)) {
|
||||
alert("MISSING API");
|
||||
}
|
||||
|
||||
browser.stylesheet.load(globalSheet, "AGENT_SHEET");
|
||||
browser.stylesheet.load(contentSheet, "USER_SHEET");
|
||||
}
|
||||
|
||||
startup();
|
||||
39
addon/manifest.json
Normal file
39
addon/manifest.json
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
{
|
||||
"manifest_version": 2,
|
||||
"name": "Lepton",
|
||||
"version": "7.0.0",
|
||||
"description": "I respect proton UI and aim to improve it. ",
|
||||
"author": "alstjr7375 <alstjr7375@daum.net>",
|
||||
"homepage_url": "https://github.com/black7375/Firefox-UI-Fix",
|
||||
"applications": {
|
||||
"gecko": {
|
||||
"id": "lepton@black7375",
|
||||
"strict_min_version": "89.0"
|
||||
}
|
||||
},
|
||||
"icons": {
|
||||
"16": "icons/default16.png",
|
||||
"48": "icons/default48.png",
|
||||
"128": "icons/default128.png"
|
||||
},
|
||||
"permissions": [
|
||||
"idle",
|
||||
"management",
|
||||
"storage",
|
||||
"tabs",
|
||||
"theme"
|
||||
],
|
||||
"background": {
|
||||
"page": "background.html"
|
||||
},
|
||||
"experiment_apis": {
|
||||
"stylesheet": {
|
||||
"schema": "stylesheet-api-experiment/schema.json",
|
||||
"parent": {
|
||||
"scopes": ["addon_parent"],
|
||||
"paths": [["stylesheet"]],
|
||||
"script": "stylesheet-api-experiment/api.js"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
52
addon/stylesheet-api-experiment/api.js
Normal file
52
addon/stylesheet-api-experiment/api.js
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
"use strict";
|
||||
|
||||
const { classes: Cc, interfaces: Ci } = Components;
|
||||
|
||||
let sss = Cc["@mozilla.org/content/style-sheet-service;1"].getService(Ci.nsIStyleSheetService);
|
||||
let ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
||||
|
||||
let sheetsMap = new WeakMap();
|
||||
|
||||
|
||||
this.stylesheet = class extends ExtensionAPI {
|
||||
|
||||
onShutdown(reason) {
|
||||
let {extension} = this;
|
||||
for (let sheet of sheetsMap.get(extension)) {
|
||||
let uriObj = ios.newURI(sheet.uri, null, null);
|
||||
sss.unregisterSheet(uriObj, sss[sheet.type]);
|
||||
}
|
||||
sheetsMap.delete(extension);
|
||||
}
|
||||
|
||||
getAPI(context) {
|
||||
let {extension} = context;
|
||||
if (!sheetsMap.has(extension)) {
|
||||
sheetsMap.set(extension, new Array());
|
||||
}
|
||||
let loadedSheets = sheetsMap.get(extension);
|
||||
return {
|
||||
stylesheet: {
|
||||
async load(uri, type) {
|
||||
let uriObj = ios.newURI(uri, null, null);
|
||||
if (!sss.sheetRegistered(uriObj, sss[type])) {
|
||||
sss.loadAndRegisterSheet(uriObj, sss[type]);
|
||||
loadedSheets.push({uri: uri, type: type});
|
||||
}
|
||||
},
|
||||
async unload(uri, type) {
|
||||
let uriObj = ios.newURI(uri, null, null);
|
||||
if (sss.sheetRegistered(uriObj, sss[type])) {
|
||||
sss.unregisterSheet(uriObj, sss[type]);
|
||||
let index = loadedSheets.findIndex(s => s.uri == uri && s.type == type);
|
||||
loadedSheets.splice(index, 1);
|
||||
}
|
||||
},
|
||||
async isLoaded(uri, type) {
|
||||
let uriObj = ios.newURI(uri, null, null);
|
||||
return sss.sheetRegistered(uriObj, sss[type]);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
56
addon/stylesheet-api-experiment/schema.json
Normal file
56
addon/stylesheet-api-experiment/schema.json
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
[
|
||||
{
|
||||
"namespace": "stylesheet",
|
||||
"description": "Basic access to StyleSheetService",
|
||||
"functions": [
|
||||
{
|
||||
"name": "load",
|
||||
"type": "function",
|
||||
"description": "Loads stylesheet",
|
||||
"async": true,
|
||||
"parameters": [
|
||||
{
|
||||
"name": "uri",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "type",
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "unload",
|
||||
"type": "function",
|
||||
"description": "Unloads stylesheet",
|
||||
"async": true,
|
||||
"parameters": [
|
||||
{
|
||||
"name": "uri",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "type",
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "isLoaded",
|
||||
"type": "function",
|
||||
"description": "Returns whether sheet is loaded",
|
||||
"async": true,
|
||||
"parameters": [
|
||||
{
|
||||
"name": "uri",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "type",
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
BIN
icons/default128.png
Normal file
BIN
icons/default128.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
BIN
icons/default16.png
Normal file
BIN
icons/default16.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 757 B |
BIN
icons/default48.png
Normal file
BIN
icons/default48.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.4 KiB |
|
|
@ -23,8 +23,8 @@
|
|||
"verbose": true,
|
||||
"sourceDir": "addon",
|
||||
"build": {
|
||||
"overwriteDest": true,
|
||||
}
|
||||
"overwriteDest": true
|
||||
},
|
||||
"run": {
|
||||
"firefox": "nightly",
|
||||
"pref": [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue