├── .gitignore ├── README.md ├── app.js ├── icon ├── all.svg ├── linux.png ├── mac.icns └── win.ico ├── index.js ├── info.js └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | package-lock.json 3 | app.json 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # electrolite 2 | 3 | Electron based lite-wrap for any website. 4 | 5 | ```js 6 | // install globally 7 | npm install -g electrolite 8 | 9 | // open any site as an app 10 | electrolite mobile.twitter.com 11 | electrolite twitter.com 12 | ``` 13 | -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | require('child_process').spawn( 4 | require('electron'), 5 | [require('path').join(__dirname, 'index.js')] 6 | .concat(require('./info').url, process.argv.slice(3)), 7 | {detached: true, stdio: 'inherit'} 8 | ).unref(); 9 | -------------------------------------------------------------------------------- /icon/all.svg: -------------------------------------------------------------------------------- 1 | 2 | 13 | 15 | 17 | 18 | 20 | image/svg+xml 21 | 23 | 24 | 25 | 26 | 27 | 30 | 33 | 38 | 44 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /icon/linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebReflection/electrolite/4919a8cad9813b80efa8b7f10e232c601cd64de2/icon/linux.png -------------------------------------------------------------------------------- /icon/mac.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebReflection/electrolite/4919a8cad9813b80efa8b7f10e232c601cd64de2/icon/mac.icns -------------------------------------------------------------------------------- /icon/win.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebReflection/electrolite/4919a8cad9813b80efa8b7f10e232c601cd64de2/icon/win.ico -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; // by Andrea Giammarchi - @WebReflection 2 | 3 | var 4 | fs = require('fs'), 5 | path = require('path'), 6 | electron = require('electron'), 7 | dbPath = path.join(__dirname, 'app.json'), 8 | db = fs.existsSync(dbPath) ? require(dbPath) : {}, 9 | info = require('./info'), 10 | url = info.url, 11 | app = electron.app, 12 | BrowserWindow = electron.BrowserWindow 13 | ; 14 | 15 | if (!db.hasOwnProperty(url)) db[url] = {}; 16 | 17 | app.commandLine.appendSwitch('--ignore-gpu-blacklist'); 18 | app.once('ready', function () { 19 | var 20 | area = electron.screen.getPrimaryDisplay().workAreaSize, 21 | width = db[url].width || 320, 22 | height = db[url].height || 568, 23 | x = db[url].x || Math.round((area.width - width) / 2), 24 | y = db[url].y || Math.round((area.height - height) / 2), 25 | updateDB = function (e) { 26 | var 27 | position = e.sender.getPosition(), 28 | size = e.sender.getSize(), 29 | x = position[0], 30 | y = position[1], 31 | width = size[0], 32 | height = size[1] 33 | ; 34 | db[url] = { 35 | lastVisit: new Date(), 36 | x: x, 37 | y: y, 38 | width: width, 39 | height: height 40 | }; 41 | } 42 | ; 43 | 44 | new BrowserWindow({ 45 | x: x, y: y - (process.platform === 'linux' ? 38 : 0), 46 | width: width, height: height, 47 | title: info.hostname, 48 | icon: path.join(__dirname, 'icon', ( 49 | process.platform === 'linux' ? 50 | 'linux.png' : ( 51 | process.platform === 'win32' ? 52 | 'win.ico' : 53 | 'mac.icns' 54 | ) 55 | )), 56 | autoHideMenuBar: true, 57 | webPreferences: { 58 | experimentalFeatures: true, 59 | nodeIntegration: false 60 | } 61 | }) 62 | .on('move', updateDB) 63 | .on('resize', updateDB) 64 | .once('closed', function () { 65 | fs.writeFileSync(dbPath, JSON.stringify(db, null, ' ')); 66 | }) 67 | .loadURL(url); 68 | 69 | }); 70 | -------------------------------------------------------------------------------- /info.js: -------------------------------------------------------------------------------- 1 | var url = process.argv[2]; 2 | if (url && !/^https?:\/\//.test(url)) url = 'https://' + url; 3 | 4 | try { 5 | module.exports = { 6 | url: url, 7 | hostname: require('url').parse(url).hostname 8 | }; 9 | } catch(o_O) { 10 | console.error( 11 | '\nusage: electrolite ${url}', 12 | '\nerror: invalid url ' + o_O.message + '\n' 13 | ); 14 | process.exit(1); 15 | } 16 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "electrolite", 3 | "version": "0.1.0", 4 | "description": "Electron based lite-wrap for any website", 5 | "author": "Andrea Giammarchi", 6 | "bin": { 7 | "electrolite": "./app.js" 8 | }, 9 | "license": "ISC", 10 | "dependencies": { 11 | "electron": "latest" 12 | }, 13 | "scripts": { 14 | "start": "electron index.js" 15 | } 16 | } 17 | --------------------------------------------------------------------------------