-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextension.js
More file actions
29 lines (27 loc) · 1.01 KB
/
extension.js
File metadata and controls
29 lines (27 loc) · 1.01 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
const vscode = require('vscode');
const superagent = require('superagent');
const cheerio = require('cheerio');
function activate(context) {
let statusBar = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right);
statusBar.text = '$(eye) GXC';
statusBar.command = 'extension.GXC';
statusBar.tooltip = 'Click to get GXC price';
statusBar.show();
let disposable = vscode.commands.registerCommand('extension.GXC', function () {
const url = 'https://m.feixiaohao.com/currencies/gxshares/';
superagent.get(url).end((err, res) => {
let $ = cheerio.load(res.text);
let price = $('.price').text();
if (price) {
vscode.window.showInformationMessage(`1 GXC ≈ ¥ ${price}`);
} else {
vscode.window.showWarningMessage('Sorry, I\'m lost.');
}
});
});
context.subscriptions.push(disposable);
}
exports.activate = activate;
function deactivate() {
}
exports.deactivate = deactivate;