From 35f630c7ed01c9b5fb97d9e8886d7e3f7239aa7f Mon Sep 17 00:00:00 2001 From: PHO Date: Tue, 13 Apr 2010 13:00:40 +0900 Subject: [PATCH] Auto commit by The Sugar System. --- dot-files/_vimperator/plugin/_libly_js | 85 +++++++++++++++---- .../_vimperator/plugin/multi_requester_js | 2 +- 2 files changed, 70 insertions(+), 17 deletions(-) diff --git a/dot-files/_vimperator/plugin/_libly_js b/dot-files/_vimperator/plugin/_libly_js index 6d547a8..b459914 100644 --- a/dot-files/_vimperator/plugin/_libly_js +++ b/dot-files/_vimperator/plugin/_libly_js @@ -12,9 +12,9 @@ var PLUGIN_INFO = 適当なライブラリっぽいものたち。 suVene MIT - 0.1.24 - 1.2 - 2.0pre + 0.1.33 + 2.3pre + 2.3 http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/_libly.js || + { + original: オリジナルの関数 + current: 現在の関数 + restore: 元に戻すための関数 + } + ||< bind(obj, func): func に obj を bind します。 func内からは this で obj が参照できるようになります。 @@ -112,7 +123,7 @@ Request(url, headers, options): 以下のようにHTTPヘッダの値を指定できる(省略可) >|| { - 'Referrer' : 'http://example.com/' + 'Referer' : 'http://example.com/' } ||< 以下の値はデフォルトで設定される('Content-type'はPOST時のみ) @@ -223,14 +234,55 @@ libly.$U = {//{{{ } return ret; }, - around: function around (obj, name, func) { - let next = obj[name]; - let current = obj[name] = function () { - let self = this, args = arguments; - return func.call(self, function () next.apply(self, args), args); + around: (function () { + function getPluginPath () { + let pluginPath; + Error('hoge').stack.split(/\n/).some( + function (s) + let (m = s.match(/^\(\)@chrome:\/\/liberator\/content\/liberator\.js -> (.+):\d+$/)) + (m && (pluginPath = m[1])) + ); + return pluginPath; + } + + let restores = {}; + + return function (obj, name, func, autoRestore) { + let original; + let restore = function () obj[name] = original; + if (autoRestore) { + let pluginPath = getPluginPath(); + if (pluginPath) { + restores[pluginPath] = + (restores[pluginPath] || []).filter( + function (res) ( + res.object != obj || + res.name != name || + (res.restore() && false) + ) + ); + restores[pluginPath].push({ + object: obj, + name: name, + restore: restore + }); + } else { + liberator.echoerr('getPluginPath failed'); + } + } + original = obj[name]; + let current = obj[name] = function () { + let self = this, args = arguments; + return func.call(self, function (_args) original.apply(self, _args || args), args); + }; + libly.$U.extend(current, {original: original.original || original, restore: restore}); + return libly.$U.extend({ + original: original, + current: current, + restore: restore + }, [original, current]); }; - return [next, current]; - }, + })(), bind: function(obj, func) { return function() { return func.apply(obj, arguments); @@ -322,7 +374,7 @@ libly.$U = {//{{{ // }}} // System {{{ readDirectory: function(path, filter, func) { - var d = io.getFile(path); + var d = io.File(path); if (d.exists() && d.isDirectory()) { let enm = d.directoryEntries; let flg = false; @@ -366,7 +418,8 @@ libly.$U = {//{{{ let uhService = Cc["@mozilla.org/feed-unescapehtml;1"].getService(Ci.nsIScriptableUnescapeHTML); let text = str.replace(/^[\s\S]*?]*)?>[\s]*|<\/body[ \t\r\n]*>[\S\s]*$/ig, ''); let fragment = uhService.parseFragment(text, false, null, root); - let htmlFragment = document.implementation.createDocument(null, 'html', null); + let doctype = document.implementation.createDocumentType('html', '-//W3C//DTD HTML 4.01//EN', 'http://www.w3.org/TR/html4/strict.dtd'); + let htmlFragment = document.implementation.createDocument(null, 'html', doctype); htmlFragment.documentElement.appendChild(htmlFragment.importNode(fragment,true)); return htmlFragment; /* うまく動いていない場合はこちらに戻してください @@ -650,7 +703,7 @@ libly.Wedata.prototype = { req.addEventListener('onSuccess', libly.$U.bind(this, function(res) { var text = res.responseText; if (!text) { - errDispatcher('respons is null.', cache); + errDispatcher('response is null.', cache); return; } var json = libly.$U.evalJson(text); diff --git a/dot-files/_vimperator/plugin/multi_requester_js b/dot-files/_vimperator/plugin/multi_requester_js index 88f24e0..45f026d 100644 --- a/dot-files/_vimperator/plugin/multi_requester_js +++ b/dot-files/_vimperator/plugin/multi_requester_js @@ -116,7 +116,7 @@ var SITEINFO = [ name: "alc", description: "SPACE ALC (\u82F1\u8F9E\u6717 on the Web)", url: "http://eow.alc.co.jp/%s/UTF-8/", - xpath: 'id("resultList")' + xpath: 'id("resultsList")' } ]; var libly = liberator.plugins.libly; -- 2.40.0