Last active
July 11, 2020 07:46
-
-
Save oeddyo/63733e70a22c36a6bc681e7e7f8af40b to your computer and use it in GitHub Desktop.
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
功能需求非常简单 | |
我会手动打开github的搜索页面,比如: | |
https://github.com/search?q=location%3Ashanghai | |
此时提供一个按钮让插件做以下操作: | |
在上述的页面,会有一些用户出现。有一些用户有邮件,可以用 xpath 判断。比如: | |
//*[@id="user_search_results"]/div[1]/div[1]/div[2]/div[2]/div[2]/a | |
循环这些用户 | |
如果这个用户有邮件,那么需要打开这个用户的页面。举例,这里我们打开: | |
https://github.com/phodal | |
的页面。 | |
在这个页面上,左侧有:https://www.phodal.com/ 这个链接,xpath为: | |
//*[@id="js-pjax-container"]/div[2]/div/div[1]/div/div[5]/div[2]/ul/li[4]/a | |
那么这里做如下判断:如果这个链接不为空,则在当前 tab 打开这个链接(需要保证我在这个 tab 里,退回时可以回到刚刚的 github页面) | |
那么整个伪代码是 | |
For userRow: searchResults: | |
If hasLink(userRow): | |
openNewTab(userRow.link) | |
If hasWebsiteOnPage: | |
If !websiteLink.startsWith(github.com): | |
OpenLinkInSameTab(websiteLink) | |
Else: continue | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment