├── LICENSE ├── README.md ├── icon.png ├── main.js ├── manifest.json ├── preload.js ├── renderer.js └── style.css /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 XiaoHe321 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LiteLoaderQQNT - custom-css 2 | 3 | LiteLoaderQQNT主题,用于加载任意CSS(会应用到所有页面,所以CSS请尽可能针对性设计)。 4 | 5 | 本插件修改自[LiteLoaderQQNT-Test-Theme](https://github.com/mo-jinran/test-theme)。 6 | 7 | 使用前需要安装[LiteLoaderQQNT](https://github.com/mo-jinran/LiteLoaderQQNT),并在QQNT新版上使用。 8 | 9 | ## 使用方法 10 | 11 | *建议从`LiteLoaderQQNT`应用商店中直接下载安装,方便快捷。*(新版本1.0`LiteLoaderQQNT`没有插件商店了,请遵循[手动安装方法](https://liteloaderqqnt.github.io/guide/plugins.html)) 12 | 13 | **版本不兼容提示**:从0.1.1起,插件已适配1.0版本以上`LiteLoaderQQNT`框架,同时不再兼容旧版框架,请遵循[安装方法](https://liteloaderqqnt.github.io/guide/install.html)更新框架。 14 | 15 | 16 | 17 | 18 | 19 | 也可以clone或下载zip文件解压,保留文件夹结构(文件夹名称为`插件名`,内容为github上的内容),将文件夹移动至`LiteLoaderQQNT数据目录/plugins/`下面,重启QQNT即可。 20 | 21 | 启用主题后,对style.css的任何修改,保存后都会立刻生效。 22 | 23 | **自带的CSS是对自己的发言文字修改为红色,请自行修改CSS文件。** 24 | 25 | 如有对单独页面应用CSS的需求,请发ISSUE。 26 | 27 | ## 协议及免责 28 | 29 | MIT | 禁止用于任何非法用途,插件开发属学习与研究目的,仅自用,未提供给任何第三方使用。任何不当使用导致的任何侵权问题责任自负。 30 | -------------------------------------------------------------------------------- /icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xh321/LiteLoaderQQNT-Custom-CSS/ed72ceafcac23ed6697d09611542bcaf8a7e5f72/icon.png -------------------------------------------------------------------------------- /main.js: -------------------------------------------------------------------------------- 1 | const fs = require("fs"); 2 | const path = require("path"); 3 | const { BrowserWindow, ipcMain } = require("electron"); 4 | 5 | // 防抖函数 6 | function debounce(fn, time) { 7 | let timer = null; 8 | return function (...args) { 9 | timer && clearTimeout(timer); 10 | timer = setTimeout(() => { 11 | fn.apply(this, args); 12 | }, time); 13 | }; 14 | } 15 | 16 | // 更新样式 17 | function updateStyle(webContents) { 18 | const csspath = path.join(__dirname, "style.css"); 19 | fs.readFile(csspath, "utf-8", (err, data) => { 20 | if (err) { 21 | return; 22 | } 23 | webContents.send("LiteLoader.custom_css.updateStyle", data); 24 | }); 25 | } 26 | 27 | // 监听CSS修改-开发时候用的 28 | function watchCSSChange(webContents) { 29 | const filepath = path.join(__dirname, "style.css"); 30 | fs.watch( 31 | filepath, 32 | "utf-8", 33 | debounce(() => { 34 | updateStyle(webContents); 35 | }, 100) 36 | ); 37 | } 38 | 39 | onLoad(); 40 | 41 | function onLoad() { 42 | ipcMain.on("LiteLoader.custom_css.rendererReady", (event, message) => { 43 | const window = BrowserWindow.fromWebContents(event.sender); 44 | updateStyle(window.webContents); 45 | }); 46 | } 47 | 48 | function onBrowserWindowCreated(window) { 49 | watchCSSChange(window.webContents); 50 | } 51 | 52 | module.exports = { 53 | onBrowserWindowCreated 54 | }; 55 | -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifest_version": 4, 3 | "type": "theme", 4 | "name": "自定义 CSS 样式", 5 | "slug": "custom_css", 6 | "description": "用来自定义 CSS 样式", 7 | "version": "0.1.1", 8 | "icon": "./icon.png", 9 | "authors": [ 10 | { 11 | "name": "XiaoHe321", 12 | "link": "https://github.com/xh321" 13 | } 14 | ], 15 | "repository": { 16 | "repo": "xh321/LiteLoaderQQNT-Custom-CSS", 17 | "branch": "master", 18 | "release": { 19 | "tag": "0.1.1" 20 | } 21 | }, 22 | "platform": ["win32", "darwin", "linux"], 23 | "injects": { 24 | "renderer": "./renderer.js", 25 | "main": "./main.js", 26 | "preload": "./preload.js" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /preload.js: -------------------------------------------------------------------------------- 1 | const { contextBridge, ipcRenderer } = require("electron"); 2 | 3 | 4 | contextBridge.exposeInMainWorld("custom_css", { 5 | updateStyle: (callback) => ipcRenderer.on( 6 | "LiteLoader.custom_css.updateStyle", 7 | callback 8 | ), 9 | rendererReady: () => ipcRenderer.send( 10 | "LiteLoader.custom_css.rendererReady" 11 | ) 12 | }); -------------------------------------------------------------------------------- /renderer.js: -------------------------------------------------------------------------------- 1 | function onLoad() { 2 | const element = document.createElement("style"); 3 | document.head.appendChild(element); 4 | 5 | custom_css.updateStyle((event, message) => { 6 | element.textContent = message; 7 | }); 8 | 9 | custom_css.rendererReady(); 10 | } 11 | onLoad(); -------------------------------------------------------------------------------- /style.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xh321/LiteLoaderQQNT-Custom-CSS/ed72ceafcac23ed6697d09611542bcaf8a7e5f72/style.css --------------------------------------------------------------------------------