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
d822da4c06
commit
ba5cb7d5c6
2 changed files with 7 additions and 2 deletions
|
@ -563,7 +563,8 @@ Zotero.Attachments = new function(){
|
||||||
reject(e);
|
reject(e);
|
||||||
},
|
},
|
||||||
true,
|
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
|
* @param {Boolean} dontDelete Don't delete the hidden browser upon completion; calling function
|
||||||
* must call deleteHiddenBrowser itself.
|
* must call deleteHiddenBrowser itself.
|
||||||
* @param {Zotero.CookieSandbox} [cookieSandbox] Cookie sandbox object
|
* @param {Zotero.CookieSandbox} [cookieSandbox] Cookie sandbox object
|
||||||
|
* @param {Object} [docShellPrefs] See Zotero.Browser.createHiddenBrowser
|
||||||
* @return {browser} Hidden browser used for loading
|
* @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
|
// (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
|
// pageshow is called before we call pageshow with an incomplete document
|
||||||
const LOADING_STATE_TIMEOUT = 120;
|
const LOADING_STATE_TIMEOUT = 120;
|
||||||
|
@ -1342,6 +1343,9 @@ Zotero.HTTP = new function() {
|
||||||
currentURL = 0;
|
currentURL = 0;
|
||||||
for(var i=0; i<urls.length; i++) {
|
for(var i=0; i<urls.length; i++) {
|
||||||
let hiddenBrowser = Zotero.Browser.createHiddenBrowser();
|
let hiddenBrowser = Zotero.Browser.createHiddenBrowser();
|
||||||
|
for (let pref in docShellPrefs) {
|
||||||
|
hiddenBrowser.docShell[pref] = docShellPrefs[pref];
|
||||||
|
}
|
||||||
if (cookieSandbox) {
|
if (cookieSandbox) {
|
||||||
cookieSandbox.attachToBrowser(hiddenBrowser);
|
cookieSandbox.attachToBrowser(hiddenBrowser);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue