mirror of
https://github.com/mirror/jdownloader.git
synced 2024-11-26 21:40:38 +00:00
Google Chrome Extension - First Release
(SVN only currently, updated ExternInterface needed) JD Logo: new formats. JDExternInterface: /flash/checkSupportForUrl added. git-svn-id: svn://svn.jdownloader.org/jdownloader/trunk@11336 ebf7c1c2-ba36-0410-9fe8-c592906822b4
This commit is contained in:
parent
49e0699411
commit
88efce4bb2
@ -1,3 +1,5 @@
|
||||
#Sat Feb 06 23:36:15 CET 2010
|
||||
#Sun May 09 22:32:56 CEST 2010
|
||||
eclipse.preferences.version=1
|
||||
encoding//ressourcen/browserintegration/chrome/src/_locales/de/messages.json=UTF-8
|
||||
encoding//ressourcen/browserintegration/chrome/src/_locales/en/messages.json=UTF-8
|
||||
encoding/<project>=UTF-8
|
||||
|
1
ressourcen/browserintegration/chrome/chrome.txt
Normal file
1
ressourcen/browserintegration/chrome/chrome.txt
Normal file
@ -0,0 +1 @@
|
||||
coalado and scr4ve have access to the signature file needed to update the extension.
|
BIN
ressourcen/browserintegration/chrome/jdownloader.crx
Normal file
BIN
ressourcen/browserintegration/chrome/jdownloader.crx
Normal file
Binary file not shown.
@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": {
|
||||
"message": "JDownloader Integration"
|
||||
},
|
||||
"description": {
|
||||
"message": "Diese Erweiterung fügt das JDownloader-Logo in die Adressleiste ein, wenn die aktuelle Seite von JD unterstützt wird. Klicke, um den Download zu starten!"
|
||||
},
|
||||
"buttonTitle": {
|
||||
"message": "Download mit JDownloader starten."
|
||||
},
|
||||
"commentPrefix": {
|
||||
"message": "Quelle: "
|
||||
},
|
||||
"commentSuffix": {
|
||||
"message": ""
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": {
|
||||
"message": "JDownloader Integration",
|
||||
"description": "Extension name."
|
||||
},
|
||||
"description": {
|
||||
"message": "This extension adds a JDownloader icon to the adress bar for supported sites. Click on it to start downloading!",
|
||||
"description": "Extension description."
|
||||
},
|
||||
"buttonTitle": {
|
||||
"message": "Download with JD.",
|
||||
"description": "Shown in tooltip of the page action button."
|
||||
},
|
||||
"commentPrefix": {
|
||||
"message": "Source: ",
|
||||
"description": "Prepended to the comment of the file in JD."
|
||||
},
|
||||
"commentSuffix": {
|
||||
"message": "",
|
||||
"description": "Appended to the comment of the file in JD."
|
||||
}
|
||||
}
|
75
ressourcen/browserintegration/chrome/src/background.html
Normal file
75
ressourcen/browserintegration/chrome/src/background.html
Normal file
@ -0,0 +1,75 @@
|
||||
<!--
|
||||
// jDownloader - Downloadmanager
|
||||
// Copyright (C) 2010 JD-Team support@jdownloader.org
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<script>
|
||||
|
||||
var source = {};
|
||||
|
||||
function togglePageAction(xhr,tabId){
|
||||
if ( (xhr.readyState == 4) &&
|
||||
(xhr.status == 200) &&
|
||||
(xhr.responseText.toLowerCase().indexOf("true") > -1)
|
||||
)
|
||||
{
|
||||
chrome.pageAction.show(tabId);
|
||||
}
|
||||
else {
|
||||
chrome.pageAction.hide(tabId);
|
||||
}
|
||||
}
|
||||
|
||||
// Called when the url of a tab changes.
|
||||
function checkForJDPlugin(tabId, changeInfo, tab) {
|
||||
|
||||
//Save last visited page for URL Source in JD
|
||||
source[tab.id] = [(source[tab.id] ? source[tab.id][1] : [null,tab.url] ),tab.url];
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.onreadystatechange = function() { togglePageAction(xhr,tabId); };
|
||||
|
||||
var url = "http://127.0.0.1:9666/flash/checkSupportForUrl?url="+encodeURIComponent(tab.url);
|
||||
xhr.open('GET', url , true); //Use GET as this request is cacheable - caching all requests ourselves would need to much memory
|
||||
xhr.send();
|
||||
};
|
||||
|
||||
function tabClosed(tabId){
|
||||
delete source[tabId];
|
||||
}
|
||||
|
||||
function passURLtoJD(tab){
|
||||
var xhr = new XMLHttpRequest();
|
||||
var url = "http://127.0.0.1:9666/flash/add";
|
||||
var comment = (source[tab.id] ?
|
||||
("&comment="+
|
||||
encodeURIComponent(chrome.i18n.getMessage("commentPrefix") +
|
||||
source[tab.id][0] +
|
||||
chrome.i18n.getMessage("commentSuffix"))
|
||||
) : "");
|
||||
var params = "urls="+encodeURIComponent(tab.url)+comment;
|
||||
xhr.open('POST', url , true);
|
||||
xhr.send(params);
|
||||
}
|
||||
|
||||
// Add Listeners
|
||||
chrome.pageAction.onClicked.addListener(passURLtoJD);
|
||||
chrome.tabs.onUpdated.addListener(checkForJDPlugin);
|
||||
chrome.tabs.onRemoved.addListener(tabClosed);
|
||||
</script>
|
||||
</head>
|
||||
</html>
|
BIN
ressourcen/browserintegration/chrome/src/logo/logo-128x128.png
Normal file
BIN
ressourcen/browserintegration/chrome/src/logo/logo-128x128.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 29 KiB |
BIN
ressourcen/browserintegration/chrome/src/logo/logo-16x16.png
Normal file
BIN
ressourcen/browserintegration/chrome/src/logo/logo-16x16.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.6 KiB |
BIN
ressourcen/browserintegration/chrome/src/logo/logo-48x48.png
Normal file
BIN
ressourcen/browserintegration/chrome/src/logo/logo-48x48.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.9 KiB |
20
ressourcen/browserintegration/chrome/src/manifest.json
Normal file
20
ressourcen/browserintegration/chrome/src/manifest.json
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "__MSG_name__",
|
||||
"background_page": "background.html",
|
||||
"version": "1.0",
|
||||
"default_locale": "en",
|
||||
"description": "__MSG_description__",
|
||||
"icons": {
|
||||
"16": "logo/logo-16x16.png",
|
||||
"48": "logo/logo-48x48.png",
|
||||
"128": "logo/logo-128x128.png"
|
||||
},
|
||||
"page_action": {
|
||||
"default_icon": "logo/logo-16x16.png",
|
||||
"default_title": "__MSG_buttonTitle__"
|
||||
},
|
||||
"permissions": [
|
||||
"http://127.0.0.1/",
|
||||
"tabs"
|
||||
]
|
||||
}
|
BIN
ressourcen/jd/img/logo/logo-128x128.png
Normal file
BIN
ressourcen/jd/img/logo/logo-128x128.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 29 KiB |
BIN
ressourcen/jd/img/logo/logo-48x48.png
Normal file
BIN
ressourcen/jd/img/logo/logo-48x48.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.9 KiB |
@ -357,7 +357,7 @@ public class Main {
|
||||
// JDUtilities.getController().fireControlEvent(new ControlEvent(this,
|
||||
// SplashScreen.SPLASH_PROGRESS, "This is JD :)"));
|
||||
init.init();
|
||||
LOG.info(new Date() + "");
|
||||
LOG.info((new Date()).toString());
|
||||
LOG.info("init Configuration");
|
||||
// JDUtilities.getController().fireControlEvent(new ControlEvent(this,
|
||||
// SplashScreen.SPLASH_PROGRESS, "Once upon a time..."));
|
||||
|
@ -249,75 +249,87 @@ public class JDExternInterface extends PluginOptional {
|
||||
}
|
||||
|
||||
} else if (namespace.equalsIgnoreCase("flash") || namespace.equalsIgnoreCase("jsonp")) {
|
||||
if (splitPath.length > 1 && splitPath[1].equalsIgnoreCase("add")) {
|
||||
askPermission(request);
|
||||
/* parse the post data */
|
||||
String urls[] = Regex.getLines(Encoding.htmlDecode(request.getParameters().get("urls")));
|
||||
String passwords[] = Regex.getLines(Encoding.htmlDecode(request.getParameters().get("passwords")));
|
||||
String source = Encoding.urlDecode(request.getParameters().get("source"), false);
|
||||
if (urls.length != 0) {
|
||||
ArrayList<DownloadLink> links = new DistributeData(Encoding.htmlDecode(request.getParameters().get("urls"))).findLinks();
|
||||
for (DownloadLink link : links) {
|
||||
link.addSourcePluginPasswords(passwords);
|
||||
if (source != null) link.setBrowserUrl(source);
|
||||
if (splitPath.length > 1) {
|
||||
if (splitPath[1].equalsIgnoreCase("add")) {
|
||||
askPermission(request);
|
||||
/* parse the post data */
|
||||
String urls[] = Regex.getLines(Encoding.htmlDecode(request.getParameters().get("urls")));
|
||||
String passwords[] = Regex.getLines(Encoding.htmlDecode(request.getParameters().get("passwords")));
|
||||
String source = Encoding.urlDecode(request.getParameters().get("source"), false);
|
||||
String comment = Encoding.urlDecode(request.getParameters().get("comment"), false);
|
||||
if (urls.length != 0) {
|
||||
ArrayList<DownloadLink> links = new DistributeData(Encoding.htmlDecode(request.getParameters().get("urls"))).findLinks();
|
||||
for (DownloadLink link : links) {
|
||||
link.addSourcePluginPasswords(passwords);
|
||||
if (comment != null) link.setSourcePluginComment(comment);
|
||||
if (source != null) link.setBrowserUrl(source);
|
||||
}
|
||||
LinkGrabberController.getInstance().addLinks(links, false, false);
|
||||
new GuiRunnable<Object>() {
|
||||
|
||||
@Override
|
||||
public Object runSave() {
|
||||
SwingGui.getInstance().getMainFrame().toFront();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}.waitForEDT();
|
||||
response.addContent(addJSONPCallback("success", request));
|
||||
} else {
|
||||
response.addContent(addJSONPCallback("failed", request));
|
||||
}
|
||||
} else if (splitPath[1].equalsIgnoreCase("addcrypted")) {
|
||||
askPermission(request);
|
||||
/* parse the post data */
|
||||
String dlc = Encoding.htmlDecode(request.getParameters().get("crypted")).trim().replace(" ", "+");
|
||||
File tmp = JDUtilities.getResourceFile("tmp/jd_" + System.currentTimeMillis() + ".dlc", true);
|
||||
tmp.deleteOnExit();
|
||||
|
||||
JDIO.saveToFile(tmp, dlc.getBytes());
|
||||
ArrayList<DownloadLink> links = JDUtilities.getController().getContainerLinks(tmp);
|
||||
|
||||
LinkGrabberController.getInstance().addLinks(links, false, false);
|
||||
new GuiRunnable<Object>() {
|
||||
|
||||
@Override
|
||||
public Object runSave() {
|
||||
SwingGui.getInstance().getMainFrame().toFront();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}.waitForEDT();
|
||||
response.addContent(addJSONPCallback("success", request));
|
||||
} else {
|
||||
response.addContent(addJSONPCallback("failed", request));
|
||||
}
|
||||
} else if (splitPath.length > 1 && splitPath[1].equalsIgnoreCase("addcrypted")) {
|
||||
askPermission(request);
|
||||
/* parse the post data */
|
||||
String dlc = Encoding.htmlDecode(request.getParameters().get("crypted")).trim().replace(" ", "+");
|
||||
File tmp = JDUtilities.getResourceFile("tmp/jd_" + System.currentTimeMillis() + ".dlc", true);
|
||||
tmp.deleteOnExit();
|
||||
} else if (splitPath[1].equalsIgnoreCase("addcrypted2")) {
|
||||
askPermission(request);
|
||||
/* parse the post data */
|
||||
String crypted = Encoding.htmlDecode(request.getParameters().get("crypted")).trim().replace(" ", "+");
|
||||
String jk = Encoding.urlDecode(request.getParameters().get("jk"), false);
|
||||
String k = Encoding.urlDecode(request.getParameters().get("k"), false);
|
||||
String passwords = Encoding.urlDecode(request.getParameters().get("passwords"), false);
|
||||
String source = Encoding.urlDecode(request.getParameters().get("source"), false);
|
||||
try {
|
||||
decrypt(crypted, jk, k, passwords, source);
|
||||
|
||||
JDIO.saveToFile(tmp, dlc.getBytes());
|
||||
ArrayList<DownloadLink> links = JDUtilities.getController().getContainerLinks(tmp);
|
||||
response.addContent(addJSONPCallback("success", request));
|
||||
new GuiRunnable<Object>() {
|
||||
@Override
|
||||
public Object runSave() {
|
||||
SwingGui.getInstance().getMainFrame().toFront();
|
||||
return null;
|
||||
}
|
||||
}.waitForEDT();
|
||||
} catch (Exception e) {
|
||||
JDLogger.exception(e);
|
||||
|
||||
LinkGrabberController.getInstance().addLinks(links, false, false);
|
||||
new GuiRunnable<Object>() {
|
||||
@Override
|
||||
public Object runSave() {
|
||||
SwingGui.getInstance().getMainFrame().toFront();
|
||||
return null;
|
||||
response.addContent(addJSONPCallback("failed " + e.getMessage(), request.getParameters().get("callback")));
|
||||
}
|
||||
}.waitForEDT();
|
||||
response.addContent(addJSONPCallback("success", request));
|
||||
} else if (splitPath.length > 1 && splitPath[1].equalsIgnoreCase("addcrypted2")) {
|
||||
askPermission(request);
|
||||
/* parse the post data */
|
||||
String crypted = Encoding.htmlDecode(request.getParameters().get("crypted")).trim().replace(" ", "+");
|
||||
String jk = Encoding.urlDecode(request.getParameters().get("jk"), false);
|
||||
String k = Encoding.urlDecode(request.getParameters().get("k"), false);
|
||||
String passwords = Encoding.urlDecode(request.getParameters().get("passwords"), false);
|
||||
String source = Encoding.urlDecode(request.getParameters().get("source"), false);
|
||||
try {
|
||||
decrypt(crypted, jk, k, passwords, source);
|
||||
} else if (splitPath[1].equalsIgnoreCase("checkSupportForUrl")) {
|
||||
|
||||
response.addContent(addJSONPCallback("success", request));
|
||||
new GuiRunnable<Object>() {
|
||||
@Override
|
||||
public Object runSave() {
|
||||
SwingGui.getInstance().getMainFrame().toFront();
|
||||
return null;
|
||||
}
|
||||
}.waitForEDT();
|
||||
} catch (Exception e) {
|
||||
JDLogger.exception(e);
|
||||
|
||||
response.addContent(addJSONPCallback("failed " + e.getMessage(), request.getParameters().get("callback")));
|
||||
// TODO: Bugtracker Issue #1729
|
||||
String url = Encoding.htmlDecode(request.getParameters().get("url"));
|
||||
String urlSupported = new Boolean(DistributeData.hasPluginFor(url, true)).toString();
|
||||
response.addContent(addJSONPCallback(urlSupported, request.getParameters().get("callback")));
|
||||
} else {
|
||||
response.addContent(addJSONPCallback("unknowncommand", request.getParameters().get("callback")));
|
||||
}
|
||||
} else {
|
||||
response.addContent(addJSONPCallback(JDUtilities.getJDTitle(), request.getParameters().get("callback")));
|
||||
|
Loading…
Reference in New Issue
Block a user