SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Jul 2012
    Posts
    155
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Extension stopped working with Google Chrome manifest v2

    I am developing an extension for Google Chrome that was working perfectly, but now stopped working with version 2 of the manifest.

    It is giving me the following error:

    HTML Code:
    Uncaught SyntaxError: Unexpected end of input
    popup.js:

    HTML Code:
    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();
        }
    
    });
    I think the problem is in this part of popup.js (line 61):

    HTML Code:
    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>');
    });
    Do not know if it's accurate but all hosted files for extension: http://www.mediafire.com/?0f7mrjvxtw5u4ad

  2. #2
    SitePoint Zealot
    Join Date
    Jul 2012
    Posts
    155
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Someone?

  3. #3
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    8,897
    Mentioned
    138 Post(s)
    Tagged
    2 Thread(s)
    The problem is with your jquery.jfeed.pack.js file, as that tries to eval code, which is not allowed anymore in chrome under manifest 2. See http://stackoverflow.com/questions/1...allowed-for-th

    What you should do:

    1) Download jquery.jfeed (https://github.com/jfhovinne/jFeed/downloads)
    2) Extract it
    3) Remove js/jquery.jfeed.pack.js from your extension
    4) Place jfhovinne-jFeed-0d411f7/build/dist/jquery.jfeed.js in your js/ directory
    5) Change js/jquery.jfeed.pack.js to js/jquery.jfeed.js in background.html and manifest.json

    After that the extension works again, at least it does for me
    Rémon - Hosting Advisor

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •