百度云插件+APIKey

在百度云网盘的页面添加一个搜索框,调用搜索API搜索所有公开分享文件// To add a search frame that calls some api for searching some public shared files in BaiduYun cloud netdisk.

< Feedback on 百度云插件+APIKey

Review: OK - script works, but has bugs

§
Posted: 2014-06-14

Firefox 下无法得到数据

闲来无事,看了下代码,发现你直接使用了 $.getJSON 来获取 www.googleapis.com 的数据,当时我就觉得奇怪,明显是无法正确得到数据的。

安装脚本尝试了下
1、Firefox 下无法正确显示数据,由于 “已阻止交叉源请求:同源策略不允许读取”。
2、Chrome 下正常,但由于我放大的原因,搜索框无法正确显示,缩放到 100% 才能显示。

文科Mod
§
Posted: 2014-06-14

卡饭论坛报错 - Greasy Forum
貌似和这个一样?
// @grant GM_xmlhttpRequest
greasepig貌似就增加了这个

cinimaAuthor
§
Posted: 2014-06-14

就是说不能直接调用其它网站的内容?那把@grant none 删掉怎样? 必须// @grant GM_xmlhttpRequest吗? PS 学校这边登不上谷歌半个月了,脚本也用不上了。。。你们还能用吗?

§
Posted: 2014-06-14
就是说不能直接调用其它网站的内容?那把@grant none 删掉怎样? 必须// @grant GM_xmlhttpRequest吗? PS 学校这边登不上谷歌半个月了,脚本也用不上了。。。你们还能用吗?

在 firefox 下对跨域的网络获取需要用 GM_xmlhttpRequest。昨天测试 Chrome 下正常。

cinimaAuthor
§
Posted: 2014-06-15

行,那我去改下,之前在mozilla firefox29里正常。关键是上不了www.googleapis.com,不知效果如何。。。╮( ̄▽ ̄)╭

cinimaAuthor
§
Posted: 2014-06-15
卡饭论坛报错 - Greasy Forum
貌似和这个一样?
// @grant GM_xmlhttpRequest
greasepig貌似就增加了这个

好坑,我用GM_xmlhttpRequest,就不能grant none,用不了百度自己的jquery,这样还要引入jquery,然后就冲突了,button绑定的函数没反应了。。。。

§
Posted: 2014-06-15
卡饭论坛报错 - Greasy Forum
貌似和这个一样?
// @grant GM_xmlhttpRequest
greasepig貌似就增加了这个
好坑,我用GM_xmlhttpRequest,就不能grant none,用不了百度自己的jquery,这样还要引入jquery,然后就冲突了,button绑定的函数没反应了。。。。

一般是 @require jquery 好点,当然也可以 unsafeWindow.jQuery 这样引用,但使用 GM 函数的话需要 setTimeout 这样调用,否则会 unsafeWindow can't call GM_xmlhttpRequest 错误。

§
Posted: 2014-06-20
Edited: 2014-06-20

https://blog.mozilla.org/addons/2014/04/10/changes-to-unsafewindow-for-the-add-on-sdk/
please read this to understand this new error due to recent changes in firefox v30

"Greasemonkey access violation: unsafeWindow cannot call GM_xmlhttpRequest"

文科Mod
§
Posted: 2014-06-20
Edited: 2014-06-20

无法@作者? 因为id有空格?

§
Posted: 2014-06-20
Edited: 2014-06-20

im not sure what you mean but this is just information on how firefox handles an unsafewindow, i don't know if this will help you but i thought i would try.

btw im using google translate so i probably don't fully understand what your saying :P

§
Posted: 2014-06-20
im not sure what you mean but this is just information on how firefox handles an unsafewindow, i don't know if this will help you but i thought i would try.

btw im using google translate so i probably don't fully understand what your saying :P

Thanks, I know you mean.

cinimaAuthor
§
Posted: 2014-06-21
https://blog.mozilla.org/addons/2014/04/10/changes-to-unsafewindow-for-the-add-on-sdk/
please read this to understand this new error due to recent changes in firefox v30

"Greasemonkey access violation: unsafeWindow cannot call GM_xmlhttpRequest"

@Sonic0170 Thanks for your review.
I found this userscript has been broken down due to some changes of Baidu cloud netdisk and firefox 30. However , I met some difficulties when I try to inprove codes. So, it might needs some time .╮( ̄▽ ̄)╭

@ywzhaiqi 火狐下调试脚本好难啊,能像chrome一样进入脚本调试模式吗?我想修改,发现错误越改越多。。。。。ps,百度云改版了,脚本失效了。。。。

§
Posted: 2014-06-21
Edited: 2014-06-22
https://blog.mozilla.org/addons/2014/04/10/changes-to-unsafewindow-for-the-add-on-sdk/
please read this to understand this new error due to recent changes in firefox v30

"Greasemonkey access violation: unsafeWindow cannot call GM_xmlhttpRequest"
@Sonic0170 Thanks for your review.
I found this userscript has been broken down due to some changes of Baidu cloud netdisk and firefox 30. However , I met some difficulties when I try to inprove codes. So, it might needs some time .╮( ̄▽ ̄)╭

@ywzhaiqi 火狐下调试脚本好难啊,能像chrome一样进入脚本调试模式吗?我想修改,发现错误越改越多。。。。。ps,百度云改版了,脚本失效了。。。。

我这次又试了下,修正百度盘改版的问题后,未修改脚本任何内容,结果可以显示搜索内容,不知道上次怎么不行。。。。

还需要修正宽度问题。

修正百度盘改版问题

function run() {
	$('#top_menu_other').replaceWith(html_1);//搜索栏替换了广告	
	$('body').append(html_2);
	$('head:first').append(cssText);//插入css

	//应用大小和页面
	$('.wxz-content').height(myDivHeight).width(myDivWidth);
	$('.wxz-myDiv').offset({ top: myDivTop, left: myDivLeft })

	//绑定各种函数
	$(wxz_searchButton).click(function(){frontIndex=0;pageIndex=0;search($(wxz_input).val());});
	$(wxz_closeButton).click(function(){searchClear();});
	$(wxz_nextPageButton).click(function(){if(pageIndex=0){pageIndex=frontIndex;search($(wxz_input).val());}else{alert("It is the top page!");}});
	$(wxz_input).keyup(function(event){if(event.which==13){$(wxz_searchButton).trigger('click');}});
}

window.addEventListener('load', run, false);

我实际上是直接使用 Google 搜索百度盘资源的,在 firefox 中把下面的网址并加入关键字即可搜索。

https://www.google.com.hk/search?newwindow=1&safe=strict&hl=zh-CN&q=site:pan.baidu.com+%s
cinimaAuthor
§
Posted: 2014-06-22

@ywzhaiqi 终于搞定了,谢谢你的思路和方案。

不过,你给代码有些问题, $(wxz_nextPageButton)绑定的函数错了,而且window.addEventListener('load', run, false);在chrome下不起作用,后来我改成window.load=run(); chrome和firefox就都能用了,就是怕又出现一些安全性问题。另外,宽度问题修改好了。


GM_xmlhttpRequest的问题我就不改了,毕竟firefox30下能运行,改起来又太多错误。之前无法显示可能是nightly版的新策略???

已更新。

§
Posted: 2014-06-22
Edited: 2014-06-22
@ywzhaiqi 终于搞定了,谢谢你的思路和方案。

不过,你给代码有些问题, $(wxz_nextPageButton)绑定的函数错了,而且window.addEventListener('load', run, false);在chrome下不起作用,后来我改成window.load=run(); chrome和firefox就都能用了,就是怕又出现一些安全性问题。另外,宽度问题修改好了。


GM_xmlhttpRequest的问题我就不改了,毕竟firefox30下能运行,改起来又太多错误。之前无法显示可能是nightly版的新策略???

已更新。

看来是 Tampermonkey 的 bug,这种方式竟然不是在 load 生效,而是在 DOMContentloaded 生效。

window.addEventListener('load', run, false);

Post reply

Sign in to post a reply.