-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
79 additions
and
2 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,2 +0,0 @@ | ||
# auto-jump | ||
自动跳转页面 | ||
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,32 @@ | ||
// 必须设置run_at=document_start才能执行 | ||
document.addEventListener('DOMContentLoaded', function() { | ||
// 注入自定义JS | ||
// injectCustomJs(); | ||
var host = location.host; | ||
if(host === 'link.zhihu.com') { | ||
var button = document.querySelector('.actions > a'); | ||
if(!!button) { | ||
button.click(); | ||
} | ||
} else if (host === 't.cn') { | ||
var button = document.querySelector('.open-url > a'); | ||
if(!!button) { | ||
button.click(); | ||
} | ||
} | ||
}) | ||
|
||
|
||
function injectCustomJs(jsPath) { | ||
jsPath = jsPath || 'js/inject.js'; | ||
var temp = document.createElement('script'); | ||
temp.setAttribute('type', 'text/javascript'); | ||
// 获得的地址类似:chrome-extension://ihcokhadfjfchaeagdoclpnjdiokfakg/js/inject.js | ||
temp.src = chrome.extension.getURL(jsPath); | ||
// temp.onload = function() | ||
// { | ||
// // 放在页面不好看,执行完后移除掉 | ||
// this.parentNode.removeChild(this); | ||
// }; | ||
document.body.appendChild(temp); | ||
} |
Empty file.
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,33 @@ | ||
{ | ||
"manifest_version": 2, | ||
"name": "auto jump", | ||
"version": "1.0", | ||
"description": "这是一个用来自动跳转知乎、微博的页面的插件", | ||
"author": "damonchen(netubu@gmail.com)", | ||
"icons": | ||
{ | ||
"48": "icon.png", | ||
"128": "icon.png" | ||
}, | ||
"browser_action": | ||
{ | ||
"default_icon": "icon.png", | ||
"default_popup": "popup.html" | ||
}, | ||
"permissions": [ | ||
"http://*/*", // 可以通过executeScript或者insertCSS访问的网站 | ||
"https://*/*" // 可以通过executeScript或者insertCSS访问的网站 | ||
], | ||
"content_scripts": | ||
[ | ||
{ | ||
"matches": [ "http://*/*", "https://*/*" ], | ||
"js": ["content-script.js"], | ||
"run_at": "document_start" | ||
} | ||
], | ||
"web_accessible_resources": | ||
[ | ||
"inject.js" | ||
] | ||
} |
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,13 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"/> | ||
<title>自动跳转</title> | ||
</head> | ||
<body style="width:500px;min-height:20px;"> | ||
<p> | ||
支持知乎,微博等的页面的自动跳转 | ||
</p> | ||
<script type="text/javascript" src="js/popup.js"></script> | ||
</body> | ||
</html> |
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 @@ | ||
console.log('你好,我是popup!'); |