Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 扩展已停止使用Google Chrome清单v2_Javascript_Jquery_Google Chrome Extension - Fatal编程技术网

Javascript 扩展已停止使用Google Chrome清单v2

Javascript 扩展已停止使用Google Chrome清单v2,javascript,jquery,google-chrome-extension,Javascript,Jquery,Google Chrome Extension,我正在为GoogleChrome开发一个扩展,它工作得很好,但现在停止使用清单的第2版 它给了我以下错误: Uncaught SyntaxError: Unexpected end of input popup.js: chrome.tabs.getSelected(null, function (aba) { link = aba.url; titulo = aba.title; document.getElementById('mensagem').value =

我正在为GoogleChrome开发一个扩展,它工作得很好,但现在停止使用清单的第2版

它给了我以下错误:

Uncaught SyntaxError: Unexpected end of input
popup.js:

chrome.tabs.getSelected(null, function (aba) {
    link = aba.url;
    titulo = aba.title;
    document.getElementById('mensagem').value = link;
});

function GrabIFrameURL(feedDescription) {
    var regex = new RegExp("iframe(?:.*?)src='(.*?)'", 'g');
    var matches = regex.exec(feedDescription);
    var url = '';
    if (matches.length == 2) {
        url = matches[1];
    }
    var quebra = url.split("/");
    return quebra[4];
}

$(document).ready(function () {
    if (localStorage.nome == '' || localStorage.nome == null || localStorage.email == '' || localStorage.email == null) {
        jQuery('#formulario').hide();
        jQuery('#erros').html('Configure seus dados <a href="options.html" target="_blank">aqui</a>');
    }

    jQuery("#resposta").ajaxStart(function () {
        jQuery(this).html("<img src='img/loading.gif'> <b>Sugestão sendo enviada, aguarde...</b>");
    });

    jQuery('#submit').click(function () {

        var nome = localStorage.nome;
        var email = localStorage.email;
        var mensagem = titulo + "\n\n<br><br>" + link;

        jQuery('#formulario').hide();
        jQuery.post('http://blabloo.com.br/naosalvo/mail.php', {
            nome: nome,
            email: email,
            mensagem: mensagem
        },

        function (data, ajaxStart) {
            jQuery('#resposta').html(data);
            console.log(data);
        });
        return false;
    });

    //Listagem de posts
    var bkg = chrome.extension.getBackgroundPage();

    jQuery('#close').click(function () {
        window.close();
    });

    jQuery('#markeall').click(function () {
        bkg.lidoAll();
        $('.naolido').attr('class', 'lido');
    });

    jQuery.each(bkg.getFeed(), function (id, item) {
        if (item.naolido == '1') 
            lidoClass = 'naolido';
        else 
            lidoClass = 'lido';
        var thumb = GrabIFrameURL(item.description);
        $('#feed').append('<li><a id="' + item.id + '" href="' + item.link + '" class="' + lidoClass + '"><img src="' + $.jYoutube(thumb, 'small') + '" class="' + lidoClass + '"/>' + item.title + '</a></li>');
    });

    $('.naolido').click(function (e) {
        e.preventDefault();
        klicked = $(this).attr('id');
        console.log(klicked);
        bkg.setLido(klicked);
        $(this).attr('class', 'lido');
        openLink($(this).attr('href'));
    });

    $('.lido').click(function (e) {
        openLink($(this).attr('href'));
    });

    var openLink = function (link) {
        chrome.tabs.create({
            'url': link,
            'selected': true
        });
        window.close();
    }

});
jQuery.each(bkg.getFeed(), function (id, item) {
        if (item.naolido == '1') 
            lidoClass = 'naolido';
        else 
            lidoClass = 'lido';
        var thumb = GrabIFrameURL(item.description);
        $('#feed').append('<li><a id="' + item.id + '" href="' + item.link + '" class="' + lidoClass + '"><img src="' + $.jYoutube(thumb, 'small') + '" class="' + lidoClass + '"/>' + item.title + '</a></li>');
});
chrome.tabs.getSelected(空,函数(aba){
link=aba.url;
titulo=aba.title;
document.getElementById('mensage')。value=link;
});
函数GrabIFrameURL(feedDescription){
var regex=new RegExp(“iframe(?:*?)src=”(*?”,“g”);
var matches=regex.exec(feedDescription);
var url='';
if(matches.length==2){
url=匹配项[1];
}
var quebra=url.split(“/”);
返回奎布拉[4];
}
$(文档).ready(函数(){
if(localStorage.nome=''|| localStorage.nome==null | | localStorage.email=''| localStorage.email==null){
jQuery(“#formulario”).hide();
jQuery('#erros').html('Configure seus dados');
}
jQuery(“#resposta”).ajaxStart(函数(){
jQuery(this.html(“Sugestão sendo enviada,aguarde…”);
});
jQuery(“#提交”)。单击(函数(){
var nome=localStorage.nome;
var email=localStorage.email;
var mensage=titulo+“\n\n

”+链接; jQuery(“#formulario”).hide(); jQuery.post('http://blabloo.com.br/naosalvo/mail.php', { 诺姆:诺姆, 电邮:电邮,, 男装:男装 }, 功能(数据、ajaxStart){ jQuery('#resposta').html(数据); 控制台日志(数据); }); 返回false; }); //邮政列表 var bkg=chrome.extension.getBackgroundPage(); jQuery(“#关闭”)。单击(函数(){ window.close(); }); jQuery('#markeall')。单击(函数(){ bkg.lidoAll(); $('.naolido').attr('class','lido'); }); jQuery.each(bkg.getFeed(),函数(id,item){ 如果(item.naolido==“1”) lidoClass=‘naolido’; 其他的 利多卡因类=‘利多’; var thumb=GrabIFrameURL(item.description); $(“#提要”)。追加(“
  • ”); }); $('.naolido')。单击(函数(e){ e、 预防默认值(); klicked=$(this.attr('id'); 控制台日志(klicked); bkg.setLido(克里克); $(this.attr('class','lido'); openLink($(this.attr('href')); }); $('.lido')。单击(函数(e){ openLink($(this.attr('href')); }); var openLink=函数(link){ chrome.tabs.create({ “url”:链接, “选定”:true }); window.close(); } });
    我认为问题出在popup.js的这一部分:

    jQuery.each(bkg.getFeed(), function (id, item) {
            if (item.naolido == '1') 
                lidoClass = 'naolido';
            else 
                lidoClass = 'lido';
            var thumb = GrabIFrameURL(item.description);
            $('#feed').append('<li><a id="' + item.id + '" href="' + item.link + '" class="' + lidoClass + '"><img src="' + $.jYoutube(thumb, 'small') + '" class="' + lidoClass + '"/>' + item.title + '</a></li>');
    });
    
    jQuery.each(bkg.getFeed(),函数(id,item){
    如果(item.naolido==“1”)
    lidoClass=‘naolido’;
    其他的
    利多卡因类=‘利多’;
    var thumb=GrabIFrameURL(item.description);
    $(“#提要”)。追加(“
  • ”); });
    您的问题实际上是在background.js的第12行和第20行,您最初将localStorage.items设置为
    '
    ,但稍后尝试在其上运行
    JSON.parse()
    ,但它不是JSON数据,因此JSON.parse返回
    输入的意外结束。而且,JSON.parse不是您定义的函数,而是本机浏览器函数,因此,它将错误显示为“第1行”


    尝试最初将它定义为一个空数组,然后像现在一样“推”到它。

    好吧,如果这是您的全部代码,那么您将缺少一个右大括号。。。通常,在
    if-else
    语句中使用大括号是一种很好的做法。我使用了键,但错误仍然存在。您能否提供完整的扩展名,如在zip文件夹或crx中?请遵循。rar:我没有看到错误。。。你知道它在哪一行吗?你能给我一个示例代码吗?我不太擅长jQuery。只需在setLocalStorage函数中设置localStorage项,如下所示:
    emptyArray=[];localStorage.items=JSON.stringify(emptyArray);localStorage.lido=JSON.stringify(emptyArray)
    您需要重新安装扩展并手动删除localStorage项(
    localStorage.removietem()
    ),以便重新设置它们。