Question

Here's the code, not abridged (it's shortish):

// ==UserScript==
// @name           Manga ChapterReader
// @license        MIT/X11 + Attribution (passcod)
// @namespace      http://www.mangareader.net
// @include        http://www.mangareader.net/*
// @description    Displays full chapters from MangaReader.net in a simpler interface.
// @author         passcod
// @version        10.331
// ==/UserScript==

// version format: y.z
function START(array_of_scripts_to_load, callback) {
    document.documentElement.innerHTML = '<head></head><body></body>';
    for ( i in array_of_scripts_to_load) {
        var script = document.createElement('script');
        script.src = array_of_scripts_to_load[i];
        var evl = new Object();
        evl.handleEvent = function (e) {
            callback();
        };
        script.addEventListener('load', evl, true);
        document.getElementsByTagName('head')[0].appendChild(script);
    }
}

var regular = /mangareader\.net\/[a-z0-9\-]+\/[0-9]+(\/.+)?/i, old = /mangareader\.net\/[0-9\-]+\/([a-z0-9\-]+)\/chapter-([0-9]+)\.htm/i;

if ( regular.test(window.location) ) {
    //START(['http://lib/libstore/jquery.js','http://scrap.book/userscripts/mangareader/index.js'],
    START(['http://code.jquery.com/jquery-1.4.2.min.js','https://bitbucket.org/passcod/scrap.book/raw/tip/userscripts/mangareader/index.js'],
    function() {
        $$$();
    });
}
else if ( old.test(window.location) ) {
    var parts = old.exec(window.location);
    window.location = 'http://www.mangareader.net/'+parts[1]+'/'+parts[2];
}

This works perfectly in Firefox 4.0b7 (Windows) and nightly (Linux), but it fails with Fx 3.6.x (Reports from 3.6, 3.6.2, and 3.6.12).

I can't see why.

Oh, wait... I use Scriptish on Fx 4... maybe this has to do with something?

But apart from that, I'm totally at loss. The scripts don't get loaded. It even looks like the document.documentElement.innerHTML = '...' line doesn't work... did it in Firebug and it erases the document to <html></html>, but nothing more happens afterward.

Any ideas?

Was it helpful?

Solution

I fixed this by changing the loaded scripts to execute immediately:

(function () { /* ... */ })();

and then removing the callbacks.

There was no problem with the browser, but in the reaction time. For some reason, the userscript finished too early in Fx 4.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top