Fixes some assets not being saved with SingleFile snapshots
Part of zotero/zotero-connectors#394 When saving an item (e.g. on arxiv) with a site translator, the translator may add a custom snapshot attachment URL which does not match the translation URL (the URL in the browser where translation was initiated) in which case Zotero handles snapshot saving. Zotero loads the page in a background browser. By default images are not loaded in this browser. SingleFile due to CORS restrictions has to refetch all resources that are not from the same domain or subdomain, but uses pre-loaded resources (images) from the same domain. Before this change any images that were from the same domain as the saved website were not saved in the snapshot. This commit fixes that.
This commit is contained in:
parent
3ba78dec78
commit
1955427d62
2 changed files with 7 additions and 2 deletions
|
@ -558,7 +558,8 @@ Zotero.Attachments = new function(){
|
|||
reject(e);
|
||||
},
|
||||
true,
|
||||
cookieSandbox
|
||||
cookieSandbox,
|
||||
{ allowImages: true }
|
||||
);
|
||||
});
|
||||
};
|
||||
|
|
|
@ -1217,9 +1217,10 @@ Zotero.HTTP = new function() {
|
|||
* @param {Boolean} dontDelete Don't delete the hidden browser upon completion; calling function
|
||||
* must call deleteHiddenBrowser itself.
|
||||
* @param {Zotero.CookieSandbox} [cookieSandbox] Cookie sandbox object
|
||||
* @param {Object} [docShellPrefs] See Zotero.Browser.createHiddenBrowser
|
||||
* @return {browser} Hidden browser used for loading
|
||||
*/
|
||||
this.loadDocuments = function (urls, processor, onDone, onError, dontDelete, cookieSandbox) {
|
||||
this.loadDocuments = function (urls, processor, onDone, onError, dontDelete, cookieSandbox, docShellPrefs={}) {
|
||||
// (Approximately) how many seconds to wait if the document is left in the loading state and
|
||||
// pageshow is called before we call pageshow with an incomplete document
|
||||
const LOADING_STATE_TIMEOUT = 120;
|
||||
|
@ -1349,6 +1350,9 @@ Zotero.HTTP = new function() {
|
|||
currentURL = 0;
|
||||
for(var i=0; i<urls.length; i++) {
|
||||
let hiddenBrowser = Zotero.Browser.createHiddenBrowser();
|
||||
for (let pref in docShellPrefs) {
|
||||
hiddenBrowser.docShell[pref] = docShellPrefs[pref];
|
||||
}
|
||||
if (cookieSandbox) {
|
||||
cookieSandbox.attachToBrowser(hiddenBrowser);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue