如何轉換使用deprecadted E4X的腳本?在不支持E4x的情況下轉換greasemonkey腳本
我不是程序員,但是如果你向我解釋我需要開始的地方,我會盡我所能。
在第一,似乎不是CDATA的一個問題...
這裏的鏈接,在Buggzilla,在這裏我介紹我的問題: Firefox 17 breaks a Greasemonkey script that relies on E4X (New : Firefox 21 delete totally its support)
我這裏得到第一指數之其中E4X是使用(代碼 「RICCB」 搜索):
requestImageComments: function(id) {
if (!id) return;
var tkey = 'getComments';
// Set up ticket status queue if needed
if (!this.ticketStatus[tkey]) this.ticketStatus[tkey] = new Object();
return this.flickrApi
({ method: 'flickr.photos.comments.getList', photo_id: id },
'ricCB', {ticktype: tkey});
},
ricCB: function(rsp) {
var hash = this.objects.comments;
for each (comments in rsp.comments) {
// for (var cs = 0; cs < rsp.comments.length; cs++) {
// var comments = rsp.comments[cs];
var pid = [email protected]_id;
for each (com in comments.comment) {
var uname = [email protected];
var nsid = [email protected];
this.setTranslation({ uname: uname, nsid: nsid });
// var create = new Date([email protected]);
var ctxt = com + '';
// Strip out HTML tags:
ctxt = ctxt.replace(/(\<|\<\;).+?(\>|\>\;)/g,'');
// Collapse all whitespace runs to single spaces:
ctxt = ctxt.replace(/[\s\n\r\t]+/g, ' ');
// Store data under both authorname and photo ID (hash
// will collide only if someone is using a pure
// integer as a name AND a photo has same integer).
var info = { txt: ctxt, uname: uname, photo: pid };
if (!hash[uname]) hash[uname] = new Array();
if (!hash[pid]) hash[pid] = new Array();
hash[uname].push(info);
hash[pid].push(info);
}
}
最初張貼在這裏: My Greasemonkey script stopped working after something updated
該腳本似乎沒有使用任何E4X。這可能不是問題。然而,劇本是7歲!自那時起,Flickr可能會發生很大的變化。爲你改寫腳本不是[so]的意思;閱讀[faq]瞭解如何改寫這個問題。 (提示:確切的錯誤消息,演示問題的代碼以及你曾嘗試過的代碼)。 –
我認爲它是E4X:在「Bug 814633 - Firefox 17打破了依賴於E4X的Greasemonkey腳本(新增功能:Firefox 21完全刪除了它的支持)「Boris Zbarsky寫道: 用戶腳本的第558行是: var pid = comments。@ photo_id; 這絕對看起來像一個e4x主義對我來說。 還有幾條這樣的線。 只需在http:// userscripts中搜索名爲「ricCB」的函數即可。org/scripts/review/5016 我不希望你重寫代碼,但你只是簡單地解釋如何去做... – decembre
好的,仔細檢查一下,它確實使用了E4X。但這仍然不是一個合適的SO問題。修復該腳本至少需要重構'parseXML'函數和所有其他使用其輸出的函數。你需要把它分解成可能幫助有同樣問題的人。這個問題需要一個SSCCE。閱讀[常見問題]並編輯您的問題,否則將被忽略並關閉。 –