This repository has been archived by the owner on Sep 10, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(new): 新增weibo/twitter的去除跳转,以及重构一些代码
- Loading branch information
axetroy
committed
Nov 17, 2016
1 parent
e60f34f
commit cb07843
Showing
13 changed files
with
631 additions
and
293 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import {Observable} from 'rxjs/Observable'; | ||
import {RedirectOnUrl} from './redirect-on-url'; | ||
|
||
class TwitterRedirect extends RedirectOnUrl { | ||
constructor(domainTester, urlTester, matcher) { | ||
super(domainTester, urlTester, matcher); | ||
} | ||
|
||
handlerOneEle(aEle: HTMLAnchorElement): Observable<any> { | ||
return Observable.of(aEle) | ||
.filter((ele: HTMLAnchorElement)=> { | ||
return this.urlTester.test(ele.href) && /^https?:\/\//.test(ele.title); | ||
}) | ||
.do((aEle: HTMLAnchorElement)=> { | ||
let url: string = decodeURIComponent(aEle.title); | ||
if (url) { | ||
aEle.href = url; | ||
this.DEBUG && (aEle.style.backgroundColor = 'green'); | ||
} | ||
}) | ||
} | ||
|
||
} | ||
|
||
export default new TwitterRedirect( | ||
/twitter\.com/, | ||
/t\.co\/\w+/, | ||
null | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import {Observable} from 'rxjs/Observable'; | ||
import {RedirectOnUrl} from './redirect-on-url'; | ||
|
||
class WeiboRedirect extends RedirectOnUrl { | ||
constructor(domainTester, urlTester, matcher) { | ||
super(domainTester, urlTester, matcher); | ||
} | ||
|
||
handlerOneEle(aEle: HTMLAnchorElement): Observable<any> { | ||
return Observable.of(aEle) | ||
.filter((ele: HTMLAnchorElement)=> { | ||
return this.urlTester.test(ele.href) && /^https?:\/\//.test(ele.title); | ||
}) | ||
.do((aEle: HTMLAnchorElement)=> { | ||
let url: string = decodeURIComponent(aEle.title); | ||
if (url) { | ||
aEle.href = url; | ||
this.DEBUG && (aEle.style.backgroundColor = 'green'); | ||
} | ||
}) | ||
} | ||
|
||
} | ||
|
||
export default new WeiboRedirect( | ||
/weibo\.com/, | ||
/t\.cn\/\w+/, | ||
null | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters