Skip to content

Commit

Permalink
Publish Opera add-on
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob--W committed Oct 17, 2013
1 parent b81eb09 commit 63fd4a0
Show file tree
Hide file tree
Showing 12 changed files with 98 additions and 7 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# Chrome extension source viewer
# Chrome extension source viewer (CRX Viewer)

View the source code of any Chrome extension in the Chrome Web store without installing it.
https://chrome.google.com/webstore/detail/chrome-extension-source-v/jifpbeccnghkjeaalbbjmodiffmgedin

Also available for Opera and Opera's add-on gallery.
https://addons.opera.com/extensions/details/extension-source-viewer/


## Features

This Chrome extension adds a button to right of the omnibox when a CRX file has been detected.
Expand Down
Binary file added opera-addon-gallery/icon64.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 opera-addon-gallery/screenshot1-cws.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 opera-addon-gallery/screenshot2-viewer.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 opera-addon-gallery/screenshot3-contextmenu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/crxviewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ progressDiv.textContent = 'Loading ' + crx_url;
openCRXasZip(crx_url, handleBlob, function(error_message) {
progressDiv.textContent = error_message;

//#if CHROME
var permission = {
origins: ['<all_urls>']
};
Expand All @@ -481,6 +482,7 @@ openCRXasZip(crx_url, handleBlob, function(error_message) {
grantAccess.textContent = 'Add permission';
progressDiv.appendChild(grantAccess);
});
//#endif
}, progressEventHandler);
function progressEventHandler(xhrProgressEvent) {
if (xhrProgressEvent.lengthComputable) {
Expand Down
5 changes: 3 additions & 2 deletions src/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "Chrome extension source viewer",
"short_name": "CRX Viewer",
"description": "Adds button to show the source code of a Chrome extension (crx file) in the Chrome web store (and elsewhere if wanted)",
"version": "1.1.11",
"version": "1.2.0",
"manifest_version": 2,
"background": {
"scripts": [
Expand All @@ -18,7 +19,7 @@
"19": "icons/19.png",
"38": "icons/38.png"
},
"default_title": "Inspect contents of the current Chrome extension",
"default_title": "Inspect contents of the current Chromium extension",
"default_popup": "popup.html"
},
"icons": {
Expand Down
49 changes: 49 additions & 0 deletions src/manifest_opera.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"name": "Extension source viewer",
"description": "View the source code of any Chrome or Opera extension (crx/nex). Also allows you to directly install extensions from the Chrome Web Store.",
"version": "1.2.0",
"manifest_version": 2,
"developer": {
"name": "Rob Wu",
"url": "https://robwu.nl"
},
"background": {
"scripts": [
"incognito-events.js",
"chrome-platform-info.js",
"cws_pattern.js",
"background.js",
"bg-contextmenu.js"
],
"persistent": false
},
"page_action": {
"default_icon": {
"19": "icons/19.png",
"38": "icons/38.png"
},
"default_title": "Inspect contents of the current Chromium extension",
"default_popup": "popup.html"
},
"icons": {
"16": "icons/16.png",
"48": "icons/48.png",
"128": "icons/128.png"
},
"options_page": "options.html",
"permissions": [
"tabs",
"webNavigation",
"storage",
"contextMenus",
"declarativeWebRequest",
"*://clients2.google.com/service/update2/crx*",
"*://clients2.googleusercontent.com/crx/download/*",
"*://addons.opera.com/*",
"*://*/*"
],
"web_accessible_resources": [
"crxviewer.html"
],
"incognito": "split"
}
3 changes: 3 additions & 0 deletions src/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@
</style>
</head>
<body>
<!--#if CHROME-->
<label>
<input type="checkbox" id="hasAccessToAllURLs">
Allow access to all URLs.<br>
This option allows the extension to detect Chrome and Opera 15 extensions outside the Chrome Web store.
When the download of a Chromium extension is detected, the CRX button will be shown.
</label>
<!--#endif-->
<label>
<input type="checkbox" id="contextmenu">
Add a context menu option to Chrome / Opera 15 extension links.
Expand All @@ -37,6 +39,7 @@
&copy; 2013 Rob Wu &lt;[email protected]&gt;
&bull; <a href="https://github.com/Rob--W/crxviewer">Source code on Github</a>
&bull; <a href="https://chrome.google.com/webstore/detail/chrome-extension-source-v/jifpbeccnghkjeaalbbjmodiffmgedin">Chrome Web Store listing</a>
&bull; <a href="https://addons.opera.com/en/extensions/details/extension-source-viewer/">Opera addon listing</a>
</footer>
<script src="options.js"></script>
</body>
Expand Down
2 changes: 2 additions & 0 deletions src/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/* jshint browser:true, devel:true */
/* globals chrome */
'use strict';
//#if CHROME
var permission = {
origins: ['<all_urls>']
};
Expand Down Expand Up @@ -34,6 +35,7 @@ if (chrome.declarativeWebRequest) {
'<a href="https://www.google.com/landing/chrome/beta/">Beta channel</a></em>.'
);
}
//#endif

document.getElementById('contextmenu').onchange = function() {
chrome.storage.local.set({showContextMenu: this.checked});
Expand Down
3 changes: 3 additions & 0 deletions src/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
<body>
<button id="download" title="Download extension in zip format">Download as zip</button>
<button id="view-source" title="View source of extension in a new tab">View source</button>
<!--#if OPERA-->
<button id="install-as-nex" title="install the extension">Install</button>
<!--#endif-->
<script src="lib/crx-to-zip.js"></script>
<script src="chrome-platform-info.js"></script>
<script src="cws_pattern.js"></script>
Expand Down
35 changes: 31 additions & 4 deletions src/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ if (crx_url) {
function ready() {
document.getElementById('download').onclick = doDownload;
document.getElementById('view-source').onclick = doViewSource;
//#if OPERA
document.getElementById('install-as-nex').onclick = doInstall;
//#endif
}
if (typeof URL === 'undefined') window.URL = window.webkitURL;
var blob_url;
function showDownload() {
var a = document.createElement('a');
a.href = blob_url;
a.download = filename;
a.click();
tryTriggerDownload(blob_url, filename);
}
var hasDownloadedOnce = false;
function doDownload() {
Expand Down Expand Up @@ -73,3 +73,30 @@ function doViewSource() {
active: true
});
}
//#if OPERA
function doInstall() {
var name = filename.replace(/\.zip$/, '.nex');
tryTriggerDownload(crx_url, name);
}
//#endif

// Try to download in the context of the current tab, such that the download
// continues even when the popup closed.
// In Opera, the Save As dialog almost falls off the screen because it's positioned relative
// to the upper-left corner of the (page action popup) viewport...
function tryTriggerDownload(url, filename) {
chrome.tabs.executeScript({
code: '(' + triggerDownload + '})(' + JSON.stringify(url) + ',' + JSON.stringify(filename) + ')'
}, function(result) {
if (!result) {
// Access denied? Then try to save in the context of the popup
triggerDownload(url, filename);
}
});
}
function triggerDownload(url, filename) {
var a = document.createElement('a');
a.href = url;
a.download = filename;
a.click();
}

0 comments on commit 63fd4a0

Please sign in to comment.