使用GM_xmlhttpRequest获取油脂猴子中的跨站点内容

时间:2018-06-26 01:24:31

标签: ajax cors greasemonkey gm-xmlhttprequest cross-origin-read-blocking

Load remote URL with Greasemonkey and jQuery

在此示例中,它说,您可以在lubricmonkey中使用GM_xmlhttpRequest获取跨站点内容。但是,当我尝试使用该示例时,我不断收到错误消息,提示“未定义$,未定义GM_XHR()”。我在做什么错了?

// ==UserScript==
    // @name        Google Hello
    // @namespace   John Galt
    // @description Basic Google Hello
    // @match       *://www.google.com/*
    // @version     1
    // @require     https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js
    // @grant       GM_xmlhttpRequest
    // ==/UserScript==

$.ajax({
    url: 'www.google.com',// this even works for cross-domain requests by default
    xhr: function(){ return new GM_XHR(); },
    type: 'POST',
    success: function(val){
        alert("works");
    }
});

也在控制台中,我不断收到此错误:跨域读取阻止(CORB)阻止了MIME类型为text / html的跨域响应https://adservice.google.com/adsid/google/ui。有关更多详细信息,请参见https://www.chromestatus.com/feature/5629709824032768

此外,它不会发出任何警报。

0 个答案:

没有答案