Convert a greasemonkey Script after E4x is not supported

625 Views Asked by At

How to convert this script which use deprecadted E4X ?

Flickr Functional Suite.

i am not a programmer, but if you explain to me where i need to start, i do my best.

In first , it seems not a problem of CDATA ...

Here a link, in Buggzilla , where i describe my problem : Firefox 17 breaks a Greasemonkey script that relies on E4X (New : Firefox 21 delete totally its support)

I obtain here a first indice where E4x is in use (search in the code "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  = comments.@photo_id;
        for each (com in comments.comment) {
            var uname  = com.@authorname;
            var nsid   = com.@author;
            this.setTranslation( { uname: uname, nsid: nsid } );
            // var create = new Date( com.@datecreate );
            var ctxt  = com + '';
            // Strip out HTML tags:
            ctxt = ctxt.replace(/(\<|\&lt\;).+?(\>|\&gt\;)/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);
        }
    }

Initially posted here : My Greasemonkey script stopped working after something updated

1

There are 1 best solutions below

3
On

If there is a dependency on e4x, try including the JavaScript implementation:

As an alternative, here are other questions which cover mapping e4x syntax to XPath or XML to JSON:

In addition, you can continue to use e4x by accessing the data via yql:

References