From ea456ed75fe4cbe9c3b655a626d73caaa3e9c398 Mon Sep 17 00:00:00 2001 From: JustOff Date: Mon, 5 Jul 2021 18:47:53 +0300 Subject: Support self-hosted GitLab instances based on Dark-GitLab domain list Tag #25. --- bootstrap.js | 6 +++-- make_glmask.js | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 make_glmask.js diff --git a/bootstrap.js b/bootstrap.js index 2544941..f3f2c90 100644 --- a/bootstrap.js +++ b/bootstrap.js @@ -176,8 +176,10 @@ f.push(d.textContent);return f.join("")},set:function(f){for(;this.firstChild;)u }).call(self);`; const hashCElements = "'sha256-rWWOwtKo7HU91YBF/nwZe2B2qiwVkRbtgbN0jJqfqXs='"; -const githost = new RegExp("^(?:gist\.)?github\.com$|^gitlab\."); -const gitlab = new RegExp("^gitlab\."); +// Known GitLab instances based on https://gitlab.com/vednoc/dark-gitlab/-/blob/master/gitlab.user.css +const glmask = "^gitlab.|^((0xacab|framagit)\.org|code\.(briarproject\.org|foxkit\.us|videolan\.org)|dev\.gajim\.org|forge\.tedomum\.net|git\.(callpipe\.com|cardiff\.ac\.uk|cit\.bcit\.ca|coop|drk\.sc|drupalcode\.org|empiresmod\.com|feneas\.org|fosscommunity\.in|gnu\.io|happy-dev\.fr|immc\.ucl\.ac\.be|jami\.net|ligo\.org|linux-kernel\.at|najer\.info|nzoss\.org\.nz|oeru\.org|pleroma\.social|pwmt\.org|silence\.dev|synz\.io)|gitgud\.io|gitplac\.si|invent\.kde\.org|lab\.libreho\.st|mau\.dev|mpeg\.expert|opencode\.net|repo\.getmonero\.org|salsa\.debian\.org|skylab\.vc\.h-brs\.de|source\.(joinmastodon\.org|puri\.sm|small-tech\.org))$"; +const githost = new RegExp("^(gist\.)?github\.com$|" + glmask); +const gitlab = new RegExp(glmask); var cookie; diff --git a/make_glmask.js b/make_glmask.js new file mode 100644 index 0000000..77e1e56 --- /dev/null +++ b/make_glmask.js @@ -0,0 +1,84 @@ +var doms = [ + '0xacab.org', + 'code.briarproject.org', + 'code.foxkit.us', + 'code.videolan.org', + 'dev.gajim.org', + 'forge.tedomum.net', + 'framagit.org', + 'git.callpipe.com', + 'git.cardiff.ac.uk', + 'git.cit.bcit.ca', + 'git.coop', + 'git.drk.sc', + 'git.drupalcode.org', + 'git.empiresmod.com', + 'git.feneas.org', + 'git.fosscommunity.in', + 'git.gnu.io', + 'git.happy-dev.fr', + 'git.immc.ucl.ac.be', + 'git.jami.net', + 'git.ligo.org', + 'git.linux-kernel.at', + 'git.najer.info', + 'git.nzoss.org.nz', + 'git.oeru.org', + 'git.pleroma.social', + 'git.pwmt.org', + 'git.silence.dev', + 'git.synz.io', + 'gitgud.io', + 'gitplac.si', + 'invent.kde.org', + 'lab.libreho.st', + 'mau.dev', + 'mpeg.expert', + 'opencode.net', + 'repo.getmonero.org', + 'salsa.debian.org', + 'skylab.vc.h-brs.de', + 'source.joinmastodon.org', + 'source.puri.sm', + 'source.small-tech.org' +]; + +doms = doms.sort().filter((el, pos, ary) => !pos || el != ary[pos - 1]); +var tld = doms.filter((el) => el.indexOf(".") == -1); +var tldr = new RegExp("\\.(" + tld.join("|") + ")$"); +doms = doms.filter((el) => el.indexOf(".") > -1 && !tldr.test(el)); +var dn = "", tlds = [], res1 = [], res2 = {}; + +function mkres(dl, drs) { + if (drs.length > 1) { + res1.push(dl + ".(" + drs.join("|") + ")"); + } else { + if (drs[0] in res2) { + res2[drs[0]].push(dl); + } else { + res2[drs[0]] = [dl]; + } + } +} + +for (var dom of doms) { + var dns = dom.split(/(.+?)\.(.+)/).slice(1,3); + if (dn == dns[0]) { + tlds.push(dns[1]); + } else { + dn != "" && mkres(dn, tlds); + dn = dns[0]; tlds = []; tlds.push(dns[1]); + } +} +mkres(dn, tlds); + +for (var r in res2) { + if (res2[r].length > 1) { + res1.push("(" + res2[r].join("|") + ")." + r); + } else { + res1.push(res2[r] + "." + r); + } +} + +res1 = res1.concat(tld).sort(); +console.log('const glmask = "^gitlab\.|^(' + res1.join("|").replace(/\./g,"\\.") + ')$";'); -- cgit v1.2.3