[CRX] Drop code supporting ancient Chrome versions

This commit is contained in:
Rob Wu 2023-07-02 17:10:17 +02:00
parent 2c74323e3d
commit 70db938fe7
5 changed files with 24 additions and 76 deletions

View File

@ -22,11 +22,7 @@ function getViewerURL(pdf_url) {
return VIEWER_URL + "?file=" + encodeURIComponent(pdf_url); return VIEWER_URL + "?file=" + encodeURIComponent(pdf_url);
} }
if (CSS.supports("animation", "0s")) { document.addEventListener("animationstart", onAnimationStart, true);
document.addEventListener("animationstart", onAnimationStart, true);
} else {
document.addEventListener("webkitAnimationStart", onAnimationStart, true);
}
function onAnimationStart(event) { function onAnimationStart(event) {
if (event.animationName === "pdfjs-detected-object-or-embed") { if (event.animationName === "pdfjs-detected-object-or-embed") {

View File

@ -1,11 +1,6 @@
/** /**
* Detect creation of <embed> and <object> tags. * Detect creation of <embed> and <object> tags.
*/ */
@-webkit-keyframes pdfjs-detected-object-or-embed {
from {
/* empty */
}
}
@keyframes pdfjs-detected-object-or-embed { @keyframes pdfjs-detected-object-or-embed {
from { from {
/* empty */ /* empty */
@ -13,9 +8,6 @@
} }
object, object,
embed { embed {
-webkit-animation-delay: 0s !important;
-webkit-animation-name: pdfjs-detected-object-or-embed !important;
-webkit-animation-play-state: running !important;
animation-delay: 0s !important; animation-delay: 0s !important;
animation-name: pdfjs-detected-object-or-embed !important; animation-name: pdfjs-detected-object-or-embed !important;
animation-play-state: running !important; animation-play-state: running !important;

View File

@ -154,19 +154,7 @@ chrome.webRequest.onBeforeRequest.addListener(
return { redirectUrl: viewerUrl }; return { redirectUrl: viewerUrl };
}, },
{ {
urls: [ urls: ["file://*/*.pdf", "file://*/*.PDF"],
"file://*/*.pdf",
"file://*/*.PDF",
...// Duck-typing: MediaError.prototype.message was added in Chrome 59.
(MediaError.prototype.hasOwnProperty("message")
? []
: [
// Note: Chrome 59 has disabled ftp resource loading by default:
// https://www.chromestatus.com/feature/5709390967472128
"ftp://*/*.pdf",
"ftp://*/*.PDF",
]),
],
types: ["main_frame", "sub_frame"], types: ["main_frame", "sub_frame"],
}, },
["blocking"] ["blocking"]
@ -252,10 +240,3 @@ chrome.runtime.onMessage.addListener(function (message, sender, sendResponse) {
} }
return undefined; return undefined;
}); });
// Remove keys from storage that were once part of the deleted feature-detect.js
chrome.storage.local.remove([
"featureDetectLastUA",
"webRequestRedirectUrl",
"extensionSupportsFTP",
]);

View File

@ -42,30 +42,18 @@ var g_requestHeaders = {};
// g_referrers[tabId][frameId] = referrer of PDF frame. // g_referrers[tabId][frameId] = referrer of PDF frame.
var g_referrers = {}; var g_referrers = {};
var extraInfoSpecWithHeaders; // = ['requestHeaders', 'extraHeaders']
(function () { (function () {
var requestFilter = { var requestFilter = {
urls: ["*://*/*"], urls: ["*://*/*"],
types: ["main_frame", "sub_frame"], types: ["main_frame", "sub_frame"],
}; };
function registerListener(extraInfoSpec) {
extraInfoSpecWithHeaders = extraInfoSpec;
// May throw if the given extraInfoSpec is unsupported.
chrome.webRequest.onSendHeaders.addListener( chrome.webRequest.onSendHeaders.addListener(
function (details) { function (details) {
g_requestHeaders[details.requestId] = details.requestHeaders; g_requestHeaders[details.requestId] = details.requestHeaders;
}, },
requestFilter, requestFilter,
extraInfoSpec ["requestHeaders", "extraHeaders"]
); );
}
try {
registerListener(["requestHeaders", "extraHeaders"]);
} catch {
// "extraHeaders" is not supported in Chrome 71 and earlier.
registerListener(["requestHeaders"]);
}
chrome.webRequest.onBeforeRedirect.addListener(forgetHeaders, requestFilter); chrome.webRequest.onBeforeRedirect.addListener(forgetHeaders, requestFilter);
chrome.webRequest.onCompleted.addListener(forgetHeaders, requestFilter); chrome.webRequest.onCompleted.addListener(forgetHeaders, requestFilter);
chrome.webRequest.onErrorOccurred.addListener(forgetHeaders, requestFilter); chrome.webRequest.onErrorOccurred.addListener(forgetHeaders, requestFilter);
@ -126,7 +114,7 @@ chrome.runtime.onConnect.addListener(function onReceivePort(port) {
types: ["xmlhttprequest"], types: ["xmlhttprequest"],
tabId, tabId,
}, },
["blocking", ...extraInfoSpecWithHeaders] ["blocking", "requestHeaders", "extraHeaders"]
); );
} }
// Acknowledge the message, and include the latest referer for this frame. // Acknowledge the message, and include the latest referer for this frame.

View File

@ -70,12 +70,6 @@ limitations under the License.
var deduplication_id = getDeduplicationId(wasUpdated); var deduplication_id = getDeduplicationId(wasUpdated);
var extension_version = chrome.runtime.getManifest().version; var extension_version = chrome.runtime.getManifest().version;
if (window.Request && "mode" in Request.prototype) {
// fetch is supported in extensions since Chrome 42 (though the above
// feature-detection method detects Chrome 43+).
// Unlike XMLHttpRequest, fetch omits credentials such as cookies in the
// requests, which guarantees that the server cannot track the client
// via HTTP cookies.
fetch(LOG_URL, { fetch(LOG_URL, {
method: "POST", method: "POST",
headers: new Headers({ headers: new Headers({
@ -85,14 +79,11 @@ limitations under the License.
// Set mode=cors so that the above custom headers are included in the // Set mode=cors so that the above custom headers are included in the
// request. // request.
mode: "cors", mode: "cors",
// Omits credentials such as cookies in the requests, which guarantees
// that the server cannot track the client via HTTP cookies.
credentials: "omit",
cache: "no-store",
}); });
return;
}
var x = new XMLHttpRequest();
x.open("POST", LOG_URL);
x.setRequestHeader("Deduplication-Id", deduplication_id);
x.setRequestHeader("Extension-Version", extension_version);
x.send();
}); });
} }