This repository has been archived by the owner on Mar 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 36
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
Showing
28 changed files
with
393 additions
and
361 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 |
---|---|---|
@@ -1,38 +1,38 @@ | ||
function getDomainFromUrl(url) { | ||
var matches = url.match(/:\/\/(.[^/]+)/); | ||
return ((matches != null && typeof matches[1] != 'undefined') ? matches[1] : null); | ||
var matches = url.match(/:\/\/(.[^/]+)/); | ||
return ((matches != null && typeof matches[1] != 'undefined') ? matches[1] : null); | ||
} | ||
|
||
kango.browser.addEventListener(kango.browser.event.BEFORE_NAVIGATE, function(event) { | ||
kango.console.log('BeforeNavigate\nUrl=' + event.url + '\nIs tab active=' + event.target.isActive()); | ||
var domain = getDomainFromUrl(event.url); | ||
// i don't like bing, redirect to google | ||
if (domain == 'www.bing.com' || domain == 'bing.com') { | ||
event.target.navigate('http://google.com/'); | ||
} | ||
kango.console.log('BeforeNavigate\nUrl=' + event.url + '\nIs tab active=' + event.target.isActive()); | ||
var domain = getDomainFromUrl(event.url); | ||
// i don't like bing, redirect to google | ||
if (domain == 'www.bing.com' || domain == 'bing.com') { | ||
event.target.navigate('http://google.com/'); | ||
} | ||
}); | ||
|
||
kango.browser.addEventListener(kango.browser.event.DOCUMENT_COMPLETE, function(event) { | ||
kango.console.log('DocumentComplete\nUrl=' + event.url + '\nTitle=' + event.title + '\nIs tab active=' + event.target.isActive()); | ||
kango.console.log('DocumentComplete\nUrl=' + event.url + '\nTitle=' + event.title + '\nIs tab active=' + event.target.isActive()); | ||
}); | ||
|
||
kango.browser.addEventListener(kango.browser.event.TAB_CREATED, function(event) { | ||
kango.console.log('Tab Created\nTarget tab url=' + event.target.getUrl() + '\nTab id=' + event.tabId); | ||
kango.console.log('Tab Created\nTarget tab url=' + event.target.getUrl() + '\nTab id=' + event.tabId); | ||
}); | ||
|
||
kango.browser.addEventListener(kango.browser.event.TAB_CHANGED, function(event) { | ||
kango.console.log('Tab Changed\nTarget tab url=' + event.target.getUrl() + '\nTab id=' + event.tabId); | ||
kango.console.log('Tab Changed\nTarget tab url=' + event.target.getUrl() + '\nTab id=' + event.tabId); | ||
}); | ||
|
||
kango.browser.addEventListener(kango.browser.event.TAB_REMOVED, function(event) { | ||
kango.console.log('Tab Removed\nTab id=' + event.tabId); | ||
kango.console.log('Tab Removed\nTab id=' + event.tabId); | ||
}); | ||
|
||
kango.ui.browserButton.addEventListener(kango.ui.browserButton.event.COMMAND, function() { | ||
// output to console all opened tabs urls | ||
kango.browser.tabs.getAll(function(tabs) { | ||
for (var i = 0; i < tabs.length; i++) { | ||
kango.console.log(tabs[i].getUrl()) | ||
} | ||
}); | ||
// output to console all opened tabs urls | ||
kango.browser.tabs.getAll(function(tabs) { | ||
for (var i = 0; i < tabs.length; i++) { | ||
kango.console.log(tabs[i].getUrl()) | ||
} | ||
}); | ||
}); |
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
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
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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
kango.ui.contextMenuItem.addEventListener(kango.ui.contextMenuItem.event.CLICK, function() { | ||
kango.console.log('Context menu item click'); | ||
kango.browser.tabs.getCurrent(function(tab) { | ||
tab.dispatchMessage('ContextMenuItemClick'); | ||
}); | ||
kango.console.log('Context menu item click'); | ||
kango.browser.tabs.getCurrent(function(tab) { | ||
tab.dispatchMessage('ContextMenuItemClick'); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"id": "{6F4DCD7C-7E52-11E0-8BAC-3CB64724019B}" | ||
"id": "{6F4DCD7C-7E52-11E0-8BAC-3CB64724019B}" | ||
} |
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 |
---|---|---|
@@ -1,14 +1,14 @@ | ||
{ | ||
"name": "Gmail Checker", | ||
"version": "1.2.0", | ||
"description": "Gmail Checker", | ||
"creator": "Kango", | ||
"homepage_url": "http://kangoextensions.com/", | ||
"background_scripts": ["main.js"], | ||
"browser_button": { | ||
"icon": "icons/button_gray.png", | ||
"tooltipText": "Gmail Checker", | ||
"caption": "Gmail Checker" | ||
}, | ||
"default_locale": "en" | ||
"name": "Gmail Checker", | ||
"version": "1.2.0", | ||
"description": "Gmail Checker", | ||
"creator": "Kango", | ||
"homepage_url": "http://kangoextensions.com/", | ||
"background_scripts": ["main.js"], | ||
"browser_button": { | ||
"icon": "icons/button_gray.png", | ||
"tooltipText": "Gmail Checker", | ||
"caption": "Gmail Checker" | ||
}, | ||
"default_locale": "en" | ||
} |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"Offline": "Offline", | ||
"Unread count": "Unread count" | ||
"Offline": "Offline", | ||
"Unread count": "Unread count" | ||
} |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"Offline": "Не подключен", | ||
"Unread count": "Количество непрочитанных" | ||
"Offline": "Не подключен", | ||
"Unread count": "Количество непрочитанных" | ||
} |
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 |
---|---|---|
@@ -1,53 +1,53 @@ | ||
function GmailChecker() { | ||
var self = this; | ||
self.refresh(); | ||
kango.ui.browserButton.addEventListener(kango.ui.browserButton.event.COMMAND, function() { | ||
kango.browser.tabs.create({url: 'https://mail.google.com/'}); | ||
self.refresh(); | ||
}); | ||
window.setInterval(function() { | ||
self.refresh() | ||
}, self._refreshTimeout); | ||
var self = this; | ||
self.refresh(); | ||
kango.ui.browserButton.addEventListener(kango.ui.browserButton.event.COMMAND, function() { | ||
kango.browser.tabs.create({url: 'https://mail.google.com/'}); | ||
self.refresh(); | ||
}); | ||
window.setInterval(function() { | ||
self.refresh() | ||
}, self._refreshTimeout); | ||
} | ||
|
||
GmailChecker.prototype = { | ||
|
||
_refreshTimeout: 60 * 1000 * 15, // 15 minutes | ||
_feedUrl: 'https://mail.google.com/mail/feed/atom', | ||
_refreshTimeout: 60 * 1000 * 15, // 15 minutes | ||
_feedUrl: 'https://mail.google.com/mail/feed/atom', | ||
|
||
_setOffline: function() { | ||
kango.ui.browserButton.setTooltipText(kango.i18n.getMessage('Offline')); | ||
kango.ui.browserButton.setIcon('icons/button_gray.png'); | ||
kango.ui.browserButton.setBadgeValue(0); | ||
}, | ||
_setOffline: function() { | ||
kango.ui.browserButton.setTooltipText(kango.i18n.getMessage('Offline')); | ||
kango.ui.browserButton.setIcon('icons/button_gray.png'); | ||
kango.ui.browserButton.setBadgeValue(0); | ||
}, | ||
|
||
_setUnreadCount: function(count) { | ||
kango.ui.browserButton.setTooltipText(kango.i18n.getMessage('Unread count') + ': ' + count); | ||
kango.ui.browserButton.setIcon('icons/button.png'); | ||
kango.ui.browserButton.setBadgeValue(count); | ||
}, | ||
_setUnreadCount: function(count) { | ||
kango.ui.browserButton.setTooltipText(kango.i18n.getMessage('Unread count') + ': ' + count); | ||
kango.ui.browserButton.setIcon('icons/button.png'); | ||
kango.ui.browserButton.setBadgeValue(count); | ||
}, | ||
|
||
refresh: function() { | ||
var details = { | ||
url: this._feedUrl, | ||
method: 'GET', | ||
async: true, | ||
contentType: 'text' | ||
}; | ||
var self = this; | ||
kango.xhr.send(details, function(data) { | ||
if (data.status == 200 && data.response != null) { | ||
var count = 0; | ||
var matches = data.response.match(/<fullcount>(\d+)<\/fullcount>/); // Old IE versions doensn't support getElementsByTagNameNS, so we using RegExp | ||
if (matches != null && matches.length > 0) { | ||
count = matches[1]; | ||
} | ||
self._setUnreadCount(count); | ||
} else { // something went wrong | ||
self._setOffline(); | ||
} | ||
}); | ||
} | ||
refresh: function() { | ||
var details = { | ||
url: this._feedUrl, | ||
method: 'GET', | ||
async: true, | ||
contentType: 'text' | ||
}; | ||
var self = this; | ||
kango.xhr.send(details, function(data) { | ||
if (data.status == 200 && data.response != null) { | ||
var count = 0; | ||
var matches = data.response.match(/<fullcount>(\d+)<\/fullcount>/); // Old IE versions doensn't support getElementsByTagNameNS, so we using RegExp | ||
if (matches != null && matches.length > 0) { | ||
count = matches[1]; | ||
} | ||
self._setUnreadCount(count); | ||
} else { // something went wrong | ||
self._setOffline(); | ||
} | ||
}); | ||
} | ||
}; | ||
|
||
var extension = new GmailChecker(); |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"id": "{6F4DCD7C-7E52-11E0-8BAC-3CB64724019B}" | ||
"id": "{6F4DCD7C-7E52-11E0-8BAC-3CB64724019B}" | ||
} |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"id": "http://kangoextensions.com/extensions/gmailchecker" | ||
"id": "http://kangoextensions.com/extensions/gmailchecker" | ||
} |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"id": "com.kangoextensions.gmailchecker" | ||
"id": "com.kangoextensions.gmailchecker" | ||
} |
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 |
---|---|---|
@@ -1,16 +1,16 @@ | ||
{ | ||
"name": "Extension name", | ||
"version": "1.2.0", | ||
"description": "Extension description", | ||
"creator": "Kango", | ||
"homepage_url": "http://kangoextensions.com/", | ||
"background_scripts": [ | ||
"main.js" | ||
], | ||
"browser_button": { | ||
"caption": "Kango", | ||
"icon": "icons/button.png", | ||
"tooltipText": "Kango" | ||
}, | ||
"default_locale": "en" | ||
"name": "Extension name", | ||
"version": "1.3.0", | ||
"description": "Extension description", | ||
"creator": "Kango", | ||
"homepage_url": "http://kangoextensions.com/", | ||
"background_scripts": [ | ||
"main.js" | ||
], | ||
"browser_button": { | ||
"caption": "Kango", | ||
"icon": "icons/button.png", | ||
"tooltipText": "Kango" | ||
}, | ||
"default_locale": "en" | ||
} |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{ | ||
"__info_name__": "Extension name", | ||
"__info_description__": "Extension description", | ||
"Hello": "Hello" | ||
"__info_name__": "Internationalization demo", | ||
"__info_description__": "Extension description", | ||
"Logo": "Logo", | ||
"Hello": "Hello {name}" | ||
} |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{ | ||
"__info_name__": "Название расширения", | ||
"__info_description__": "Описание расширения", | ||
"Hello": "Привет" | ||
"__info_name__": "Демонстрация интернационализации", | ||
"__info_description__": "Описание расширения", | ||
"Logo": "Логотип", | ||
"Hello": "Привет {name}" | ||
} |
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
Oops, something went wrong.