correctly fix the USO bug with populating settings on their site
previously we disconnected the interceptor on first XHR response, which is not necessarily for the style, so now we wait until an actual one.
This commit is contained in:
parent
e8d0c7d039
commit
777adf1bae
|
@ -24,17 +24,20 @@ chrome.runtime.onMessage.addListener((msg, sender, sendResponse) => {
|
|||
document.documentElement.appendChild(document.createElement('script')).text = '(' +
|
||||
function () {
|
||||
let settings;
|
||||
const originalResponseJson = Response.prototype.json;
|
||||
document.addEventListener('stylusFixBuggyUSOsettings', function _({detail}) {
|
||||
document.removeEventListener('stylusFixBuggyUSOsettings', _);
|
||||
settings = /\?/.test(detail) && new URLSearchParams(new URL(detail).search);
|
||||
if (!settings) {
|
||||
Response.prototype.json = originalResponseJson;
|
||||
}
|
||||
});
|
||||
const originalResponseJson = Response.prototype.json;
|
||||
Response.prototype.json = function (...args) {
|
||||
return originalResponseJson.call(this, ...args).then(json => {
|
||||
Response.prototype.json = originalResponseJson;
|
||||
if (!settings || typeof ((json || {}).style_settings || {}).every !== 'function') {
|
||||
return json;
|
||||
}
|
||||
Response.prototype.json = originalResponseJson;
|
||||
const images = new Map();
|
||||
for (const jsonSetting of json.style_settings) {
|
||||
let value = settings.get('ik-' + jsonSetting.install_key);
|
||||
|
|
Loading…
Reference in New Issue
Block a user