Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add topsites plugin && add ga #8

Merged
merged 1 commit into from
Sep 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,22 @@
<h1 align="center">Steward</h1>
<p align="center">Chrome里的Alfred,命令式管理扩展/应用/书签/历史记录/标签...</p>
<p align="center">
<a href="https://github.com/solobat/Steward/releases"><img src="https://img.shields.io/badge/lastest_version-2.5.0-blue.svg"></a>
<a href="https://github.com/solobat/Steward/releases"><img src="https://img.shields.io/badge/lastest_version-2.5.1-blue.svg"></a>
<a target="_blank" href="https://chrome.google.com/webstore/detail/dnkhdiodfglfckibnfcjbgddcgjgkacd"><img src="https://img.shields.io/badge/download-_chrome_webstore-brightgreen.svg"></a>
<a href="http://owsjc7iz3.bkt.clouddn.com/Steward-2.5.0.crx"><img src="https://img.shields.io/badge/download-_crx-brightgreen.svg"></a>
<a href="http://owsjc7iz3.bkt.clouddn.com/Steward-2.5.1.crx"><img src="https://img.shields.io/badge/download-_crx-brightgreen.svg"></a>
</p>

***

#### 安装:
- [Chrome 应用商店](https://chrome.google.com/webstore/detail/dnkhdiodfglfckibnfcjbgddcgjgkacd)
- [离线下载](http://owsjc7iz3.bkt.clouddn.com/Steward-2.5.0.crx)。
- [离线下载](http://owsjc7iz3.bkt.clouddn.com/Steward-2.5.1.crx)。

---
#### 功能:
+ 背景图来自[bing.com](https://www.bing.com)首页,15分钟自动切换,也可右下角按钮手动
+ `on`/`off`/`set`/`del` 启动/禁用/设置/删除相应的扩展
+ `site` 显示MostVisited网站
+ `run` 命令启动App
+ `tab` 命令查找并定位到打开的标签页
+ `his` 命令查找历史记录并新标签打开
Expand All @@ -43,11 +44,11 @@
[![license-badge]][license-link]

<!-- Link -->
[version-badge]: https://img.shields.io/badge/lastest_version-2.5.0-blue.svg
[version-badge]: https://img.shields.io/badge/lastest_version-2.5.1-blue.svg
[version-link]: https://github.com/solobat/Steward
[chrome-badge]: https://img.shields.io/badge/download-_chrome_webstore-brightgreen.svg
[chrome-link]: https://chrome.google.com/webstore/detail/dnkhdiodfglfckibnfcjbgddcgjgkacd
[offline-badge]: https://img.shields.io/badge/download-_crx-brightgreen.svg
[offline-link]: http://owsjc7iz3.bkt.clouddn.com/Steward-2.5.0.crx
[offline-link]: http://owsjc7iz3.bkt.clouddn.com/Steward-2.5.1.crx
[license-badge]: https://img.shields.io/github/license/mashape/apistatus.svg
[license-link]: https://opensource.org/licenses/MIT
6 changes: 6 additions & 0 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
"bookmark_subtitle": {
"message": "find bookmark and open it"
},
"topsites_title": {
"message": "top sites"
},
"topsites_subtitle": {
"message": "show topsites and open"
},
"download_title": {
"message": "show downloads"
},
Expand Down
6 changes: 6 additions & 0 deletions _locales/zh_CN/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
"bookmark_subtitle": {
"message": "查找书签记录并打开"
},
"topsites_title": {
"message": "常用网站"
},
"topsites_subtitle": {
"message": "常用网站并打开"
},
"download_title": {
"message": "下载列表"
},
Expand Down
Binary file added img/icon128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icon48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/topsites.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions js/common/ga.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-106561500-1']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = 'https://ssl.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
14 changes: 12 additions & 2 deletions js/main/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ define(function (require, exports, module) {
var plugins = require('../plugins/plugins').plugins;
const Wallpaper = require('/js/main/wallpaper');

var _gaq = window._gaq || [];
var commands = {};
var keys;
var reg;
Expand Down Expand Up @@ -92,6 +93,12 @@ define(function (require, exports, module) {
this.query = key;

storage.h5.set(CONST.LAST_CMD, str);

if (this.lastcmd !== this.cmd) {
_gaq.push(['_trackEvent', 'command', 'input', this.cmd]);
this.lastcmd = this.cmd;
}

return commands[this.cmd].plugin.onInput.call(this, key);
},

Expand All @@ -115,7 +122,7 @@ define(function (require, exports, module) {
});

cmdbox.bind('init', function () {
var cmd = storage.h5.get(CONST.LAST_CMD) || 'todo ';
var cmd = storage.h5.get(CONST.LAST_CMD) || 'site ';

this.ipt.val(cmd);
this.render(cmd);
Expand All @@ -131,7 +138,10 @@ define(function (require, exports, module) {
return;
}

commands[this.cmd].plugin.onEnter.call(this, $(elem).data('id'), elem);
let plugin = commands[this.cmd].plugin;

plugin.onEnter.call(this, $(elem).data('id'), elem);
_gaq.push(['_trackEvent', 'exec', 'enter', plugin.name]);
});

cmdbox.bind('empty', function () {
Expand Down
8 changes: 7 additions & 1 deletion js/options/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,13 @@ define(function(require, exports, module) {
}
},
methods: {
handleClick: function() {
handleClick: function(tab) {
_gaq.push(['_trackEvent', 'options_tab', 'click', tab.name]);
},

handlePluginClick: function(plugin) {
this.currentPlugin = plugin;
_gaq.push(['_trackEvent', 'options_plugins', 'click', plugin.name]);
},

handlePluginsSubmit: function() {
Expand All @@ -72,6 +77,7 @@ define(function(require, exports, module) {
}, function() {
self.$message('保存成功!');
});
_gaq.push(['_trackEvent', 'options_plugins', 'save']);
}
}
});
Expand Down
2 changes: 1 addition & 1 deletion js/plugins/calculate.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ define(function (require, exports, module) {
title,
subtitle,
icon,
editable: true
editable: false
}];

function onInput() {
Expand Down
3 changes: 2 additions & 1 deletion js/plugins/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ define(function(require, exports, module) {
require('/js/plugins/calculate'),
require('/js/plugins/urlblock'),
require('/js/plugins/download'),
require('/js/plugins/help')
require('/js/plugins/help'),
require('/js/plugins/topsites')
]

module.exports = {
Expand Down
57 changes: 57 additions & 0 deletions js/plugins/topsites.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* @file bm command plugin script
* @description 书签记录检索
* @author tomasy
* @email [email protected]
*/

define(function (require, exports, module) {
var chrome = window.chrome;
var name = 'topsites';
var key = 'site';
var icon = chrome.extension.getURL('img/topsites.png');
var title = chrome.i18n.getMessage(name + '_title');
var subtitle = chrome.i18n.getMessage(name + '_subtitle');
var commands = [{
key,
title,
subtitle,
icon,
editable: true
}];

function onInput(key) {
var that = this;
chrome.topSites.get(function (sites) {
var arr = [];
for (var i in sites) {
var item = sites[i];
arr.push({
key: key,
id: item.id,
icon: icon,
url: item.url,
title: item.title,
desc: item.url,
isWarn: false
});
}
that.showItemList(arr);
});
}

function onEnter(id, elem) {
chrome.tabs.create({
url: $(elem).data('url')
});
}

module.exports = {
name: 'Top Sites',
icon,
title,
commands,
onInput: onInput,
onEnter: onEnter
};
});
11 changes: 7 additions & 4 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "Steward: 扩展/应用/标签/历史记录/alfred",
"short_name": "Steward",
"version": "2.5",
"version": "2.5.1",
"description": "便捷管理扩展/应用/标签/历史记录等",
"default_locale": "zh_CN",
"chrome_url_overrides" : {
Expand All @@ -18,14 +18,16 @@
},

"icons": {
"16": "img/icon16.png"
"16": "img/icon16.png",
"48": "img/icon48.png",
"128": "img/icon128.png"
},
"web_accessible_resources": [
"img/*",
"urlblock.html",
"login.html"
],
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'",
"content_security_policy": "script-src 'self' 'unsafe-eval' https://ssl.google-analytics.com; object-src 'self'",
"options_page": "options.html",
"optional_permissions": [
"background", "clipboardRead", "clipboardWrite"
Expand All @@ -39,7 +41,8 @@
"contextMenus",
"management",
"notifications",
"<all_urls>"
"<all_urls>",
"topSites"
],
"commands": {
"_execute_browser_action": {
Expand Down
3 changes: 2 additions & 1 deletion options.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<head>
<meta charset="UTF-8">
<title>Steward Preference</title>
<script src="js/common/ga.js"></script>
<link rel="stylesheet" href="css/element-ui.css">
<link rel="stylesheet" href="css/options.css">
</head>
Expand All @@ -22,7 +23,7 @@
<el-input placeholder="Search" icon="search" v-model="pluginSearchText">
</el-input>
</div>
<div class="plugin-item" v-for="plugin in plugins" @click="currentPlugin = plugin">
<div class="plugin-item" v-for="plugin in plugins" @click="handlePluginClick(plugin)">
<img :src="plugin.icon" class="plugin-icon" alt="">
<span class="plugin-name">{{plugin.name}}</span>
</div>
Expand Down
1 change: 1 addition & 0 deletions popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<meta charset="UTF-8">
<title>popup</title>
<link href="css/popup.css" rel="stylesheet">
<script src="js/common/ga.js"></script>
</head>

<body>
Expand Down
1 change: 1 addition & 0 deletions steward.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<meta charset="UTF-8">
<title>New Tab</title>
<link href="css/newtab.css" rel="stylesheet">
<script src="js/common/ga.js"></script>
</head>

<body>
Expand Down
5 changes: 3 additions & 2 deletions urlblock.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<head>
<meta charset="UTF-8">
<title>url block message</title>
<script src="js/common/ga.js"></script>
<style>
h1 {
text-align: center;
Expand All @@ -11,6 +12,6 @@
</style>
</head>
<body>
<h1>This page has been blocked by you!</h1>
<h1>This page has been blocked by you!</h1>
</body>
</html>
</html>