Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Background.html error makes elements not load #30

Open
GoogleCodeExporter opened this issue Aug 23, 2015 · 0 comments
Open

Background.html error makes elements not load #30

GoogleCodeExporter opened this issue Aug 23, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. Browse to Facebook.com
2. Set refresh Time
3. Elements under your Friends birthdays fail to load

What is the expected output? What do you see instead?
I expected the full page to load so, maybe something such as an auto poker 
could poke someone instantly.  Instead it fails to load the elements like ads 
and the poke section.

What version of the product are you using? On what operating system?
Using Chrome Reload V0.5  on Ubuntu 11.04

Please provide any additional information below.
Chrome Reload reports

"Inspect active views:
background.html
To inspect a popup, right-click the page or browser action's icon and choose 
Inspect popup."

No such pop up exists, when its inspected via the extensions tab it is a blank 
html page, if I click on Resources and the background.html drop down, It shows

"<html>
<head>
<script>

    var tabs = new Array();

    chrome.extension.onConnect.addListener(function(port) {
        if (port.name === 'findReloadTime') {
            port.onMessage.addListener(function(data) {
                if (data.msg === 'getReloadTime') {
                    chrome.tabs.getSelected(null, function(tab) {
                        var tabIsReloaderActive = tabs[tab.id] || false;
                        if (tabIsReloaderActive) {
                            port.postMessage({ms_between_load:tabs[tab.id].ms_between_load, is_random:tabs[tab.id].is_random});
                        }
                    });
                }
            });
        }

    });

    function doReloader(time, isRandom) {
        if (time > 0) {
            chrome.tabs.getSelected(null, function(tab) {

                if (tabs[tab.id] || false) {
                    // if there is already a reloader setup for this tab, cancel it
                    cancelReload(tab.id);
                }

                tabs[tab.id] = new Array();
                tabs[tab.id]['action_url'] = tab.url;
                tabs[tab.id]['ms_between_load'] = time;
                tabs[tab.id]['seconds_to_next_reload'] = time/1000;
                tabs[tab.id]['is_random'] = isRandom;

                chrome.tabs.onUpdated.addListener(onUpdateListener);

                chrome.browserAction.setIcon({path:"icons/KnobLoopOn.png", tabId:tab.id});

                // reload the page
                // timers are set for the next reload (and a display timer) in the page load listener
                doReload(tab.id);
            });

        } else {
            chrome.tabs.getSelected(null, function(tab) {
                cancelReload(tab.id);
            });
        }
    }

    function onUpdateListener(tabId, changeInfo) {
        // Hide the badge text
        chrome.browserAction.setBadgeText({text:'', tabId:tabId});

        var tabIsReloaderActive = (tabs[tabId] || false) && (tabs[tabId].ms_between_load > 0 || false);        
        if (tabIsReloaderActive) {
            // can only get the URL infomation when the page is loading, not when it is complete
            if (changeInfo['status'] === 'loading') {
                // we want to cancel the reloader if they navigate away
                var urlChanged=changeInfo['url'] || false;
                if (urlChanged) {
                    // the URL has changed - presumably by navigation
                    // cancel the reloads
                    cancelReload(tabId);
                } else {
                    // reset the icon (it is cleared when reloaded)
                    chrome.browserAction.setIcon({path:"icons/KnobLoopOn.png", tabId:tabId}); // the icon is reset when the page is reloaded


                    // Cancel the timer display while the tab is reloading
                    cancelDisplayTimer(tabId);

                    // Cancel the reload time (in case the user manually reloaded the page)
                    if (tabs[tabId].reloadTimer || false) {
                        clearTimeout(tabs[tabId].reloadTimer);
                        tabs[tabId].reloadTimer = null;
                    }
                }
            } else if (changeInfo['status'] === 'complete') {
                // page has just completed loading

                // reset the icon (it is cleared when reloaded)
                chrome.browserAction.setIcon({path:"icons/KnobLoopOn.png", tabId:tabId}); // the icon is reset when the page is reloaded

                // if we are using random timouts then we need to reset the time related variables here
                if (tabs[tabId]['is_random']) {
                    var time = Math.floor(Math.random()*1800000);
                    tabs[tabId].ms_between_load = time;

                }

                // reset the timer for the countdown
                tabs[tabId].seconds_to_next_reload = tabs[tabId].ms_between_load/1000;



                // and set the correct countdown text
                setBadgeText(tabId);

                // set a timeout for the next reload
                setupReloadTimer(tabId);

                // make really sure this timeout is cancelled before we add a new one
                cancelDisplayTimer(tabId);

                // setup the reload countdown
                tabs[tabId].displayTimer = window.setInterval(function(tab_id) {
                        tabs[tab_id].seconds_to_next_reload--;
                        setBadgeText(tab_id);
                    }, 1000, tabId);
            }
        }
    }

    function setupReloadTimer(tabId) {
        // be sure to remove any reload timer before we add a new one
        if (tabs[tabId].reloadTimer || false) {
            clearTimeout(tabs[tabId].reloadTimer);
            tabs[tabId].reloadTimer = null;
        }

        // set the reload to occur in ms_between_load milliseconds time
        tabs[tabId].reloadTimer = window.setTimeout(function(tab_id) {
                doReload(tab_id);
            }, tabs[tabId].ms_between_load, tabId);
    }

    function cancelDisplayTimer(tabId) {
        if (tabs[tabId].displayTimer || false) {
            clearTimeout(tabs[tabId].displayTimer);
            tabs[tabId].displayTimer = null;
        }
    }

    function setBadgeText(tab_id) {
        //chrome.browserAction.setBadgeText({text:'p1', tabId:tab_id});

        if (tabs[tab_id].seconds_to_next_reload < 0) {
            // something is wrong! Don't display any text
            chrome.browserAction.setBadgeText({text:String(), tabId:tab_id});
            // cancel the time which is calling this. It will get recreated if the page is auto-reloaded
            cancelDisplayTimer(tab_id);
        } else {
            var badgeText = String(tabs[tab_id].seconds_to_next_reload);

            //var mins = Math.floor(tabs[tab_id].seconds_to_next_reload/60);
            var secs = tabs[tab_id].seconds_to_next_reload%60;
            //if (secs < 10) {
            //    secs = '0' + String(secs);
            //}            
            //badgeText= String(mins) + ':' + String(secs);

            var mins = Math.floor((tabs[tab_id].seconds_to_next_reload/60)%60);
            var hours = Math.floor((tabs[tab_id].seconds_to_next_reload/(60*60))%24);
            var days = Math.floor((tabs[tab_id].seconds_to_next_reload/(60*60*24)));

            // Format
            // The banner fits about 4.5 characters (depending on the character's width)
            if (days > 999) {
                badgeText = 'long'; // it will take long...
            } else if (days > 9) {
                badgeText = String(days) + 'd';
            } else if (days > 0) {
                // The 'h' will not entirely fit on the banner all the time.  Live with it.
                badgeText = String(days) + 'd' + String(hours) + 'h';
            } else if (hours > 0) {
                if (mins < 10) {
                    mins = '0' + String(mins);
                }
                // Blinking ':'
                // Note: The banner uses a variable-width font; both strings have to have the same width
            if (secs % 2) {
                var blinker = ':';
            } else {
                var blinker = ' ';
            }
            badgeText = String(hours) + blinker + String(mins);
            } else {
                    if (secs < 10) {
                        secs = '0' + String(secs);
                }
                badgeText = String(mins) + ':' + String(secs);
            }

            chrome.browserAction.setBadgeText({text:badgeText, tabId:tab_id});
        }
    }

    function cancelReload(tab_id) {
        if (tabs[tab_id].reloadTimer || false) {
            clearTimeout(tabs[tab_id].reloadTimer);
            tabs[tab_id].reloadTimer = null;
        }
        if (tabs[tab_id].displayTimer || false) {
            clearTimeout(tabs[tab_id].displayTimer);
            tabs[tab_id].displayTimer = null;
        }
        tabs[tab_id].ms_between_load = 0;
        tabs[tab_id].seconds_to_next_reload = 0;
        chrome.browserAction.setIcon({path:"icons/KnobLoopOff.png", tabId:tab_id});
        chrome.browserAction.setBadgeText({text:String(), tabId:tab_id});

    }

    function doReload(tab_id) {
        chrome.browserAction.setIcon({path:"icons/KnobLoopOn.png", tabId:tab_id});
        chrome.browserAction.setBadgeText({text:'', tabId:tab_id});

        // need to work out a way to make POST'ed pages reload
        chrome.tabs.update(tab_id, {url: tabs[tab_id].action_url});
        //chrome.tabs.executeScript(tab_id, {code: 'window.location.reload()'});

    }


</script>
</head>
</html>
"


Original issue reported on code.google.com by jaymesdr...@gmail.com on 23 Jul 2011 at 6:05

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant