Created
August 17, 2010 09:36
-
-
Save koyachi/529085 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tombloo www.delicious.com対応修正, github最新版とのdiff | |
% diff -u ~/source/tombloo/xpi/chrome/content/library/20_model.js ~/Library/Application\ Support/Firefox/Profiles/cfsal59b.default/extensions/[email protected]/chrome/content/library/20_model.js > ~/tmp/hoge.text | |
--- /Users/koyachi/source/tombloo/xpi/chrome/content/library/20_model.js 2010-08-17 18:13:55.000000000 +0900 | |
+++ /Users/koyachi/Library/Application Support/Firefox/Profiles/cfsal59b.default/extensions/[email protected]/chrome/content/library/20_model.js 2010-08-17 18:31:03.000000000 +0900 | |
@@ -101,7 +101,7 @@ | |
getToken : function(){ | |
return request(FFFFOUND.URL + 'bookmarklet.js').addCallback(function(res){ | |
- return res.responseText.match(/token ?= ?'(.*?)'/)[1]; | |
+ return res.responseText.match(/token='(.*?)'/)[1]; | |
}); | |
}, | |
@@ -1097,7 +1097,7 @@ | |
models.register({ | |
name : 'Delicious', | |
- ICON : 'http://delicious.com/favicon.ico', | |
+ ICON : 'http://www.delicious.com/favicon.ico', | |
/** | |
* ユーザーの利用しているタグ一覧を取得する。 | |
@@ -1137,7 +1137,7 @@ | |
self.getCurrentUser(); | |
// ブックマークレット用画面の削除リンクを使い既ブックマークを判定する | |
- return request('http://delicious.com/save', { | |
+ return request('http://www.delicious.com/save', { | |
queryString : { | |
noui : 1, | |
url : url, | |
@@ -1152,7 +1152,7 @@ | |
return $x('id("save-' + part + '-tags")//a[contains(@class, "tag-list-tag")]/text()', doc, true); | |
} | |
return { | |
- editPage : editPage = 'http://delicious.com/save?url=' + url, | |
+ editPage : editPage = 'http://www.delicious.com/save?url=' + url, | |
form : { | |
item : doc.getElementById('title').value, | |
description : doc.getElementById('notes').value, | |
@@ -1182,7 +1182,7 @@ | |
getCurrentUser : function(){ | |
// FIXME: 判定不完全、_userが取得できて、かつ、ログアウトしている状態がありうる | |
- if(decodeURIComponent(getCookieString('delicious.com', '_user')).match(/user=(.*?) /)) | |
+ if(decodeURIComponent(getCookieString('www.delicious.com', '_user')).match(/user=(.*?) /)) | |
return RegExp.$1; | |
throw new Error(getMessage('error.notLoggedin')); | |
@@ -1193,7 +1193,7 @@ | |
}, | |
post : function(ps){ | |
- return request('http://delicious.com/post/', { | |
+ return request('http://www.delicious.com/post/', { | |
queryString : { | |
title : ps.item, | |
url : ps.itemUrl, | |
@@ -1204,7 +1204,7 @@ | |
if(!elmForm) | |
throw new Error(getMessage('error.notLoggedin')); | |
- return request('http://delicious.com' + $x('id("saveitem")/@action', doc), { | |
+ return request('http://www.delicious.com' + $x('id("saveitem")/@action', doc), { | |
redirectionLimit : 0, | |
sendContent : update(formContents(elmForm), { | |
description : ps.item, | |
@@ -1435,10 +1435,7 @@ | |
}, | |
isBookmarked : function(uri){ | |
- return this.getBookmarkId(uri) != null; | |
- | |
- // 存在しなくてもtrueが返ってくるようになり利用できない | |
- // return NavBookmarksService.isBookmarked(createURI(uri)); | |
+ return NavBookmarksService.isBookmarked(createURI(uri)); | |
}, | |
removeBookmark : function(uri){ | |
@@ -2350,20 +2347,16 @@ | |
mix_id : mixId, | |
} | |
}).addCallback(function(res){ | |
- var track = res.set.track; | |
- | |
// 最後のトラック以降にはトラック個別情報が含まれない | |
- if(!track.url){ | |
+ if(!res.track.item){ | |
d.callback(tracks); | |
return; | |
} | |
- track.number = ++number; | |
- tracks.push(track); | |
+ res.track.number = ++number; | |
+ tracks.push(res.track); | |
me(); | |
}).addErrback(function(e){ | |
- error(e); | |
- | |
// 異常なトラックをスキップする(破損したJSONが返る) | |
if(e.message.name == 'SyntaxError') | |
me(); | |
@@ -2503,19 +2496,15 @@ | |
convert : function(str, name){ | |
var service; | |
var self = this; | |
- | |
+ | |
return this.getService(name).addCallback(function(res){ | |
- var strForRequest; | |
- | |
service = res; | |
charset = self.charsets[service.charset]; | |
if(charset != 'utf-8') | |
- strForRequest = escape(str.convertFromUnicode(charset)); | |
- else | |
- strForRequest = encodeURIComponent(str); | |
+ str = escape(str.convertFromUnicode(charset)); | |
- return request(service.url.replace(/%s/, strForRequest), { | |
+ return request(service.url.replace(/%s/, str), { | |
charset : charset, | |
}); | |
}).addCallback(function(res){ | |
@@ -2578,68 +2567,6 @@ | |
}, | |
}); | |
-models.register({ | |
- name : 'Soundcloud', | |
- URL : 'http://soundcloud.com/', | |
- ICON : 'http://soundcloud.com/favicon.ico', | |
- | |
- normalizeTrackUrl : function(url){ | |
- if(!url) | |
- return; | |
- | |
- url = createURI(url); | |
- url = url.prePath + url.filePath; | |
- | |
- return url.extract('^(.+:/(/.+?){3})(/|$)'); | |
- }, | |
- | |
- getPageInfo : function(url){ | |
- url = this.normalizeTrackUrl(url); | |
- | |
- return request(url).addCallback(function(res){ | |
- var doc = convertToHTMLDocument(res.responseText); | |
- var tokens = url.split('/'); | |
- var track = tokens.pop(); | |
- var user = tokens.pop(); | |
- | |
- var info = {user:user, track:track}; | |
- ['uid', 'token'].forEach(function(prop){ | |
- info[prop] = res.responseText.extract('"' + prop + '":"(.+?)"'); | |
- }); | |
- | |
- info.download = !!$x('//a[contains(@class, "download")]', doc); | |
- info.type = (info.download)? $x('//span[contains(@class, "file-type")]/text()', doc) || 'mp3' : 'mp3'; | |
- | |
- info.title = $x('//div[contains(@class, "info-header")]//h1', doc).textContent.replace(/[\n\r\t]/g, ''); | |
- | |
- return info; | |
- }); | |
- }, | |
- | |
- download : function(url, file){ | |
- var self = this; | |
- url = this.normalizeTrackUrl(url); | |
- | |
- return this.getPageInfo(url).addCallback(function(info){ | |
- if(!file){ | |
- file = getDownloadDir(); | |
- file.append(self.name); | |
- file.append(info.user); | |
- createDir(file); | |
- | |
- file.append(validateFileName( | |
- info.title + | |
- ((info.download)? '' : ' (STREAM)') + | |
- '.' + info.type)); | |
- } | |
- | |
- return download((info.download)? | |
- url + '/download' : | |
- 'http://media.soundcloud.com/stream/' + info.uid + '?stream_token=' + info.token, file, true); | |
- }); | |
- }, | |
-}); | |
- | |
models.register(update({}, AbstractSessionService, { | |
name : 'NDrive', | |
ICON : 'http://ndrive1.naver.jp/favicon.ico', |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment