diff --git a/extension-manifest.json b/extension-manifest.json index ffcf14f..9aa8b61 100644 --- a/extension-manifest.json +++ b/extension-manifest.json @@ -11,5 +11,6 @@ "homepage_url": "https://github.com/ix64/unlock-music", "browser_action": { "default_popup": "./popup.html" - } + }, + "content_security_policy": "script-src 'self' https://stats.ixarea.com; object-src 'self'" } diff --git a/public/index.html b/public/index.html index bd60e18..33e39ab 100644 --- a/public/index.html +++ b/public/index.html @@ -5,13 +5,10 @@ - - - - 音乐解锁 + @@ -27,12 +24,12 @@ style="border:0"/>

请勿直接运行源代码!

-
- + diff --git a/public/ixarea-stats.js b/public/ixarea-stats.js new file mode 100644 index 0000000..5cb9f71 --- /dev/null +++ b/public/ixarea-stats.js @@ -0,0 +1,10 @@ +var _paq = window._paq || []; +_paq.push(["setRequestMethod", "POST"], ["trackPageView"], ["enableLinkTracking"], + ["setSiteId", "2"], ["setTrackerUrl", "https://stats.ixarea.com/ixarea-stats/report"]); + +var tag = document.createElement('script'); +tag.type = 'text/javascript'; +tag.async = true; +tag.src = 'https://stats.ixarea.com/ixarea-stats.js'; +var s = document.getElementsByTagName('script')[0]; +s.parentNode.insertBefore(tag, s); diff --git a/public/loader.js b/public/loader.js new file mode 100644 index 0000000..b257fa5 --- /dev/null +++ b/public/loader.js @@ -0,0 +1,25 @@ +(function () { + setTimeout(function () { + var ele = document.getElementById("loader-tips-timeout"); + if (ele != null) { + ele.hidden = false; + } + }, 2000); + + var ua = navigator && navigator.userAgent; + var detected = (function () { + var m; + if (!ua) return true; + if (/MSIE |Trident\//.exec(ua)) return true; // no IE + m = /Edge\/([\d.]+)/.exec(ua); // Edge >= 17 + if (m && Number(m[1]) < 17) return true; + m = /Chrome\/([\d.]+)/.exec(ua); // Chrome >= 58 + if (m && Number(m[1]) < 58) return true; + m = /Firefox\/([\d.]+)/.exec(ua); // Firefox >= 45 + return m && Number(m[1]) < 45; + })(); + if (detected) { + document.getElementById('loader-tips-outdated').hidden = false; + document.getElementById("loader-tips-timeout").hidden = false; + } +})(); diff --git a/src/registerServiceWorker.js b/src/registerServiceWorker.js index 5f6a312..a2c6497 100644 --- a/src/registerServiceWorker.js +++ b/src/registerServiceWorker.js @@ -2,7 +2,8 @@ import {register} from 'register-service-worker' -if (process.env.NODE_ENV === 'production') { +if (process.env.NODE_ENV === 'production' && window.location.protocol === "https:") { + register(`${process.env.BASE_URL}service-worker.js`, { ready() { console.log('App is being served from cache by a service worker.')