<commit_before>var gImageForward = {

    preferences: Components
                     .classes["@mozilla.org/preferences-service;1"]
                     .getService(Components.interfaces.nsIPrefService),

    onLoad: function() {
        if ('undefined' == typeof gBrowser) {
            return;
        }
        window.removeEventListener('load', gImageForward.onLoad, false);
        window.addEventListener('unload', gImageForward.onUnload, false);
    },

    onUnload: function() {
        window.removeEventListener('unload', gImageForward.onUnload, false);
    },

    go: function() {
        var documents = gImageForward.getDocuments();
        var urlsAndReferrers = gImageForward.getURLsAndReferrers(documents);
        gImageForward.addURLsToHistoryAndAdvance(urlsAndReferrers);
    },

    getDocuments: function() {
        var documents = new Array();
        documents.push(gBrowser.selectedBrowser.contentWindow.document);
        for(var index = 0; index < gBrowser.selectedBrowser.contentWindow.frames.length; index++) {
            documents.push(gBrowser.selectedBrowser.contentWindow.frames[index].document);
        }
        return documents;
    },

    getURLsAndReferrers: function(documents) {
        var result = new Array()
        for(var documentIndex = 0; documentIndex < documents.length; documentIndex++) {
            var urls = gImageForward.matchURLs(documents[documentIndex].links);
            var referrer = documents[documentIndex].URL;
            for(var urlIndex = 0; urlIndex < urls.length; urlIndex++) {
                result.push(gImageForward.makeTuple(urls[urlIndex], referrer));
            }
        }
        return result;
    },<commit_msg>Start implementing manual url loading<commit_after>var gImageForward = {

    preferences: Components
                     .classes["@mozilla.org/preferences-service;1"]
                     .getService(Components.interfaces.nsIPrefService),

    onLoad: function() {
        if ('undefined' == typeof gBrowser) {
            return;
        }
        window.removeEventListener('load', gImageForward.onLoad, false);
        window.addEventListener('unload', gImageForward.onUnload, false);
    },

    onUnload: function() {
        window.removeEventListener('unload', gImageForward.onUnload, false);
    },

    go: function() {
        if (!gBrowser.selectedBrowser.imageForwardLinks) {
            var documents = gImageForward.getDocuments();
            var urlsAndReferrers = gImageForward.getURLsAndReferrers(documents);
            gBrowser.selectedBrowser.imageForwardLinks = urlsAndReferrers;
            gBrowser.selectedBrowser.imageForwardNextIndex = 0;
        }
        var links = gBrowser.selectedBrowser.imageForwardLinks;
        var index = gBrowser.selectedBrowser.imageForwardNextIndex;
        if (index > links.length -1) {
            gBrowser.selectedBrowser.contentWindow.history.go(-links.length)
            gBrowser.selectedBrowser.imageForwardNextIndex = 0;
        } else {
            var currentUrlAndReferrer = links[index];
            var url = currentUrlAndReferrer[0];
            if (url.indexOf("file://") == 0) {
                gBrowser.selectedBrowser.contentDocument.location.assign(url)
            } else {
                var referrerUrl = currentUrlAndReferrer[1];
                gBrowser.selectedBrowser.loadURI(url, makeURI(referrerUrl), null);
            }
            gBrowser.selectedBrowser.imageForwardNextIndex = index + 1;
        }

    },

    getDocuments: function() {
        var documents = new Array();
        documents.push(gBrowser.selectedBrowser.contentWindow.document);
        for(var index = 0; index < gBrowser.selectedBrowser.contentWindow.frames.length; index++) {
            documents.push(gBrowser.selectedBrowser.contentWindow.frames[index].document);
        }
        return documents;
    },

    getURLsAndReferrers: function(documents) {
        var result = new Array()
        for(var documentIndex = 0; documentIndex < documents.length; documentIndex++) {
            var urls = gImageForward.matchURLs(documents[documentIndex].links);
            var referrer = documents[documentIndex].URL;
            for(var urlIndex = 0; urlIndex < urls.length; urlIndex++) {
                result.push(gImageForward.makeTuple(urls[urlIndex], referrer));
            }
        }
        return result;
    },
{'fraction_non_alphanumeric': 0.10521521293554999, 'fraction_numerical': 0.003416078342063311, 'mean_word_length': 2.5333869670152858, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '201834', 'n_tokens_mistral': 1189, 'n_tokens_neox': 1142, 'n_words': 197}