forked from cadey/xesite
Improve domain matching for nag warning, add more reddit domains (#420)
This commit is contained in:
parent
6df97ccc87
commit
0fcaf87b1a
|
@ -2,6 +2,12 @@ import { g, x, r, t } from "./xeact.min.js";
|
||||||
import { div, ahref, br } from "./xeact-html.min.js";
|
import { div, ahref, br } from "./xeact-html.min.js";
|
||||||
import { mkConversation } from "./conversation.js";
|
import { mkConversation } from "./conversation.js";
|
||||||
|
|
||||||
|
// list of regexps for potentially problematic referrers to display the nag to
|
||||||
|
const FLAGGED_REFERRERS = [
|
||||||
|
/^https?:\/\/((.+)\.)?reddit\.com/i,
|
||||||
|
/^https?:\/\/news\.ycombinator\.com/i,
|
||||||
|
];
|
||||||
|
|
||||||
const addNag = () => {
|
const addNag = () => {
|
||||||
let root = g("refererNotice");
|
let root = g("refererNotice");
|
||||||
x(root);
|
x(root);
|
||||||
|
@ -20,19 +26,10 @@ const addNag = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
r(() => {
|
r(() => {
|
||||||
switch (document.referrer) {
|
const ref = document.referrer;
|
||||||
case "https://news.ycombinator.com/":
|
if (!ref) return;
|
||||||
|
|
||||||
|
if (FLAGGED_REFERRERS.some(r => r.test(ref))) {
|
||||||
addNag();
|
addNag();
|
||||||
break;
|
|
||||||
case "https://www.reddit.com/":
|
|
||||||
addNag();
|
|
||||||
break;
|
|
||||||
case "https://old.reddit.com/":
|
|
||||||
addNag();
|
|
||||||
break;
|
|
||||||
case "https://reddit.com/":
|
|
||||||
addNag();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue