Javascript 使用bookmarklet注入jQuery不在页面上工作

Javascript 使用bookmarklet注入jQuery不在页面上工作,javascript,jquery,html,Javascript,Jquery,Html,我正在尝试使用此bookmarklet: javascript:void((function(doc){if(typeof jQuery=='undefined'){var script_jQuery=document.createElement('script');script_jQuery.setAttribute('src','https://code.jquery.com/jquery-latest.min.js');document.body.appendChild(script_jQ

我正在尝试使用此bookmarklet:

javascript:void((function(doc){if(typeof jQuery=='undefined'){var script_jQuery=document.createElement('script');script_jQuery.setAttribute('src','https://code.jquery.com/jquery-latest.min.js');document.body.appendChild(script_jQuery);console.log('jQuery included ^_^');}else{console.log('jQuery already included ...');}})(document));
要将jQuery插入此页面,请执行以下操作:

https://cn.bing.com/dict/?mkt=zh-cn&q=test
我打开页面,然后打开开发者控制台(我正在使用Chrome),切换到网络选项卡,然后单击书签,我注意到Chrome没有请求,而是请求了以下url:

https://cn.bing.com/fd/ls/l?IG=EE977A4E38924F57B34A1371C04323C1&Type=Event.ClientInst&DATA=[{%22T%22:%22CI.AntiMalware%22,%22FID%22:%22CI%22,%22Name%22:%22AC%22,%22Text%22:%22S%3Ahttps%3A//code.jquery.com/jquery-latest.min.js%22}]

有人知道为什么bookmarklet在这个页面上不起作用吗?此页面如何重定向请求

该特定站点已安装monkeypatch
appendChild
,如果您运行

document.body.appendChild.toString()
进入控制台:它给你

function(n){return t(n,"AC")?u.apply(this,arguments):null}
而不是
[native code]
,这意味着本机函数已被覆盖

请注意,已修补的原型对象是
元素。原型
,但
appendChild
本机存在于
节点上。原型
,它保持未修补状态:

Node.prototype.appendChild.toString()
// gives function appendChild() { [native code] }
您可以
。调用
未打补丁的
appendChild

(function(doc) {
  if (typeof jQuery == 'undefined') {
    var script_jQuery = document.createElement('script');
    script_jQuery.setAttribute('src', 'https://code.jquery.com/jquery-latest.min.js');
    Node.prototype.appendChild.call(
      document.body,
      script_jQuery
    );
    console.log('jQuery included ^_^');
  } else {
    console.log('jQuery already included ...');
  }
})(document)
然后它将被成功附加。(
typeofjquery
将计算为
函数
,而不是
未定义
,您可以看到从网络选项卡请求了正确的URL)



如果站点正确地修补了它,并使对
节点.prototype.appendChild
的所有引用都不可访问,那么唯一的解决方案就是在页面的Javascript运行之前运行自己的Javascript,这可以使用用户脚本管理器来完成,比如,
@run at document start
,在被覆盖之前,使用即时脚本注入保存对
节点.prototype.appendChild的引用。

这看起来是一个非常完整的评估和解决方案,非常奇怪。当一个问题的答案得分为正或被接受(或两者都被接受)时,这个问题就从我的答案栏中消失了,对吗?我想是的,但它没有接受答案,我在结果列表中也看到了其他“已回答”的问题(尽管这些问题不是被高估的问题)我点击了第一页上的每个问题,没有一个答案的分数大于0,所以这可能是因为答案分数