Added the same regex as in the faq page in scribe #19

This commit is contained in:
ManeraKai 2022-02-08 19:17:27 +03:00
parent 352c9127a6
commit 343ab3bbc0
2 changed files with 18 additions and 15 deletions

View File

@ -2,18 +2,19 @@ import commonHelper from './common.js'
const targets = [
/^medium\.com/,
/.*\.medium\.com/,
// Other domains of medium blogs, source(s): https://findingtom.com/best-medium-blogs-to-follow/#1-forge
/towardsdatascience\.com/,
/uxdesign\.cc/,
/uxplanet\.org/,
/betterprogramming\.pub/,
/aninjusticemag\.com/,
/betterhumans\.pub/,
/psiloveyou\.xyz/,
/entrepreneurshandbook\.co/,
/blog\.coinbase\.com/
/(?:.*\.)*(?<!(link\.|cdn\-images\-\d+\.))medium\.com(\/.*)?$/,
// /^medium\.com/,
// /.*\.medium\.com/,
// // Other domains of medium blogs, source(s): https://findingtom.com/best-medium-blogs-to-follow/#1-forge
// /towardsdatascience\.com/,
// /uxdesign\.cc/,
// /uxplanet\.org/,
// /betterprogramming\.pub/,
// /aninjusticemag\.com/,
// /betterhumans\.pub/,
// /psiloveyou\.xyz/,
// /entrepreneurshandbook\.co/,
// /blog\.coinbase\.com/
];
let redirects = {
@ -64,11 +65,13 @@ function setDisableMedium(val) {
function redirect(url, initiator) {
function redirect(url, initiator, type) {
if (disableMedium) return null;
if (url.pathname == "/") return null;
if (type != "main_frame" && "sub_frame" && "xmlhttprequest" && "other")
return null;
let instancesList = [...scribeRedirectsChecks, ...scribeCustomRedirects];
if (instancesList.length === 0) return null;
@ -85,7 +88,7 @@ function redirect(url, initiator) {
}
function isMedium(url) {
return targets.some((rx) => rx.test(url.host));
return targets.some((rx) => rx.test(url.href));
}
async function init() {

View File

@ -49,7 +49,7 @@ browser.webRequest.onBeforeRequest.addListener(
else if (redditHelper.isReddit(url)) newUrl = redditHelper.redirect(url, initiator, details.type);
else if (mediumHelper.isMedium(url)) newUrl = mediumHelper.redirect(url, initiator);
else if (mediumHelper.isMedium(url)) newUrl = mediumHelper.redirect(url, initiator, details.type);
else if (translateHelper.isTranslate(url)) newUrl = translateHelper.redirect(url, initiator);