workaround for URLSearchParams not stripping "?" in chrome 49-51

This commit is contained in:
tophf 2017-11-28 22:19:00 +03:00
parent a64dc26dd7
commit bf13383c93
4 changed files with 8 additions and 4 deletions

View File

@ -280,7 +280,8 @@ document.documentElement.appendChild(document.createElement('script')).text = '(
document.currentScript.remove(); document.currentScript.remove();
document.addEventListener('stylusFixBuggyUSOsettings', function _({detail}) { document.addEventListener('stylusFixBuggyUSOsettings', function _({detail}) {
document.removeEventListener('stylusFixBuggyUSOsettings', _); document.removeEventListener('stylusFixBuggyUSOsettings', _);
settings = /\?/.test(detail) && new URLSearchParams(new URL(detail).search); // TODO: remove .replace(/^\?/, '') when minimum_chrome_version >= 52 (https://crbug.com/601425)
settings = /\?/.test(detail) && new URLSearchParams(new URL(detail).search.replace(/^\?/, ''));
if (!settings) { if (!settings) {
Response.prototype.json = originalResponseJson; Response.prototype.json = originalResponseJson;
} }

View File

@ -1336,7 +1336,8 @@ function beautify(event) {
} }
function initStyleData() { function initStyleData() {
const params = new URLSearchParams(location.search); // TODO: remove .replace(/^\?/, '') when minimum_chrome_version >= 52 (https://crbug.com/601425)
const params = new URLSearchParams(location.search.replace(/^\?/, ''));
const id = params.get('id'); const id = params.get('id');
const createEmptyStyle = () => ({ const createEmptyStyle = () => ({
id: null, id: null,

View File

@ -3,7 +3,8 @@
'use strict'; 'use strict';
(() => { (() => {
const params = new URLSearchParams(location.search); // TODO: remove .replace(/^\?/, '') when minimum_chrome_version >= 52 (https://crbug.com/601425)
const params = new URLSearchParams(location.search.replace(/^\?/, ''));
let liveReload = false; let liveReload = false;
let installed = false; let installed = false;

View File

@ -8,7 +8,8 @@ const filtersSelector = {
numTotal: 0, numTotal: 0,
}; };
const urlFilterParam = new URLSearchParams(location.search).get('url'); // TODO: remove .replace(/^\?/, '') when minimum_chrome_version >= 52 (https://crbug.com/601425)
const urlFilterParam = new URLSearchParams(location.search.replace(/^\?/, '')).get('url');
if (location.search) { if (location.search) {
history.replaceState(0, document.title, location.origin + location.pathname); history.replaceState(0, document.title, location.origin + location.pathname);
} }