-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinject_js.html
45 lines (39 loc) · 1.54 KB
/
inject_js.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<!DOCTYPE html>
<html>
<head>
<title>Chrome Inject Javascript Extension</title>
</head>
<body>
<div>
<label>
<p>Inject Javascript:</p>
<textarea id="inject_js" style="width: 90%; height: 200px">
(function () {
if(top != window) // skip all iframe/frameset
return;
// if(location.host.match(/grepmusic\.com/i)) { // for a certain host
// alert(location.href);
// // append javascript file: function append_javascript (src, onload) { /* code implemented by the extension */ }
// append_javascript('http://code.jquery.com/jquery-1.11.1.min.js', function () { alert('jquery has been downloaded'); });
// }
// force user to go to ONE page every time
// if(location.href != 'http://www.grepmusic.com/') location.href = 'http://www.grepmusic.com/';
// the following javascript will make chrome scroll to the best answer of stackoverflow.com automatically
if(location.href.match(/^http:\/\/stackoverflow.com\/questions\/\d/i)) {
var span = document.getElementsByClassName('load-accepted-answer-date')[0];
span && span.parentNode.scrollIntoView();
console.log('ok');
}
console.log('Hello bro, greetings from inject_script, enjoy it!')
// you can do anything you want here using javascript
})();
</textarea>
</label>
<div>
<input id="save" value="Save" type="button" />
<span id="save_status" style="display: none; color: #080;">ok</span>
</div>
</div>
<script type="text/javascript" src="inject_js.js"></script>
</body>
</html>