From 337cdbbc9fb681a39f38886fc5a33128369c72f0 Mon Sep 17 00:00:00 2001 From: appotry Date: Wed, 27 Apr 2022 19:23:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E5=AE=8C=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E4=B9=8B=E5=89=8D=E7=94=B3=E8=AF=B7=E9=80=9A=E7=9F=A5=E6=9D=83?= =?UTF-8?q?=E9=99=90=E4=BD=93=E9=AA=8C=E4=B8=8D=E5=A5=BD=EF=BC=8C=E4=BC=9A?= =?UTF-8?q?=E8=A2=ABlighthouse=E4=B9=8B=E7=B1=BB=E7=9A=84=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 96385c2..353da83 100644 --- a/index.js +++ b/index.js @@ -107,7 +107,7 @@ hexo.on("deployAfter", async function (post) { //insert webpushr tracking code hexo.extend.filter.register('after_render:html', data => { var payload = `(function (w, d, s, id) { - if (typeof (w.webpushr) !== 'undefined') return; w.webpushr = w.webpushr || function () { (w.webpushr.q = w.webpushr.q || []).push(arguments) }; var js, fjs = d.getElementsByTagName(s)[0]; js = d.createElement(s); js.id = id; js.async = 1; js.src = "https://cdn.webpushr.com/app.min.js";fjs.parentNode.appendChild(js);}(window, document, 'script', 'webpushr-jssdk'));webpushr('setup', { 'key': '${hexo.config.webPushNotification.trackingCode}' });` + if (typeof (w.webpushr) !== 'undefined') return; w.webpushr = w.webpushr || function () { (w.webpushr.q = w.webpushr.q || []).push(arguments) }; var js, fjs = d.getElementsByTagName(s)[0]; js = d.createElement(s); js.id = id; js.async = false; js.src = "https://cdn.webpushr.com/app.min.js";fjs.parentNode.appendChild(js);}(window, document, 'script', 'webpushr-jssdk'));webpushr('setup', { 'key': '${hexo.config.webPushNotification.trackingCode}' });` // return data.replace(/(?!<\/body>).+?<\/body>/s, str => str.replace('', "")); return data.replace(/(?!<\/body>).+?<\/body>/s, str => str.replace('', "")); @@ -117,4 +117,4 @@ hexo.extend.filter.register('after_render:html', data => { //insert webpushr-sw.js to web root dir hexo.on('generateAfter', async function (post) { fs.writeFile('public/webpushr-sw.js', "importScripts('https://cdn.webpushr.com/sw-server.min.js');", function (err, data) { hexo.log.info("Generated: webpushr-sw.js") }) -}) \ No newline at end of file +})