diff options
-rw-r--r-- | happy_hacking_vimperator.js | 3 | ||||
-rw-r--r-- | stella.js | 29 |
2 files changed, 17 insertions, 15 deletions
diff --git a/happy_hacking_vimperator.js b/happy_hacking_vimperator.js index 3a6607d..816a374 100644 --- a/happy_hacking_vimperator.js +++ b/happy_hacking_vimperator.js @@ -3320,7 +3320,8 @@ let PLUGIN_INFO = xml` } }); - around(events, 'onKeyPress', function (next, [event]) { + around(events, 'onKeyPress', function (next, args) { + let event = args[0]; let keyStr = events.toString(event); let fmaping = let (fmap = liberator.plugins.feedSomeKeys_3) (fmap && fmap.API.State.feeding); if (!fmaping && !events.feedingKeys && uncleanKeys.some(function(v) v == keyStr)) { @@ -313,14 +313,12 @@ Thanks: return mis; } - let dm = Cc["@mozilla.org/download-manager;1"].getService(Ci.nsIDownloadManager); - let wbp = Cc["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"].createInstance(Ci.nsIWebBrowserPersist); let file; if (filepath) { file = io.File(io.expandPath(filepath)); } else { - file = dm.userDownloadsDirectory; + file = io.File(FileUtils.getDir("DfltDwnld", [""])); } if (file.exists() && file.isDirectory() && title) @@ -329,12 +327,15 @@ Thanks: if (file.exists()) return U.echoError('The file already exists! -> ' + file.path); - file = makeFileURI(file); - - let dl = dm.addDownload(0, U.makeURL(url, null, null), file, title, null, null, null, null, wbp); - wbp.progressListener = dl; - wbp.persistFlags |= wbp.PERSIST_FLAGS_AUTODETECT_APPLY_CONVERSION; - wbp.saveURI(U.makeURL(url), null, null, postData && makePostStream(postData), null, file); + Task.spawn(function () { + if (postData) { + yield U.httpRequest(url, postData, function (xhr) { + file.write(xhr.response); + }); + } else { + yield Downloads.fetch(url, file); + } + }).then(null, Cu.reportError); return file; }, @@ -1020,7 +1021,7 @@ Thanks: }, get title () - content.document.title.replace(/^YouTube - /, ''), + content.document.title.replace(/- YouTube$/, ''), get totalTime () parseInt(this.player.getDuration()), @@ -1032,7 +1033,7 @@ Thanks: fetch: function (filepath) { // all(1080p,720p,480p,360p) -> 37, 22, 35, 34, 5 // FIXME 一番初めが最高画質だと期待 - let cargs = content.wrappedJSObject.yt.playerConfig.args; + let cargs = content.wrappedJSObject.ytplayer.config.args; cargs.url_encoded_fmt_stream_map.split(',')[0].split('&').forEach(function(x) { let [key, val] = x.split('='); if (key == 'url') { @@ -1156,12 +1157,12 @@ Thanks: }, get title () - content.document.title.replace(/^YouTube - /, ''), + content.document.title.replace(/ - YouTube$/, ''), fetch: function (filepath) { // all(1080p,720p,480p,360p) -> 37, 22, 35, 34, 5 // FIXME 一番初めが最高画質だと期待 - let cargs = content.wrappedJSObject.yt.playerConfig.args; + let cargs = content.wrappedJSObject.ytplayer.config.args; cargs.url_encoded_fmt_stream_map.split(',')[0].split('&').forEach(function(x) { let [key, val] = x.split('='); if (key == 'url') { @@ -1476,7 +1477,7 @@ Thanks: } }, - get title () content.document.title.replace(/\s*\u2010\s*\u30CB\u30B3\u30CB\u30B3\u52D5\u753B(.+)$/, ''), + get title () content.document.title.replace(/\s*\u002D\s*\u30CB\u30B3\u30CB\u30B3\u52D5\u753B(.+)$/, ''), get totalTime () parseInt(this.player.ext_getTotalTime()), |