油猴子(greasemonkey)初步体验心得
项目需要把微博搜索的东西发送到指定服务器上,我想到了油猴子,现学之,
// ==UserScript==// @name weibo_test2// @namespace http://www.oreilly.com/catalog/greasemonkeyhacks/// @description 抓取微博搜素结果的uid// @include http://s.weibo.com/*// @exclude %exclude%// @version 1// ==/UserScript==alert('Hello world! myweibo');function work(){var lst = document.getElementsByClassName("person_name");var len = lst.length;if(len<1){return;}var uid ="";for(var idx=0;idx<len;idx++){var aE = lst[idx].getElementsByTagName("a")[0].getAttribute("uid");uid = uid+aE+",";}//alert("abc"+uid);GM_xmlhttpRequest({ method: "GET", url: "http://localhost/test.php?id="+uid, onload: function(response) {alert(response.responseText); }});}work();