Skip to content

Commit

Permalink
Remove location.search on init.
Browse files Browse the repository at this point in the history
  • Loading branch information
CXuesong committed Dec 7, 2019
1 parent dfeaac0 commit 52f9451
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion assets/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script>
Array.from || (Array.from = function () { var e = Object.prototype.toString, n = function (n) { return "function" == typeof n || "[object Function]" === e.call(n) }, o = Math.pow(2, 53) - 1, t = function (e) { var n = function (e) { var n = Number(e); return isNaN(n) ? 0 : 0 !== n && isFinite(n) ? (n > 0 ? 1 : -1) * Math.floor(Math.abs(n)) : n }(e); return Math.min(Math.max(n, 0), o) }; return function (e) { var o = Object(e); if (null == e) throw new TypeError("Array.from requires an array-like object - not null or undefined"); var r, i = arguments.length > 1 ? arguments[1] : void 0; if (void 0 !== i) { if (!n(i)) throw new TypeError("Array.from: when provided, the second argument must be a function"); arguments.length > 2 && (r = arguments[2]) } for (var a, c = t(o.length), l = n(this) ? Object(new this(c)) : new Array(c), u = 0; u < c;)a = o[u], l[u] = i ? void 0 === r ? i(a, u) : i.call(r, a, u) : a, u += 1; return l.length = c, l } }()), [Element.prototype, CharacterData.prototype, DocumentType.prototype].forEach(function (e) { e.hasOwnProperty("remove") || Object.defineProperty(e, "remove", { configurable: !0, enumerable: !0, writable: !0, value: function () { null !== this.parentNode && this.parentNode.removeChild(this) } }) }), function () { var e = [], n = function () { e.push([new Date].concat(Array.from(arguments))) }; function o(e, n) { var o = "__rlc_" + n; window[o] = function () { const n = window.event.currentTarget; t(e, n.src || n.href, "load" === window.event.type), delete window[o] } } function t(e, o, t) { try { o = new URL(o, document.location).href } catch (e) { } n("_RL", e, o, t) } function r(e, o) { var r = document.createElement("link"), i = document.createElement("link"), a = !1; r.rel = i.rel = "stylesheet", r.onload = function () { a = !0, t(e, o, !0), i.remove() }, r.onerror = function (n) { console.log(n), t(e, o, !1) }, r.href = o; var c = o.replace("fonts.googleapis.com", "fonts.proxy.ustclug.org"); c !== o && window.setTimeout(function () { a || (i.onload = function () { t(e, c, !0), r.remove() }, r.onerror = function () { t(e, c, !1) }, i.href = c, document.head.appendChild(i), n("Added fallback CDN link.", e)) }, 1500), document.head.appendChild(r), n("Added CDN link.", e, o) } window.__drainBacklog = function (o) { e.forEach(o), e = void 0, n = function () { o([new Date].concat(Array.from(arguments))) }, delete window.__drainBacklog }, r("mui-css", "https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap"), r("mui-icon", "https://fonts.googleapis.com/icon?family=Material+Icons"), o("index-js", "ij"), o("index-css", "ic"), o("index1-css", "ic1") }();
Array.from || (Array.from = function () { var e = Object.prototype.toString, o = function (o) { return "function" == typeof o || "[object Function]" === e.call(o) }, n = Math.pow(2, 53) - 1, t = function (e) { var o = function (e) { var o = Number(e); return isNaN(o) ? 0 : 0 !== o && isFinite(o) ? (o > 0 ? 1 : -1) * Math.floor(Math.abs(o)) : o }(e); return Math.min(Math.max(o, 0), n) }; return function (e) { var n = Object(e); if (null == e) throw new TypeError("Array.from requires an array-like object - not null or undefined"); var r, a = arguments.length > 1 ? arguments[1] : void 0; if (void 0 !== a) { if (!o(a)) throw new TypeError("Array.from: when provided, the second argument must be a function"); arguments.length > 2 && (r = arguments[2]) } for (var i, c = t(n.length), l = o(this) ? Object(new this(c)) : new Array(c), f = 0; f < c;)i = n[f], l[f] = a ? void 0 === r ? a(i, f) : a.call(r, i, f) : i, f += 1; return l.length = c, l } }()), [Element.prototype, CharacterData.prototype, DocumentType.prototype].forEach(function (e) { e.hasOwnProperty("remove") || Object.defineProperty(e, "remove", { configurable: !0, enumerable: !0, writable: !0, value: function () { null !== this.parentNode && this.parentNode.removeChild(this) } }) }), function () { var e = [], o = function () { e.push([new Date].concat(Array.from(arguments))) }; function n(e, o) { var n = "__rlc_" + o; window[n] = function () { const o = window.event.currentTarget; t(e, o.src || o.href, "load" === window.event.type), delete window[n] } } function t(e, n, t) { try { n = new URL(n, document.location).href } catch (e) { } o("_RL", e, n, t) } function r(e, n) { var r = document.createElement("link"), a = document.createElement("link"), i = !1; r.rel = a.rel = "stylesheet", r.onload = function () { i = !0, t(e, n, !0), a.remove() }, r.onerror = function (o) { console.log(o), t(e, n, !1) }, r.href = n; var c = n.replace("fonts.googleapis.com", "fonts.proxy.ustclug.org"); c !== n && window.setTimeout(function () { i || (a.onload = function () { t(e, c, !0), r.remove() }, r.onerror = function () { t(e, c, !1) }, a.href = c, document.head.appendChild(a), o("Added fallback CDN link.", e)) }, 1500), document.head.appendChild(r), o("Added CDN link.", e, n) } if (window.__drainBacklog = function (n) { e.forEach(n), e = void 0, o = function () { n([new Date].concat(Array.from(arguments))) }, delete window.__drainBacklog }, location.search) { if ("?" !== location.search) { var a; if ("function" == typeof URLSearchParams) { var i = new URLSearchParams(location.search); a = {}, i.forEach(function (e, o) { a[o] ? Array.isArray(o) ? a[o].push(e) : a[o] = [a[o], e] : a[o] = e }) } o("location.search", location.search, a) } if ("function" == typeof URL && history.replaceState) { var c = new URL(location.href); c.search = "", history.replaceState(history.state, document.title, c.href) } else location.search = null } r("mui-css", "https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap"), r("mui-icon", "https://fonts.googleapis.com/icon?family=Material+Icons"), n("index-js", "ij"), n("index-css", "ic"), n("index1-css", "ic1") }();
</script>
<link rel="stylesheet" type="text/css" href="./index.css" onload="__rlc_ic();" onerror="__rlc_ic();">
<link rel="stylesheet" type="text/css" href="./index1.css" onload="__rlc_ic1();" onerror="__rlc_ic1();">
Expand Down
27 changes: 27 additions & 0 deletions shared/index.snippet.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,33 @@ if (!Array.from) {
document.head.appendChild(l);
pushTrace("Added CDN link.", trackId, nominalUrl);
}
if (location.search) {
if (location.search !== "?") {
var dict;
if (typeof URLSearchParams === "function") {
var sp = new URLSearchParams(location.search);
dict = {};
sp.forEach(function (v, k) {
if (!dict[k]) {
dict[k] = v;
} else if (Array.isArray(k)) {
dict[k].push(v);
} else {
dict[k] = [dict[k], v];
}
});
}
pushTrace("location.search", location.search, dict);
}
// Remove search params (our "search" is inside hash)
if (typeof URL === "function" && history.replaceState) {
var u = new URL(location.href);
u.search = "";
history.replaceState(history.state, document.title, u.href);
} else {
location.search = null;
}
}
addCDNLink("mui-css", "https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap");
addCDNLink("mui-icon", "https://fonts.googleapis.com/icon?family=Material+Icons");
registerResourceLoadCallback("index-js", "ij");
Expand Down

0 comments on commit 52f9451

Please sign in to comment.