grasemonkey ajax页面,Greasemonkey 中使用 GM_xmlhttpRequest 如何在 https 页面中加载 http 资源?...

之前写过一个ff下的gm脚本,功能是在豆瓣读书页面加载图书馆的馆藏信息,但是随着豆瓣全站https,脚本失效,尝试更改,但是仍然无法使用,请大家看看这个问题改如何解决。

目前的代码段

// ==UserScript==

// @name douban_opac

// @include https://book.douban.com/subject/*

// @include https://book.douban.com/isbn/*

// @grant GM_xmlhttpRequest

// ==/UserScript==

$(document).ready(function(){

if ((window.location.href).indexOf("book.douban") > 0 ) {

var title = $('h1').text();

console.log(title);

$("#info .pl").each(function(i){

if ($(this).text() == 'ISBN:'){

var isbn = $(this)[0].nextSibling.nodeValue;

isbn = isbn.substr(1,13);

GM_xmlhttpRequest({ //获取列表

method : "GET",

headers: {"Accept": "application/json"},

url : "http://localhost/getLOC.php?isbn="+isbn+"&title="+title+"&callback=?",

onload : function (response) {

console.log(response.Reponsetext);

}

});

}

});

}

});

加载脚本之后,在浏览器开发工具的console中,查看不到任何log记录。如果是不使用GM_xmlhttpRequest,则在console中有title的记录。

怀疑是因为豆瓣采用了https,而使浏览器无法加载http的资源。不知道是不是这样,请教该如何解决此问题?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值