forked from fm16191/FlashBrowser-linux
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbrowser.html
More file actions
403 lines (360 loc) · 16.4 KB
/
browser.html
File metadata and controls
403 lines (360 loc) · 16.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="themes/chrome-like.css">
</head>
<p id='topspacer' style="color:grey;font-size:1px; height:28px; min-height:28px !important; -webkit-app-region: drag;">
</p>
<div id="flash-tabs" style="display: inline;">
<embed id="FlashTab1" src="about:blank#404" style='display: none;' width="320" height="200"></embed>
<embed id="FlashTab2" src="about:blank#404" style='display: none;' width="320" height="200"></embed>
<embed id="FlashTab3" src="about:blank#404" width="320" style='display: none;' width="320" height="200"></embed>
</div>
<div id="overlay">
<button onclick="showHideSettings()"
style="width: 100%; font-size: 27px; border: none; background: none; color: hotpink; background-color: #222222; text-align: center;">close</button>
<div id="favoritesDiv">
<ul>
<li><a href="about:blank#404" target="_blank" onclick="jsfunction(event)">Link 1</a></li>
<li><a href="#">Link 2</a></li>
</ul>
</div>
</div>
<body>
<div id="window-controls">
<div class="button" id="min-button">
<img class="icon"
srcset="icons/min-w-10.png 1x, icons/min-w-12.png 1.25x, icons/min-w-15.png 1.5x, icons/min-w-15.png 1.75x, icons/min-w-20.png 2x, icons/min-w-20.png 2.25x, icons/min-w-24.png 2.5x, icons/min-w-30.png 3x, icons/min-w-30.png 3.5x"
draggable="false" />
</div>
<div class="button" id="max-button">
<img class="icon"
srcset="icons/max-w-10.png 1x, icons/max-w-12.png 1.25x, icons/max-w-15.png 1.5x, icons/max-w-15.png 1.75x, icons/max-w-20.png 2x, icons/max-w-20.png 2.25x, icons/max-w-24.png 2.5x, icons/max-w-30.png 3x, icons/max-w-30.png 3.5x"
draggable="false" />
</div>
<div class="button" id="restore-button">
<img class="icon"
srcset="icons/restore-w-10.png 1x, icons/restore-w-12.png 1.25x, icons/restore-w-15.png 1.5x, icons/restore-w-15.png 1.75x, icons/restore-w-20.png 2x, icons/restore-w-20.png 2.25x, icons/restore-w-24.png 2.5x, icons/restore-w-30.png 3x, icons/restore-w-30.png 3.5x"
draggable="false" />
</div>
<div class="button" id="close-button">
<img class="icon"
srcset="icons/close-w-10.png 1x, icons/close-w-12.png 1.25x, icons/close-w-15.png 1.5x, icons/close-w-15.png 1.75x, icons/close-w-20.png 2x, icons/close-w-20.png 2.25x, icons/close-w-24.png 2.5x, icons/close-w-30.png 3x, icons/close-w-30.png 3.5x"
draggable="false" />
</div>
</div>
<div id="nav-body-tabs"></div>
<div id="nav-body-ctrls"></div>
<div id="nav-body-views"></div>
<script>
const { ipcRenderer } = require('electron');
const Store = require('./store');
const store = new Store({
configName: 'user-preferences'
});
let home
try {
home = store.get('homepage');
}
catch (error) {
home = null;
}
const enav = new (require('electron-navigation'))({
defaultFavicons: true,
newTabCallback: (url, options) => {
options.postTabOpenCallback = webview => {
webview.setAttribute('plugins', '');
}
return { options };
}
});
function toggleFullscreen(event) {
if (event.key === 'Escape') {
ipcRenderer.send('fullScreen-click');
isFullScreen = false;
header.style.display = oldStyle;
tabs.style.display = oldStyle1;
nav.style.display = oldStyle2;
topspacer.style.display = oldStyle3;
}
if (event.type === 'click') {
ipcRenderer.send('fullScreen-click');
}
if (event.key === 'F11' || event.type === 'click') {
isFullScreen = !isFullScreen;
header.style.display = isFullScreen ? "none" : oldStyle;
tabs.style.display = isFullScreen ? "none" : oldStyle1;
nav.style.display = isFullScreen ? "none" : oldStyle2;
topspacer.style.display = isFullScreen ? "none" : oldStyle3;
}
}
window.addEventListener('keyup', toggleFullscreen, true);
let nav = document.getElementById('nav-body-ctrls');
let tabs = document.getElementById('nav-body-tabs');
let header = document.getElementById('window-controls');
let topspacer = document.getElementById('topspacer');
let controls = document.getElementById('nav-body-ctrls');
let oldStyle = getComputedStyle(header).display;
let oldStyle1 = getComputedStyle(tabs).display;
let oldStyle2 = getComputedStyle(nav).display;
let oldStyle3 = getComputedStyle(topspacer).display;
const { clipboard } = require('electron');
//clipboard.writeText('Example String');
let clipboardStr = clipboard.readText();
var length = window.process.argv.length;
var lastArgument = window.process.argv[length - 1]
if (lastArgument && lastArgument.indexOf("file:///") == 0) {
console.log(lastArgument);
enav.newTab(lastArgument, {
title: 'Local file'
})
}
// else if (clipboardStr.indexOf("https://") == 0) {
// enav.newTab(clipboardStr);
// // mainWindow.show();
// }
else if (home) {
console.log("WE HAGE CUSTOM HOMEPAGE" + home);
enav.newTab(home, { icon: "icons/restore-w-24.png" })
}
else {
enav.newTab('https://www.duckduckgo.com', { icon: "clear" });
}
/// Set Favorite Button
let setFavoriteButton = document.createElement("button");
setFavoriteButton.id = 'fs-button';
setFavoriteButton.innerHTML = '⭐️';
setFavoriteButton.title = "Set as Favorite"
setFavoriteButton.onclick = setFavorit;
controls.appendChild(setFavoriteButton);
function setFavorit(event) {
let favURL = document.getElementById('nav-ctrls-url').value;
console.log("set fav" + favURL);
const { remote } = require('electron');
const mainProcess = remote.require('./index');
mainProcess.setFavorite(favURL); // 'Yay'
}
// Set Home
let setHomeButton = document.createElement("button");
setHomeButton.id = 'fs-button';
setHomeButton.innerHTML = '🏠';
setHomeButton.title = 'Set as hompage';
setHomeButton.onclick = setHome;
controls.appendChild(setHomeButton);
function setHome(event) {
let homeURL = document.getElementById('nav-ctrls-url').value;
const { remote } = require('electron');
const mainProcess = remote.require('./index');
mainProcess.sethome(homeURL); // 'Yay'
}
//Zoom In out
let zoomInButton = document.createElement("button");
zoomInButton.id = 'fs-button';
zoomInButton.innerHTML = '➕';
zoomInButton.title = 'Zoom In';
zoomInButton.onclick = zoomIn;
controls.appendChild(zoomInButton);
function zoomIn(event) {
webview = document.getElementById('nav-body-views').getElementsByClassName("active")[0];
if (webview) {
webview.zoomFactor = webview.getZoomFactor() + 0.2//1
}
}
let zoomOutButton = document.createElement("button");
zoomOutButton.id = 'fs-button';
zoomOutButton.innerHTML = '➖';
zoomInButton.title = 'Zoom Out';
zoomOutButton.onclick = zoomOut;
controls.appendChild(zoomOutButton);
function zoomOut(event) {
webview = document.getElementById('nav-body-views').getElementsByClassName("active")[0];
if (webview) {
webview.zoomFactor = webview.getZoomFactor() - 0.2//1
}
}
//FullScreen Buton
let isFullScreen = false;
let fsButton = document.createElement("button");
fsButton.id = 'fs-button';
fsButton.title = "FullScreen"
fsButton.innerHTML = '🔳️';
fsButton.onclick = toggleFullscreen;
controls.appendChild(fsButton);
// Mute button
let muteButton = document.createElement("button");
muteButton.id = 'fs-button';
muteButton.innerHTML = '🔊';
muteButton.title = "Mute/UnMute"
muteButton.onclick = onMute;
controls.appendChild(muteButton);
function onMute(event) {
webview = document.getElementById('nav-body-views').getElementsByClassName("active")[0];
if (webview) {
if (webview.isAudioMuted()) {
webview.setAudioMuted(false);
muteButton.innerHTML = '🔊';
}
else {
webview.setAudioMuted(true);
muteButton.innerHTML = '🔈';
}
}
}
///// Clear Cache Button ////
let clearCachButton = document.createElement("button");
clearCachButton.id = 'fs-button';
clearCachButton.innerHTML = '🧹️';
clearCachButton.title = 'Clear Cache & Restart'
clearCachButton.onclick = clearChache;
controls.appendChild(clearCachButton);
function clearChache(event) {
if (event.type === 'click') {
ipcRenderer.send('clearChache-click');
}
}
/////Settings Button /////
let settingsButton = document.createElement("button");
settingsButton.id = 'fs-button';
settingsButton.innerHTML = '⚙️';
settingsButton.title = "Show/Hide Settings";
settingsButton.onclick = showSettings;
controls.appendChild(settingsButton);
function showSettings(event) {
if (event.type === 'click') {
const { ipcRenderer } = require('electron');
ipcRenderer.send('show-settings-request');
}
}
function jsfunction(e) {
//console.log(e.target.href)
e.preventDefault(); //optional);
enav.newTab(e.target.href);
}
var div = document.getElementById('overlay');
div.style = "display: none;";
require('electron').ipcRenderer.on('ping', showHideSettings);
function showHideSettings(event, message, refresh) {
var div = document.getElementById('overlay');
let ht = window.getComputedStyle(div, null).getPropertyValue("display");
console.log("showHideSettings called, current display: " + ht + ", refresh: " + refresh);
if (ht === 'none' && !refresh) {
// Show settings and populate favorites
document.getElementById('favoritesDiv').innerHTML = "";
document.getElementById('favoritesDiv').appendChild(makeUL(message));
div.style.display = "block";
}
else if (refresh && ht === "block") {
// Refresh favorites list while keeping overlay visible
document.getElementById('favoritesDiv').innerHTML = "";
document.getElementById('favoritesDiv').appendChild(makeUL(message));
div.style.display = "block";
}
else {
// Hide settings
div.style.display = "none";
}
}
function makeUL(array) {
// Create the list element:
var list = document.createElement('ul');
// Guard against undefined or non-array input
if (!array || !Array.isArray(array) || array.length === 0) {
var item = document.createElement('li');
item.style = 'color:hotpink;font-size: 23px;text-align:center;';
item.textContent = 'No favorites yet. Add some sites!';
list.appendChild(item);
return list;
}
for (var i = 0; i < array.length; i++) {
// Create the list item:
var item = document.createElement('li');
if (typeof array[i] === 'string') {
var a = document.createElement('a')
a.text = array[i].replace(/(^\w+:|^)\/\//, '').replace("www.", "");
a.href = array[i]
a.style = 'color:hotpink;font-size: 23px;'
a.onclick = jsfunction;
let btn = document.createElement("button");
btn.innerHTML = " remove";
btn.id = i;
btn.style = "border: none; background: none; color: hotpink; background-color: #222222; margin-left: 30px; ";
btn.onclick = function (event) {
ipcRenderer.send('remove-favorite', event.target.id);
};
item.style = 'color:hotpink;font-size: 23px;'
item.appendChild(a);
item.appendChild(btn);
// Set its contents:
//item.appendChild(document.createTextNode(array[i]));
// Add it to the list:
list.appendChild(item);
}
}
return list;
}
/// Suggest nav bar
let navBar = document.getElementById('nav-ctrls-url')
navBar.addEventListener('keyup', checkFavorites);
function checkFavorites(e) {
console.log('checkFavorites');
let listFavorites = store.get('favorites');
let inputText = navBar.value;
let deURL;
for (var i = 0; i < listFavorites.length; i++) {
deURL = listFavorites[i].replace(/(^\w+:|^)\/\//, '');
deURL = deURL.replace("www.", "");
//console.log(i + " " + listFavorites[i] + "!" + deURL);
if (e.keyCode != 8 && e.keyCode != 17 && !e.ctrlKey && deURL != inputText && deURL && deURL.indexOf(inputText) == 0) {
console.log("Fond it" + deURL)
navBar.value = deURL;
navBar.setSelectionRange(inputText.length, 999);
}
}
}
//Find on Page
let finInwebview = document.getElementById('nav-body-views').getElementsByClassName("active")[0];
const FindInPage = require('electron-find').FindInPage;
const { remote } = require('electron');
let findInPage = new FindInPage(remote.getCurrentWebContents(), {
parentElement: document.querySelector('#nav-body-views'), offsetTop: 70, boxBgColor: '#000000', boxShadowColor: '#111111'
});
ipcRenderer.on('on-find', (e, args) => {
findInPage.openFindWindow();
console.log(223 + document.querySelector('#nav-body-views'));
})
// Note: Removed problematic closeTab listener that was triggering on tab clicks
// and causing unwanted navigation to flash.pm. The electron-navigation library
// handles tab closing internally.
// Window controls
const windowControls = document.getElementById('window-controls');
// Check initial window state
ipcRenderer.send('check-window-state');
ipcRenderer.on('window-state-checked', (event, isMaximized) => {
if (isMaximized) {
windowControls.classList.add('maximized');
} else {
windowControls.classList.remove('maximized');
}
});
document.getElementById('min-button').addEventListener('click', () => {
ipcRenderer.send('minimize-window');
});
document.getElementById('max-button').addEventListener('click', () => {
ipcRenderer.send('maximize-window');
});
document.getElementById('restore-button').addEventListener('click', () => {
ipcRenderer.send('unmaximize-window');
});
document.getElementById('close-button').addEventListener('click', () => {
ipcRenderer.send('close-window');
});
// Listen for window state changes
ipcRenderer.on('window-maximized', () => {
windowControls.classList.add('maximized');
});
ipcRenderer.on('window-unmaximized', () => {
windowControls.classList.remove('maximized');
});
</script>
</body>
</html>