はここで、任意のnをつかむ完全なGreasemonkeyのスクリプトですちょうど記述からランダムに単語のアンバー、そして少し良く、Googleの検索ページのさまざまなハンドル(彼らはページを取得した方法に応じて、少しDOMを変更する。)
// ==UserScript==
// @name _RandomWord from results
// @include http://www.google.com/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js
// ==/UserScript==
function GrabRandomWords() {
/*--- Google search results are wrapped in a list with the id "rso".
Here, we want just the descriptions in the results, so we know
that title and link tag tags can be excluded.
(Alas, Google's search results pages vary quite a bit in the
detailed structure of their HTML.)
*/
var descriptText = $("#rso li *:not(a,h1,h2,h3)").text();
//--- Split into words. Change the "{1,}", if short words like "a" are to be excluded.
var words = descriptText.match (/\b(\w{1,})\b/g);
//--- Pick 5 random words and store them in an array.
if (words) {
var ourRandWords = [];
for (var J = 0; J < 5; ++J)
ourRandWords.push (words[ Math.floor (words.length * Math.random()) ]);
alert (ourRandWords);
}
}
//--- We must wait until page has fully loaded, because the results are usually Ajaxed in.
window.addEventListener ("load",
function() {
/*--- Page is "loaded", but results are still not in, still need a short delay.
Note that listening for DOMSubtreeModified doesn't seem to work well.
*/
setTimeout (function() { GrabRandomWords(); }, 666);
},
false
);
そして、あなたは言葉だけがしたいです表示されたページから来て、HTMLコードから何も来ませんか? – Jonathon
はい、好ましくは結果の説明からのみです。助けてくれてありがとう! – loopx