Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/442.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 未捕获的语法错误:输入意外结束_Javascript_Jquery_Html_Google Chrome Extension - Fatal编程技术网

Javascript 未捕获的语法错误:输入意外结束

Javascript 未捕获的语法错误:输入意外结束,javascript,jquery,html,google-chrome-extension,Javascript,Jquery,Html,Google Chrome Extension,我在google chrome扩展的javascript控制台中遇到这个错误,我不知道为什么,有人能帮我吗? 以下是我的脚本: popup.js function urlReduce(href){ href = href.replace(href.substring(href.indexOf(location.pathname), href.length), ""); href = href.replace("http://", "").replace("www.", "");

我在google chrome扩展的javascript控制台中遇到这个错误,我不知道为什么,有人能帮我吗? 以下是我的脚本:

popup.js

function urlReduce(href){
    href = href.replace(href.substring(href.indexOf(location.pathname), href.length), "");
    href = href.replace("http://", "").replace("www.", "");
    return href;
}

chrome.runtime.onMessage.addListener(function (message) {
    var hosts = ["novamov.com", "videoweed.es", "vidspot.net", "allmyvideos.net", "streamcloud.eu", "magnovideo.com", "played.to", "vk.com", "moevideos.net", "youtube.com", "videomega.tv", "movshare.net"];
    var url = urlReduce(message.url);
    var found = $.inArray(url, hosts) > -1;
    if (found) {
    alert("sending msg");
        chrome.runtime.sendMessage({method:'getInfo'}, function(response){
            var response_array = response.split(",");
            var title = response_array[0];
            var serie = response_array[1];
            var number = response_array[2];
            var url = response_array[3];            
        });


        $("#serie").html(serie);
        $("#url").html(url);
        $("#number").html(number);
        $("#title").html(title);
    }
}
这里是popup.html中的标题

<head>
<script src="jquery.min.js"></script>
<script src="popup.js"></script>
</head>

第二个函数有回调,未正确关闭

function urlReduce(href) {
    href = href.replace(href.substring(href.indexOf(location.pathname), href.length), "");
    href = href.replace("http://", "").replace("www.", "");
    return href;
}

chrome.runtime.onMessage.addListener(function (message) {
    var hosts = ["novamov.com", "videoweed.es", "vidspot.net", "allmyvideos.net", "streamcloud.eu", "magnovideo.com", "played.to", "vk.com", "moevideos.net", "youtube.com", "videomega.tv", "movshare.net"];
    var url = urlReduce(message.url);
    var found = $.inArray(url, hosts) > -1;
    if (found) {
        alert("sending msg");
        chrome.runtime.sendMessage({
            method: 'getInfo'
        }, function (response) {
            var response_array = response.split(",");
            var title = response_array[0];
            var serie = response_array[1];
            var number = response_array[2];
            var url = response_array[3];
        });


        $("#serie").html(serie);
        $("#url").html(url);
        $("#number").html(number);
        $("#title").html(title);
    }
}); // close it properly
浏览器控制台应该告诉你错误在哪里,至少我的是这样