-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInject-jQuery.user.js
More file actions
51 lines (47 loc) · 1.41 KB
/
Inject-jQuery.user.js
File metadata and controls
51 lines (47 loc) · 1.41 KB
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
46
47
48
49
50
51
// ==UserScript==
// @name Inject jQuery script
// @namespace Violentmonkey Scripts
// @match *://*.acwing.com/*
// @grant none
// @version 1.0
// @author Hanson Hu
// @description 3/29/2022, 2:20:04 PM
// @homepage https://blog.pythoner.work
// @icon https://blog.pythoner.work/favicon.ico
// @license MIT
// ==/UserScript==
/*
function injectJQuery(callback) {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'https://cdn.jsdelivr.net/npm/jquery@3/dist/jquery.min.js';
if (script.readyState) {
// ie
script.onreadystatechange = function () {
if (script.readyState == 'loaded' || script.readyState == 'complete') {
script.onreadystatechange = null;
callback();
};
}
} else {
script.onload = function () {
callback();
};
};
document.body.appendChild(script);
}
*/
function injectJQuery(callback) {
var script = document.createElement('script');
script.src = 'https://cdn.jsdelivr.net/npm/jquery@3/dist/jquery.min.js';
document.getElementsByTagName('head')[0].appendChild(script);
script.addEventListener('load', function() {
jQuery = unsafeWindow['jQuery'];
jQuery.noConflict();
callback();
}, false);
}
function callback() {
alert('called');
}
injectJQuery(callback);