From 84902d8e5ae2c1e4616ae698e97e1b9e08a75955 Mon Sep 17 00:00:00 2001 From: ilyaigpetrov Date: Fri, 5 Jun 2020 15:15:13 +0000 Subject: [PATCH] Dirty hack to turn off wrong caching of AntiZapret --- .../37-sync-pac-script-with-pac-provider-api.tmpl.js | 9 ++++++++- .../src/extension-common/manifest.tmpl.json | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-common/37-sync-pac-script-with-pac-provider-api.tmpl.js b/extensions/chromium/runet-censorship-bypass/src/extension-common/37-sync-pac-script-with-pac-provider-api.tmpl.js index c637ac7..4b62465 100644 --- a/extensions/chromium/runet-censorship-bypass/src/extension-common/37-sync-pac-script-with-pac-provider-api.tmpl.js +++ b/extensions/chromium/runet-censorship-bypass/src/extension-common/37-sync-pac-script-with-pac-provider-api.tmpl.js @@ -146,7 +146,14 @@ httpLib.ifModifiedSince(pacUrl, lastModifiedStr, (err, newLastModifiedStr) => { if (!newLastModifiedStr) { - const ifWasEverModified = lastModifiedStr !== new Date(0).toUTCString(); + /* + TODO: Get rid of this dirty hack + IPFS used by AntiZapret always returns last-modified date as new Date(1000) which is 1 sec since unix epoch. + Last-modified isn't changed but target redireciton URL is and this URL should be compared to the last cached URL. + Hack here is to consider 5 seconds since epoch time the same way as the unix epoch start. + If you think etags are the solution then know that etags can't be read from the fetch API, see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Expose-Headers. + */ + const ifWasEverModified = new Date(lastModifiedStr) - new Date(0) > 5000; if (ifWasEverModified) { addWarning( diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-common/manifest.tmpl.json b/extensions/chromium/runet-censorship-bypass/src/extension-common/manifest.tmpl.json index 7f19801..0f75361 100644 --- a/extensions/chromium/runet-censorship-bypass/src/extension-common/manifest.tmpl.json +++ b/extensions/chromium/runet-censorship-bypass/src/extension-common/manifest.tmpl.json @@ -6,7 +6,7 @@ "description": "__MSG_extDesc__", "version": "0.0.${version}", "icons": { - "128": "/icons/default-128.png" + "128": "icons/default-128.png" }, "author": "anticensority+owners@googlegroups.com",