Chrome扩展程序会破坏Google表格

时间:2016-02-02 15:55:15

标签: google-chrome-extension google-analytics

我正在使用Chrome扩展程序来记录我使用Google云端硬盘的分析。我使用了webNavigation.onCompleted.addListener函数来发送分析页面视图,除了表单之外,它都能正常工作。

我正在间歇性地无法正确装入纸张。但是,没有任何内容在扩展程序的控制台中记录为错误 - 它显示一切正常。在我试图加载的工作表的控制台中,我发现了两个奇怪的错误。

第一个(尽管它的荣耀)是:

Uncaught TypeError: Cannot read property 'setTimeout' of undefined
Mfb                  @ 2046562200-ritz_waffle_i18n_core.js:2745
pN                   @ 2046562200-ritz_waffle_i18n_core.js:2746
ggb                  @ 2046562200-ritz_waffle_i18n_core.js:2757
fxb                  @ 2046562200-ritz_waffle_i18n_core.js:3558
r.load               @ 2046562200-ritz_waffle_i18n_core.js:3555
loadWaffle           @ edit:163
w2b                  @ ritz-0.js:1465
KGb                  @ ritz-0.js:990
g                    @ ritz-0.js:2
jC                   @ ritz-0.js:649
mC                   @ ritz-0.js:652
(anonymous function) @ ritz-0.js:651
AGb                  @ ritz-0.js:3
(anonymous function) @ ritz-0.js:7622
(anonymous function) @ VM3274:1
m                    @ edit:110
(anonymous function) @ edit:111
d                    @ edit:107
(anonymous function) @ edit:108

第二个是:

Uncaught TypeError: Cannot read property 'Yu' of undefined
r.jLa                @ 2046562200-ritz_waffle_i18n_core.js:361

我无法理解是什么造成了这个问题。我的代码没有修改任何标题,只有在Web导航完成后才会触发。以下是导致此问题的功能:

chrome.webNavigation.onCompleted.addListener(
// callback
function(info) {
    console.log("webNavigation Complete - Docs");
    console.log(info.url);
    var fields = { hitType:'pageview'};
    chrome.pageAction.show(info.tabId);  

    // check for editor of docs, sheets, slides, etc.
    if (info.url.indexOf('docs') > -1 && info.url.indexOf('/d/') > -1) {
        var start = info.url.indexOf('.com/')+5;
        var end = info.url.indexOf('/',start+1);
        var type = info.url.substring(start,end);
        start = end+2;
        end = info.url.indexOf('/',start+1);
        var docId = info.url.substring(start,end);
        fields['page'] = docId;
        ga('send','event',type,'Load');

    } 
    // check for editor of docs, sheets, slides, etc.
    if (info.url.indexOf('macros') > -1 && info.url.indexOf('/d/') > -1) {
        console.log('Apps-Script');
        ga('send','event',type,'Apps-Script');
    }

    if (info.url.indexOf('drive') > -1 ){
        fields['page'] = '/drive';
    }

    if (fields.page) {
        var tabId = info.tabId;
        chrome.pageAction.show(tabId);
        chrome.tabs.get(tabId,function(tab) {
            fields['title'] = tab.title;
            console.log(fields);
            //ga('send',fields);
        });

    }

},
//filters
{url:[{hostContains:'docs.google.com'},
     {hostContains:'drive.google.com'}]
});

0 个答案:

没有答案