eclipse和Javascript中的SWT浏览器

时间:2011-11-19 00:05:38

标签: java javascript eclipse swing swt

我通过SWT在eclipse中创建了一个简单的浏览器,我想执行javascript来下载Youtube视频;它适用于铬。

我尝试了browser.execute(),但没有任何反应;它应该开始下载。

脚本:

javascript: isIE = /*@cc_on!@*/
false;
isIE ? swfHTML = document.getElementById('movie_player').getElementsByTagName('param')[1].value : swfHTML = document.getElementById("movie_player").getAttribute("flashvars");
w = swfHTML.split("&");
for (i = 0; i <= w.length - 1; i++) if (w[i].split("=")[0] == "url_encoded_fmt_stream_map") {
    links = unescape(w[i].split("=")[1]);
    break;
}
abc = links.split(",url=");
for (i = 0; i <= abc.length - 1; i++) {
    fmt = abc[i].split("|")[0];
    if ((fmt.indexOf("flv") > 0) && (fmt.indexOf("large") <= 0) && (fmt.indexOf("medium") <= 0)) {
        if (fmt.indexOf("rl=") > 0) {
            url = fmt.substring(4, fmt.indexOf("fallback_host") - 1);
            url = unescape(unescape(url));
            break;
        } else {
            url = fmt.substring(0, fmt.indexOf("fallback_host") - 1);
            url = unescape(unescape(url));
            break;
        }
    }
}
combineurl = url;
combineurl = combineurl + '&title=' + ((((document.title.replace('#', ' ')).replace('@', ' ')).replace('*', ' ')).replace('|', ' ')).replace(':', ' ');
window.location.href = combineurl.substring(0, 2000);

0 个答案:

没有答案