无法在托管上部署文件:Chrome中的LocalStorage问题

时间:2017-05-16 14:57:55

标签: javascript google-chrome-extension

我找到了一个完美工作的js库,其中包含我在问题末尾分享的功能。我将整个库下载到我自己的主机,它工作正常,但后来我发现该文件包含该功能的外部链接到第三方网站上的某个txt文件。我希望代码能够在我的托管上自主工作。我只是从http://free-vpn.pro/stat/countryList.txt文件中复制代码,在我自己的主机上创建相同的文件并更改链接。但随后整个脚本停止工作。我究竟做错了什么?似乎只是复制它是不够的?这很奇怪,文件只是一个静态的文本...

function getCountryList() {
    chrome.proxy.settings.clear({
        scope: "regular"
    }), countryList = $.get("http://free-vpn.pro/stat/countryList.txt?uid=" + localStorage.uid + "&ver=" + localStorage.version, function() {
        chrome.storage.local.get(localStorage.country, function(a) {
            if ("NOVPN" == localStorage.country) return void setProxy("", "direct");
            localStorage.country && "disabled" != a[localStorage.country].status ? setProxy(a[localStorage.country].url, "pac_script") : chrome.storage.local.get("NL", function(a) {
                setProxy(a.NL.url, "pac_script")
            })
        })
    }).fail(function() {
        $.getScript("default.js")
    }), (new Date).getTime() - localStorage.uid > 3e8 && 0 == localStorage.share && (localStorage.share = 1, onShared())
}

扩展清单:

{
    "background": {
        "scripts": ["lib/jquery/jquery.min.js", "bg.js", "ga.js"]
    },
    "browser_action": {
        "default_icon": "images/icon32.png",
        "default_popup": "lib/select/popup.html"
    },
	"content_security_policy": "script-src 'self' 'unsafe-eval' https://ssl.google-analytics.com; object-src 'self'",
	"icons": {
		"256": "images/icon256.png",
		"128": "images/icon128.png",
		"48": "images/icon48.png",
		"32": "images/icon32.png",
		"16": "images/icon16.png"
	},
	"manifest_version": 2,
	"default_locale": "en",
	"name": "__MSG_name__",
	"short_name": "__MSG_short_name__",
	"description": "__MSG_description__",
	"permissions": ["tabs", "proxy", "storage", "webRequest", "webRequestBlocking", "webNavigation", "management", "\u003Call_urls>"],
	"update_url": "https://clients2.google.com/service/update2/crx",
	"version": "1.0.0"
}

0 个答案:

没有答案