Profilo di agentzhHuman & MachineFotoBlogElenchiAltro ![]() | Guida |
|
30 gennaio 作秀中...最近又写了一篇东西到"雅虎搜索日志",题为"从SearchAll看搜索引擎DNA": http://ysearchblog.cn/2008/01/searchalldna.html 感谢杏岚的编辑工作 :) 我的下一篇东西可能题为"装在口袋里的网站";我一直打算介绍一下我们的基于 OpenAPI 的纯客户端应用的开发技术。 我们的 M,yuting++,已经怪我"染上了作秀不良风气"了,哈哈。我看来是很难改正了,呵呵。tingting 一定要原谅我哦 ;) -agentzh 18 gennaio Re: Intercepting access to a method/propertyOn Jan 18, 2008 7:21 PM, AllSeeingI wrote: > Is it possible (through an extension, XPCOM, other way) to call a > particular JS function when a particular method or property is > accessed by a user script (= script on a HTML page)? > Object.watch is the way to go for properties ;) Not sure about methods though. > The reason I'm asking is that I'm trying to create an extension that > intercepts JavaScript redirections: > > location.href = ... Heh, I'm afraid it's more browser-specific. So it might be OT here. But I'd like to share some of my experiences (mostly from NSA++) in this mail. I think the following code should work in Firefox 2 (i.e. the js 1.7 engine): top.watch("location", function () { throw "Permission denied." }); top.location.watch("href", function () { throw "Permission denied." }); But unfortunately it won't work in Firefox 3 (i.e. the js 1.8 engine). AFAIK, Firefox has been trying much harder than IE to protect frame-busting sites. > location.replace(...); > Well, I was trying very hard to defeat this one but with no luck. A good enough workaround for (static) sites is to (locally) disable JS for that particular frame loading the frame-busting page, as in: myBrowser.docShell.allowJavascript = false; Basically, if you load the web page in a separate chrome window, frame-busting code will always fail. But if you're trying to load it in Firefox's own browser tab, you're not really "chrome" there. Another trick that works is to use the onbeforeunload handler, as in: window.onbeforeunload = function (e) { e.returnValue = "This action might be caused by a frame-busting site.\nPlease click 'Cancel' if you're not meant to quit me."; return false; }; But this will pop up a confirmation dialog to the end user. There's no known way to bypass it without hacks ;) There may exist much better solutions that I don't know. Hope these help. Cheers, -agentzh 09 gennaio Introduction to the Yahoo! REST Base (aka OpenAPI) projectSorry for the lack of posting in the last few weeks. Been mostly focusing on the Yahoo! REST Base project (aka OpenAPI or OpenSearch within the company). The Chinese version of the API spec can be found here: http://svn.openfoundry.org/openapi/trunk/doc/spec.html Sorry, there's no English version yet. But I'll surely work it out ;) We've stolen the spirit of Jifty's REST design and extend it to support a lot of cool features like models, actions, views, roles, minisql, and captchas. Currently the best spec is the test suite though (and the knowledge of the Chinese language is not required ;)): http://svn.openfoundry.org/openapi/trunk/t/ Most of the test cases are declared in the Test::Base syntax, hence the readability. We've already set up a small demo app using our REST service: http://www.yisou.com/opi/post.html Feel free to mud around there ;) It's worth mentioning that the post board app itself is totally static; just a few .js files, 1 .html file, 1 .css file, and 1 image file. It makes heavy use of cross-domain AJAX. So it also runs directly in the subversion repository: http://svn.openfoundry.org/openapi/trunk/demo/YisouComments/post.html The source of the demo app can be found here: http://svn.openfoundry.org/openapi/trunk/demo/YisouComments/ The whole project but the Pg cluster backend is opensourced under GPL. You can always get the latest source from the following subversion repository: http://svn.openfoundry.org/openapi/trunk If you like a commit bit, please let me know. Have fun! 01 gennaio Yahoo! 4e team 贺岁语录:"妈呀,又是测试啊?" -- leiyh "话说……你加的功能 work 了!" -- carrie "这事咋办呢?让我想想。。。" -- ting "每日常坐电脑前,每逢春秋必感冒。锻炼永远计划中,感冒一直在行动。" -- jianingy "谁说我不乖的?我很乖的。" -- ywayne "咦?是 exe 的。。。我来 hack 一下。。。" -- shangerdi "哈哈!央视8套真好看,讲苍蝇飞行的原理 :D" -- laser "锅得刚说了,铛铛铛,铛儿嘀儿嘀个儿铛!" -- arthas "yay! it works! :D" -- agentzh "春儿太猛了!整天写一坨一坨的没用的东西……" -- luoyi |
|
|