summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeaHOH <Seahoh@Gmail.com>2022-04-15 21:21:33 +0800
committerSeaHOH <Seahoh@Gmail.com>2022-04-15 21:21:33 +0800
commit12b940d616f5f0ff35f7934e877fffff73e0affc (patch)
tree6852f447dedbacdef99bd30014655094a1d8c865
parent1414868b75aa5d3dea1ab60031b0c27631f92486 (diff)
downloadgithub-wc-polyfill-12b940d616f5f0ff35f7934e877fffff73e0affc.tar.gz
Bypass "invalid regexp group" error on GitLabs BORED!
-rw-r--r--bootstrap.js35
-rw-r--r--install.rdf4
2 files changed, 31 insertions, 8 deletions
diff --git a/bootstrap.js b/bootstrap.js
index 8dabbc6..3f4f63e 100644
--- a/bootstrap.js
+++ b/bootstrap.js
@@ -422,6 +422,15 @@ var httpObserver = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver, Ci.nsISupportsWeakReference])
};
+function replace1 (string, patterns, replacement) {
+ const oString = string;
+ for (let pattern of patterns) {
+ string = string.replace(pattern, replacement);
+ if (string != oString) break
+ }
+ return string;
+}
+
function tracingListener () {
this.receivedData = [];
}
@@ -444,26 +453,40 @@ tracingListener.prototype = {
let data = this.receivedData.join("");
try {
if (this.site == "github") {
- data = data.replace("<head>", "<head><script>" + pfFollowUp + "</script>");
- data = data.replace("<head>", "<head><script crossorigin=\"anonymous\" integrity=\"sha512-g4ztuyuFPzjTvIqYBeZdHEDaHz2K6RCz4RszsnL3m5ko4kiWCjB9W6uIScLkNr8l/BtC2dYiIFkOdOLDYBHLqQ==\" type=\"application/javascript\" src=\"https://github.githubassets.com/assets/compat-838cedbb.js\"></script>");
- data = data.replace("<head>", "<head><script>" + pfBase + "</script>");
+ data = data.replace("<head>", "<head><script>" + pfFollowUp + "</script>")
+ .replace("<head>", "<head><script crossorigin=\"anonymous\" integrity=\"sha512-g4ztuyuFPzjTvIqYBeZdHEDaHz2K6RCz4RszsnL3m5ko4kiWCjB9W6uIScLkNr8l/BtC2dYiIFkOdOLDYBHLqQ==\" type=\"application/javascript\" src=\"https://github.githubassets.com/assets/compat-838cedbb.js\"></script>")
+ .replace("<head>", "<head><script>" + pfBase + "</script>");
if (isSeaMonkey) {
data = data.replace("<head>", "<head><script>" + pfSeaMonkey + "</script>");
}
} else if (this.site == "gitlab") {
data = data.replace("<script", "<script>" + customElements + "</script><script");
} else if (this.site == "gitlabjs") {
+ const path = request.URI.path;
// https://gitlab.com/gitlab-org/gitlab/-/commit/5522a5ffb6a0522e11dd684cce5c5e99ae6c24ce
- data = data.replace("/^&(?<iid>\\d+)$/", "/^&(\\d+)$/").replace(".groups.iid", "[1]");
+ if (/\/1\d\.[0-9a-f]{8}\.chunk\.js$/.test(path))
+ data = data.replace("/^&(?<iid>\\d+)$/", "/^&(\\d+)$/")
+ .replace(".groups.iid", "[1]");
+ /*
// https://gitlab.com/gitlab-org/gitlab-ui/-/commit/d23c341bb8cef5683bf2d49556dabe4008be76cf
// https://gitlab.com/gitlab-org/gitlab-ui/-/commit/f3fcb2ff5a2e74f77b3a96dc8922a3821c86e2fa
// Test URL: https://gitlab.com/ykweyer-test-group/emoji-test
- //data = data.replace("\\p{Emoji}", "[\\u{1f300}-\\u{1f5ff}\\u{1f900}-\\u{1f9ff}\\u{1f600}-\\u{1f64f}\\u{1f680}-\\u{1f6ff}\\u{2600}-\\u{26ff}\\u{2700}-\\u{27bf}\\u{1f1e6}-\\u{1f1ff}\\u{1f191}-\\u{1f251}\\u{1f004}\\u{1f0cf}\\u{1f170}-\\u{1f171}\\u{1f17e}-\\u{1f17f}\\u{1f18e}\\u{3030}\\u{2b50}\\u{2b55}\\u{2934}-\\u{2935}\\u{2b05}-\\u{2b07}\\u{2b1b}-\\u{2b1c}\\u{3297}\\u{3299}\\u{303d}\\u{00a9}\\u{00ae}\\u{2122}\\u{23f3}\\u{24c2}\\u{23e9}-\\u{23ef}\\u{25b6}\\u{23f8}-\\u{23fa}]");
+ if (path.includes("/main."))
+ data = data.replace("\\p{Emoji}", "[\\u{1f300}-\\u{1f5ff}\\u{1f900}-\\u{1f9ff}\\u{1f600}-\\u{1f64f}\\u{1f680}-\\u{1f6ff}\\u{2600}-\\u{26ff}\\u{2700}-\\u{27bf}\\u{1f1e6}-\\u{1f1ff}\\u{1f191}-\\u{1f251}\\u{1f004}\\u{1f0cf}\\u{1f170}-\\u{1f171}\\u{1f17e}-\\u{1f17f}\\u{1f18e}\\u{3030}\\u{2b50}\\u{2b55}\\u{2934}-\\u{2935}\\u{2b05}-\\u{2b07}\\u{2b1b}-\\u{2b1c}\\u{3297}\\u{3299}\\u{303d}\\u{00a9}\\u{00ae}\\u{2122}\\u{23f3}\\u{24c2}\\u{23e9}-\\u{23ef}\\u{25b6}\\u{23f8}-\\u{23fa}]");
+ */
// https://gitlab.com/gitlab-org/gitlab/-/merge_requests/79161
// https://gitlab.com/gitlab-org/gitlab/-/commit/87a9ae81bbedd12029edc1f2adcbb4f97e6aaedc
// https://gitlab.com/gitlab-org/gitlab/-/commit/775a98516a5c4f35d7320ed1be2dc442937e367b
// https://gitlab.com/gitlab-org/gitlab/-/commit/c1e52059b3e4581250f80643f925f1b353555dfe
- data = data.replace("/^(?<indent>\\s*)(?<leader>((?<isUl>[*+-])|(?<isOl>\\d+\\.))( \\[([xX ])\\])?\\s)(?<content>.)?/", "/^(\\s*)(([*+-]|(\\d+\\.))( \\[[xX ]\\])?\\s)(.)?/").replace("/^(?<indent>\\s*)(?<leader>((?<isUl>[*+-])|(?<isOl>\\d+\\.))( \\[([xX\\s])\\])?\\s)(?<content>.)?/", "/^(\\s*)(([*+-]|(\\d+\\.))( \\[[xX\\s]\\])?\\s)(.)?/").replace(/\{leader:.,indent:.,content:.,isOl:.\}=(.)\.groups(?=;)/, "$&={indent:$1[1],leader:$1[2],isOl:$1[4],content:$1[6]}").replace(/(\{indent:.,isOl:.\}=).+?(.)\.groups.+?(?=:\{\},)/, "$1$2?{indent:$2[1],isOl:$2[4]}");
+ if (path.includes("/commons-pages.admin.topics.edit-pages.admin.topics.new-pages.groups."))
+ data = replace1(data, [
+ "/^(?<indent>\\s*)(?<leader>((?<isUl>[*+-])|(?<isOl>\\d+\\.))( \\[([xX\\s])\\])?\\s)(?<content>.)?/",
+ "/^(?<indent>\\s*)(?<leader>((?<isUl>[*+-])|(?<isOl>\\d+\\.))( \\[([xX ])\\])?\\s)(?<content>.)?/",
+ "/^(?<indent>\\s*)(?<leader>((?<isUl>[*+-])|(?<isOl>\\d+\\.))( \\[([x ])\\])?\\s)(?<content>.)?/",
+ "/^(?<indent>\\s*)(?<leader>((?<isOl>[*+-])|(?<isUl>\\d+\\.))( \\[([x ])\\])?\\s)(?<content>.)?/"
+ ], "/^(\\s*)(([*+-]|(\\d+\\.))( \\[[xX\\s]\\])?\\s)(.)?/")
+ .replace(/\{leader:[^}]+\}=(.)\.groups(?=;)/, "$&={indent:$1[1],leader:$1[2],isOl:$1[4],content:$1[6]}")
+ .replace(/(\{indent:.,isOl:.\}=).+?(.)\.groups.+?(?=:\{\},)/, "$1$2?{indent:$2[1],isOl:$2[4]}");
}
} catch (e) {}
let storageStream = Cc["@mozilla.org/storagestream;1"].createInstance(Ci["nsIStorageStream"]);
diff --git a/install.rdf b/install.rdf
index f566f61..e27ff5a 100644
--- a/install.rdf
+++ b/install.rdf
@@ -2,7 +2,7 @@
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>github-wc-polyfill@Off.JustOff</em:id>
- <em:version>1.2.18.1</em:version>
+ <em:version>1.2.18.2</em:version>
<em:type>2</em:type>
<em:bootstrap>true</em:bootstrap>
<em:strictCompatibility>true</em:strictCompatibility>
@@ -17,7 +17,7 @@
<Description>
<em:id>{8de7fcbb-c55c-4fbe-bfc5-fc555c87dbc4}</em:id>
<em:minVersion>28.14.0</em:minVersion>
- <em:maxVersion>29.*</em:maxVersion>
+ <em:maxVersion>30.*</em:maxVersion>
</Description>
</em:targetApplication>
<em:targetApplication>