This repository has been archived by the owner on Nov 12, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Zhongyi Tong
committed
Feb 18, 2016
0 parents
commit 947424e
Showing
7 changed files
with
202 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2016 Zhongyi Tong | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# electron-quick-start | ||
|
||
**Clone and run for a quick way to see an Electron in action.** | ||
|
||
This is a minimal Electron application based on the [Quick Start Guide](http://electron.atom.io/docs/latest/tutorial/quick-start) within the Electron documentation. | ||
|
||
A basic Electron application needs just these files: | ||
|
||
- `index.html` - A web page to render. | ||
- `main.js` - Starts the app and creates a browser window to render HTML. | ||
- `package.json` - Points to the app's main file and lists its details and dependencies. | ||
|
||
You can learn more about each of these components within the [Quick Start Guide](http://electron.atom.io/docs/latest/tutorial/quick-start). | ||
|
||
## To Use | ||
|
||
To clone and run this repository you'll need [Git](https://git-scm.com) and [Node.js](https://nodejs.org/en/download/) (which comes with [npm](http://npmjs.com)) installed on your computer. From your command line: | ||
|
||
```bash | ||
# Clone this repository | ||
git clone https://github.com/atom/electron-quick-start | ||
# Go into the repository | ||
cd electron-quick-start | ||
# Install dependencies and run the app | ||
npm install && npm start | ||
``` | ||
|
||
Learn more about Electron and its API in the [documentation](http://electron.atom.io/docs/latest). | ||
|
||
#### License [CC0 (Public Domain)](LICENSE.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>WeChat</title> | ||
<link rel="stylesheet" href="style.css"> | ||
</head> | ||
<body> | ||
<webview id="webview" src="https://wx.qq.com/"/> | ||
</body> | ||
<script src="wechat.js"></script> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
'use strict'; | ||
|
||
const electron = require('electron'); | ||
// Module to control application life. | ||
const app = electron.app; | ||
// Module to create native browser window. | ||
const BrowserWindow = electron.BrowserWindow; | ||
|
||
// Keep a global reference of the window object, if you don't, the window will | ||
// be closed automatically when the JavaScript object is garbage collected. | ||
let mainWindow; | ||
|
||
function createWindow () { | ||
// Create the browser window. | ||
mainWindow = new BrowserWindow({width: 800, height: 600}); | ||
|
||
// and load the index.html of the app. | ||
mainWindow.loadURL('file://' + __dirname + '/index.html'); | ||
|
||
// Open the DevTools. | ||
// mainWindow.webContents.openDevTools(); | ||
|
||
// Emitted when the window is closed. | ||
mainWindow.on('closed', function() { | ||
// Dereference the window object, usually you would store windows | ||
// in an array if your app supports multi windows, this is the time | ||
// when you should delete the corresponding element. | ||
mainWindow = null; | ||
}); | ||
} | ||
|
||
// This method will be called when Electron has finished | ||
// initialization and is ready to create browser windows. | ||
app.on('ready', createWindow); | ||
|
||
// Quit when all windows are closed. | ||
app.on('window-all-closed', function () { | ||
// On OS X it is common for applications and their menu bar | ||
// to stay active until the user quits explicitly with Cmd + Q | ||
if (process.platform !== 'darwin') { | ||
app.quit(); | ||
} | ||
}); | ||
|
||
app.on('activate', function () { | ||
// On OS X it's common to re-create a window in the app when the | ||
// dock icon is clicked and there are no other windows open. | ||
if (mainWindow === null) { | ||
createWindow(); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"name": "wechat-electron", | ||
"version": "0.0.0", | ||
"description": "A Electron application for WeChat", | ||
"main": "main.js", | ||
"scripts": { | ||
"start": "electron main.js" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/geeeeeeeeek/wechat-electron.git" | ||
}, | ||
"keywords": [ | ||
"Electron", | ||
"WeChat", | ||
"微信", | ||
"Web" | ||
], | ||
"author": "Zhongyi Tong", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/geeeeeeeeek/wechat-electron/issues" | ||
}, | ||
"homepage": "https://github.com/geeeeeeeeek/wechat-electron/", | ||
"devDependencies": { | ||
"electron-prebuilt": "^0.36.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
html, body, #webview { | ||
width: 100%; | ||
height: 100%; | ||
margin: 0; | ||
padding: 0; | ||
overflow-y: hidden; | ||
} | ||
|
||
html::-webkit-scrollbar { | ||
width: 0 !important; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
const shell = require('electron').shell; | ||
|
||
const injectCSS = ` | ||
div.main { | ||
height: 100% !important; | ||
min-height: 0 !important; | ||
padding-top: 0 !important; | ||
} | ||
div.main_inner { | ||
max-width: none !important; | ||
min-width: 0 !important; | ||
} | ||
div.message_empty { | ||
margin-top: 50px; | ||
} | ||
p.copyright { | ||
display: none !important | ||
} | ||
a.web_wechat_screencut { | ||
display: none !important; | ||
} | ||
`; | ||
|
||
function getParameterByName(url, name) { | ||
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); | ||
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), | ||
results = regex.exec(url); | ||
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); | ||
} | ||
|
||
onload = function () { | ||
var webview = document.getElementById("webview"); | ||
console.log(webview); | ||
webview.addEventListener('dom-ready', function () { | ||
// overwrite css style. make it fullscreen. | ||
webview.insertCSS(injectCSS); | ||
// inject js to trigger if there is new message in. | ||
webview.executeJavaScript('injectJS.getBadge()'); | ||
}); | ||
|
||
webview.addEventListener('new-window', function (e) { | ||
var url = getParameterByName(e.url, 'requrl'); | ||
if (url.length > 1) { | ||
shell.openExternal(url); | ||
} else { | ||
shell.openExternal(e.url); | ||
} | ||
}) | ||
}; |