Skip to content
This repository has been archived by the owner on Sep 10, 2023. It is now read-only.

Commit

Permalink
fix: 更精准的重定向去除. close #49
Browse files Browse the repository at this point in the history
  • Loading branch information
axetroy committed Apr 10, 2019
1 parent 0b93f81 commit 0d0bb46
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 17 deletions.
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -5,6 +5,7 @@
"main": "./dist/anti-redirect.user.js",
"scripts": {
"test": "npm run build",
"build:dev": "cross-env NODE_ENV=development webpack --display-error-details --progress --colors",
"build": "cross-env NODE_ENV=production webpack --display-error-details --progress --colors",
"watch": "cross-env NODE_ENV=development webpack --display-error-details --progress --colors --watch",
"changelog": "npx conventional-changelog-cli -p angular -i CHANGELOG.md -s -r 0",
Expand Down
4 changes: 2 additions & 2 deletions src/sites/google.docs.ts
@@ -1,9 +1,9 @@
import { IProvider } from "../provider";
import { matchLinkFromUrl, antiRedirect } from "../utils";
import { antiRedirect } from "../utils";

export class GoogleDocsProvider implements IProvider {
public test = /www\.google\.com\/url\?q=(.*)/;
public resolve(aElement: HTMLAnchorElement) {
antiRedirect(aElement, matchLinkFromUrl(aElement, this.test));
antiRedirect(aElement, new URL(aElement.href).searchParams.get("q"));
}
}
2 changes: 1 addition & 1 deletion src/sites/google.play.ts
Expand Up @@ -3,6 +3,6 @@ import { antiRedirect, matchLinkFromUrl } from "../utils";
export class GooglePlayProvider implements IProvider {
public test = /google\.com\/url\?q=(.*)/;
public resolve(aElement: HTMLAnchorElement) {
antiRedirect(aElement, matchLinkFromUrl(aElement, this.test));
antiRedirect(aElement, new URL(aElement.href).searchParams.get("q"));
}
}
4 changes: 2 additions & 2 deletions src/sites/jianshu.ts
@@ -1,9 +1,9 @@
import { IProvider } from "../provider";
import { matchLinkFromUrl, antiRedirect } from "../utils";
import { antiRedirect } from "../utils";

export class JianShuProvider implements IProvider {
public test = /link\.jianshu\.com\/\?t=(.*)/;
public resolve(aElement: HTMLAnchorElement) {
antiRedirect(aElement, matchLinkFromUrl(aElement, this.test));
antiRedirect(aElement, new URL(aElement.href).searchParams.get("t"));
}
}
4 changes: 2 additions & 2 deletions src/sites/juejin.ts
@@ -1,9 +1,9 @@
import { IProvider } from "../provider";
import { matchLinkFromUrl, antiRedirect } from "../utils";
import { antiRedirect } from "../utils";

export class JuejinProvider implements IProvider {
public test = /link\.juejin\.im\/\?target=(.*)/;
public resolve(aElement: HTMLAnchorElement) {
antiRedirect(aElement, matchLinkFromUrl(aElement, this.test));
antiRedirect(aElement, new URL(aElement.href).searchParams.get("target"));
}
}
4 changes: 2 additions & 2 deletions src/sites/pocket.ts
@@ -1,9 +1,9 @@
import { IProvider } from "../provider";
import { matchLinkFromUrl, antiRedirect } from "../utils";
import { antiRedirect } from "../utils";

export class PocketProvider implements IProvider {
public test = /getpocket\.com\/redirect\?url=(.*)/;
public resolve(aElement: HTMLAnchorElement) {
antiRedirect(aElement, matchLinkFromUrl(aElement, this.test));
antiRedirect(aElement, new URL(aElement.href).searchParams.get("url"));
}
}
4 changes: 2 additions & 2 deletions src/sites/so.ts
@@ -1,10 +1,10 @@
import { IProvider } from "../provider";
import { matchLinkFromUrl, antiRedirect } from "../utils";
import { antiRedirect } from "../utils";

export class SoProvider implements IProvider {
public test = /so\.com\/link\?url=(.*)/;
public resolve(aElement: HTMLAnchorElement) {
antiRedirect(aElement, matchLinkFromUrl(aElement, this.test));
antiRedirect(aElement, new URL(aElement.href).searchParams.get("url"));

const dataUrl: string = aElement.getAttribute("data-url");
if (dataUrl) {
Expand Down
4 changes: 2 additions & 2 deletions src/sites/zhihu.daily.ts
@@ -1,9 +1,9 @@
import { IProvider } from "../provider";
import { matchLinkFromUrl, antiRedirect } from "../utils";
import { antiRedirect } from "../utils";

export class ZhihuDailyProvider implements IProvider {
public test = /zhihu\.com\/\?target=(.*)/;
public resolve(aElement: HTMLAnchorElement) {
antiRedirect(aElement, matchLinkFromUrl(aElement, this.test));
antiRedirect(aElement, new URL(aElement.href).searchParams.get("target"));
}
}
4 changes: 2 additions & 2 deletions src/sites/zhihu.ts
@@ -1,9 +1,9 @@
import { IProvider } from "../provider";
import { matchLinkFromUrl, antiRedirect } from "../utils";
import { antiRedirect } from "../utils";

export class ZhihuProvider implements IProvider {
public test = /zhihu\.com\/\?target=(.*)/;
public resolve(aElement: HTMLAnchorElement) {
antiRedirect(aElement, matchLinkFromUrl(aElement, this.test));
antiRedirect(aElement, new URL(aElement.href).searchParams.get("target"));
}
}
4 changes: 2 additions & 2 deletions src/sites/zhihu.zhuanlan.ts
@@ -1,9 +1,9 @@
import { IProvider } from "../provider";
import { matchLinkFromUrl, antiRedirect } from "../utils";
import { antiRedirect } from "../utils";

export class ZhihuZhuanlanProvider implements IProvider {
public test = /link\.zhihu\.com\/\?target=(.*)/;
public resolve(aElement: HTMLAnchorElement) {
antiRedirect(aElement, matchLinkFromUrl(aElement, this.test));
antiRedirect(aElement, new URL(aElement.href).searchParams.get("target"));
}
}

0 comments on commit 0d0bb46

Please sign in to comment.