forked from tootyta/FlashBrowser2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
117 lines (104 loc) · 2.51 KB
/
main.js
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
const electron = require('electron');
const path = require('path');
const { app, BrowserWindow, Menu} = electron; //Menu generated for the purposes of visiting new URLs.
const prompt = require('electron-prompt'); //prompting system to get user URL
let pluginName = null; //put the right flash plugin in depending on the operating system.
switch (process.platform) {
case 'win32':
switch (process.arch) {
case 'ia32':
case 'x32':
pluginName = 'flashver/pepflashplayer32.dll'
console.log("ran!");
break
case 'x64':
pluginName = 'flashver/pepflashplayer64.dll'
console.log("ran!");
break
}
break
case 'linux':
switch (process.arch) {
case 'ia32':
case 'x32':
pluginName = 'flashver/libpepflashplayer.so' // added and tested :D
break
case 'x64':
pluginName = 'flashver/libpepflashplayer.so'
break
}
app.commandLine.appendSwitch('no-sandbox');
break
case 'darwin':
pluginName = 'flashver/PepperFlashPlayer.plugin'
break
}
app.commandLine.appendSwitch('ppapi-flash-path', path.join(__dirname, pluginName));
//CACHE IS ENABLED but restarted on launch!
//TODO: Support importing custom .swf files to play
let mainWindow;
function promptIt(isSplash, win) { //function to handle prompting
prompt({
title: "Flash Browser",
label: "URL: ",
inputAttrs: {
type: 'url'
},
type: 'input'
})
.then((r) => {
if (r == null) {
console.log("user cancelled!");
if (!isSplash) {
app.quit();
}
} else {
console.log('result', r);
if (isSplash) {
win.loadURL(r);
}
else {
win.loadURL(r);
win.maximize();
setTimeout(() => {
win.show(); //pauses program for 1 second to allow web-page to load before rendering.
}, 1000);
}
}
}).catch(console.error)
}
app.on('ready', function () {
var menu = Menu.buildFromTemplate([
{
label: 'Menu',
submenu: [
{
label: 'Change URL',
click() {
promptIt(true, win);
}
},
{
label: 'Exit',
click() {
app.quit();
}
}
]
}
])
Menu.setApplicationMenu(menu);
let win = new BrowserWindow({
show: false,
webPreferences: {
plugins: true
}
})
promptIt(false, win);
win.webContents.session.clearCache(function () {
//clearCache
});
})
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') app.quit(); //fricking darwin!! >:D
})