Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Commit 26ce42a

Browse files
authored
Merge pull request #7 from vcborn/dev
今度は大丈夫
2 parents d62e405 + 54ce13c commit 26ce42a

File tree

8 files changed

+73
-25
lines changed

8 files changed

+73
-25
lines changed

main.js

+25-24
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,26 @@ async function newtab() {
6969
if (store.get('bookmarks') == null) {
7070
store.set('bookmarks', [])
7171
}
72+
if (!fs.existsSync(path.join(app.getPath('userData'), 'custom.css'))) {
73+
fs.writeFile(
74+
path.join(app.getPath('userData'), 'custom.css'),
75+
`/*
76+
This is a CSS file to customize Reamix.
77+
It is applied to tabs and icons and not to pages such as settings.
78+
*/`
79+
)
80+
}
81+
if (
82+
!fs.existsSync(path.join(app.getPath('userData'), 'custom_setting.css'))
83+
) {
84+
fs.writeFile(
85+
path.join(app.getPath('userData'), 'custom_setting.css'),
86+
`/*
87+
This is a CSS file to customize Reamix.
88+
These apply to pages such as Home, Settings and Extensions.
89+
*/`
90+
)
91+
}
7292
if (store.get('adblocker')) {
7393
ElectronBlocker.fromPrebuiltAdsAndTracking(fetch).then((blocker) => {
7494
blocker.enableBlockingInSession(browserview.webContents.session)
@@ -577,33 +597,14 @@ ipcMain.handle('browserGoes', (e, index) => {
577597
ipcMain.handle('getBrowserUrl', (e, index) => {
578598
return bv[index].webContents.getURL()
579599
})
600+
ipcMain.handle('cssPath', () => {
601+
return app.getPath('userData')
602+
})
580603
ipcMain.handle('openCustomCSS', () => {
581-
if (fs.existsSync(path.join(app.getPath('userData'), 'custom.css'))) {
582-
shell.openPath(path.join(app.getPath('userData'), 'custom.css'))
583-
} else {
584-
fs.writeFile(
585-
path.join(app.getPath('userData'), 'custom.css'),
586-
`/*
587-
This is a CSS file to customize Reamix.
588-
It is applied to tabs and icons and not to pages such as settings.
589-
*/`
590-
)
591-
shell.openPath(path.join(app.getPath('userData'), 'custom.css'))
592-
}
604+
shell.openPath(path.join(app.getPath('userData'), 'custom.css'))
593605
})
594606
ipcMain.handle('openCustomSettingCSS', () => {
595-
if (fs.existsSync(path.join(app.getPath('userData'), 'custom_setting.css'))) {
596-
shell.openPath(path.join(app.getPath('userData'), 'custom_setting.css'))
597-
} else {
598-
fs.writeFile(
599-
path.join(app.getPath('userData'), 'custom_setting.css'),
600-
`/*
601-
This is a CSS file to customize Reamix.
602-
It is applied to tabs and icons and not to pages such as settings.
603-
*/`
604-
)
605-
shell.openPath(path.join(app.getPath('userData'), 'custom_setting.css'))
606-
}
607+
shell.openPath(path.join(app.getPath('userData'), 'custom_setting.css'))
607608
})
608609
ipcMain.handle('moveToNewTab', (e, index) => {
609610
bv[index].webContents.loadFile(`${__dirname}/src/pages/home.html`)

src/index.html

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
<title>Reamix</title>
77
<link rel="stylesheet" href="assets/styles/fonts.css">
88
<link rel="stylesheet" href="assets/styles/index.min.css">
9-
<link rel="stylesheet" href="assets/styles/custom.css">
109
</head>
1110

1211
<body>

src/pages/others.js

+10
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,13 @@ function deleteAll() {
7878
}
7979
node.deleteAll()
8080
}
81+
82+
async function css() {
83+
if (await node.getPath()) {
84+
const link = document.createElement('link')
85+
link.rel = 'stylesheet'
86+
link.href = (await node.getPath()) + '/custom_setting.css'
87+
document.head.appendChild(link)
88+
}
89+
}
90+
css()

src/pages/search.js

+10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
'use strict'
22

3+
async function css() {
4+
if (await node.getPath()) {
5+
const link = document.createElement('link')
6+
link.rel = 'stylesheet'
7+
link.href = (await node.getPath()) + '/custom_setting.css'
8+
document.head.appendChild(link)
9+
}
10+
}
11+
css()
12+
313
if (node.getSettings('background')) {
414
document.body.style.backgroundImage = `url("${node.getSettings(
515
'background'

src/pages/settings.js

+10
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,13 @@ const changeList = () => {
5151
const blocker = document.getElementById('blockList').value.split(/\r\n|\n/)
5252
node.setBlockList(blocker)
5353
}
54+
55+
async function css() {
56+
if (await node.getPath()) {
57+
const link = document.createElement('link')
58+
link.rel = 'stylesheet'
59+
link.href = (await node.getPath()) + '/custom_setting.css'
60+
document.head.appendChild(link)
61+
}
62+
}
63+
css()

src/script/event.js

+10
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
each()
44

5+
async function css() {
6+
if (await node.getPath()) {
7+
const link = document.createElement('link')
8+
link.rel = 'stylesheet'
9+
link.href = (await node.getPath()) + '/custom.css'
10+
document.head.appendChild(link)
11+
}
12+
}
13+
css()
14+
515
function each() {
616
document.querySelectorAll('.tab').forEach((i, item) => {
717
i.addEventListener('click', () => {

src/script/preload-browserview.js

+5
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,9 @@ contextBridge.exposeInMainWorld('node', {
120120
exitFullscreen: () => {
121121
ipcRenderer.invoke('exitFullscreen')
122122
},
123+
getPath: () => {
124+
if (window.location.href.includes('file:///')) {
125+
return ipcRenderer.invoke('cssPath')
126+
}
127+
},
123128
})

src/script/preload.js

+3
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,7 @@ contextBridge.exposeInMainWorld('node', {
124124
saveFav: (name, link) => {
125125
ipcRenderer.invoke('saveFav', name, link)
126126
},
127+
getPath: () => {
128+
return ipcRenderer.invoke('cssPath')
129+
},
127130
})

0 commit comments

Comments
 (0)