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

Commit

Permalink
feat: 支持gmail
Browse files Browse the repository at this point in the history
  • Loading branch information
axetroy committed Apr 28, 2018
1 parent 68b65aa commit 6f21f91
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
8 changes: 7 additions & 1 deletion index.ts
Expand Up @@ -18,6 +18,7 @@ import { JuejinProvider } from "./src/sites/juejin";
import { QQMailProvider } from "./src/sites/qq.mail";
import { MozillaProvider } from "./src/sites/mozilla";
import { JianShuProvider } from "./src/sites/jianshu";
import { GmailProvider } from "./src/sites/gmail";

const app = new App();
const isDebug: boolean = process.env.NODE_ENV !== "production";
Expand All @@ -26,7 +27,7 @@ http.setConfig({ debug: isDebug });

app
.setConfig({
isDebug: isDebug
isDebug
})
.registerProvider([
{
Expand Down Expand Up @@ -58,6 +59,11 @@ app
test: /docs\.google\.com/,
provider: GoogleDocsProvider
},
{
name: "Gmail",
test: /mail\.google\.com/,
provider: GmailProvider
},
{
// 测试地址: https://www.so.com/s?ie=utf-8&fr=none&src=360sou_newhome&q=chrome
name: "360搜索",
Expand Down
14 changes: 14 additions & 0 deletions src/sites/gmail.ts
@@ -0,0 +1,14 @@
import { IProvider } from "../provider";
import { antiRedirect } from "../utils";
export class GmailProvider implements IProvider {
public test = true;
private REDIRECT_PROPERTY = "data-saferedirecturl";
public resolve(aElement: HTMLAnchorElement) {
// 移除这个属性,那么 a 链接就不会跳转
// FIXME: gmail 是多层 iframe 嵌套
if (aElement.getAttribute(this.REDIRECT_PROPERTY)) {
aElement.removeAttribute(this.REDIRECT_PROPERTY);
antiRedirect(aElement, aElement.href);
}
}
}
1 change: 1 addition & 0 deletions webpack.config.ts
Expand Up @@ -55,6 +55,7 @@ const webpackConfig: webpack.Configuration = {
// @include *xueshu.baidu.com*
// @include *www.google.*
// @include *docs.google.*
// @include *mail.google.*
// @include *encrypted.google.com*
// @include *www.so.com*
// @include *www.zhihu.com*
Expand Down

0 comments on commit 6f21f91

Please sign in to comment.