我正在编写一个小用户来从服务器获取一些内容并将其添加到平局中
该网站有jQuery,我怎么才能使用网站的jQuery而不是@require
(因为Chrome现在不支持这个)?
答案 0 :(得分:4)
使用 现有的 jQuery副本,代码如下:
function main () {
/*--- Put all of your code here.
Use jquery with $ or however the target page uses it.
*/
}
function addJS_Node (text, s_URL, funcToRun) {
var D = document;
var scriptNode = D.createElement ('script');
scriptNode.type = "text/javascript";
if (text) scriptNode.textContent = text;
if (s_URL) scriptNode.src = s_URL;
if (funcToRun) scriptNode.textContent = '(' + funcToRun.toString() + ')()';
var targ = D.getElementsByTagName ('head')[0] || D.body || D.documentElement;
targ.appendChild (scriptNode);
}
addJS_Node (null, null, main);