Created
November 28, 2012 11:47
-
-
Save metude/4160680 to your computer and use it in GitHub Desktop.
Opera Extension - Download Chrome
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
window.addEventListener('DOMContentLoaded', function() { | |
if (opera.contexts.menu) { // Check the Context Menu API is supported | |
var menu = opera.contexts.menu; // Create a menu item properties object | |
var itemProps = { | |
contexts: ['page', 'link'], | |
icon: 'images/chrome.png', | |
documentURLPatterns: [ | |
'http://chrome.google.com/webstore/*', | |
'https://chrome.google.com/webstore/*' | |
], | |
title: strings['download-it'], | |
onclick: function(event) { | |
var tabProps = {}; // Create a tab properties object, opera extension api to use it later. | |
var currentTab = opera.extension.tabs.getFocused(), currentUrl = currentTab.url; | |
var pathArray = currentUrl.split('/'); // try to get id of extension. | |
var lastArray = pathArray[6].split('?'); // now eliminate localization strings (?hl=tr e.g.) | |
tabProps.url = "https://clients2.google.com/service/update2/crx?response=redirect&x=id%3D" + lastArray[0] + "%26uc"; // magic | |
currentTab.update({url: tabProps.url}); // Update a tab with the specified properties | |
} | |
} | |
var item = menu.createItem(itemProps); // Create a menu item with the specified properties | |
menu.addItem(item); // Add the menu item to the context menu | |
} else { | |
console.error('Context Menu API not supported.'); | |
} | |
}, false); |
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
<?xml version='1.0' encoding='utf-8'?> | |
<widget xmlns="http://www.w3.org/ns/widgets" id="https://addons.opera.com/extensions/details/download-chrome-extension/" version="1.1" defaultlocale="en" href="https://addons.opera.com/extensions/details/download-chrome-extension/"> | |
<name>Download Chrome Extension</name> | |
<author href="http://my.opera.com/metude/">metude (metude@myopera.com)</author> | |
<icon src="images/icon_64.png"/> | |
<feature name="opera:contextmenus" required="true"/> | |
<license href="http://www.opensource.org/licenses/mit-license.php">Licensed under the MIT license</license> | |
<update-description href="https://extension-updates.opera.com/api/w3c-wd1/update/f0f14fab-4cdb-48e6-9d6e-10e7f10fde62/"/> | |
<description xml:lang="en">Download Google Chrome Extensions from Web Store.</description> | |
<description xml:lang="tr">Google Chrome Uzantılarını Web Store'dan indirin.</description> | |
</widget> |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Download Chrome Extensions (Opera extension)</title> | |
<script src="strings.js"></script> | |
<script src="background.js"></script> | |
</head> | |
<body> | |
</body> | |
</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
var strings = { | |
'download-it': 'Chrome Eklentisini İndir' | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment