From 26aa32b622aba4970ee1ebd3b5f2b4efc2f45ab1 Mon Sep 17 00:00:00 2001 From: Piro / YUKI Hiroshi Date: Wed, 3 Jul 2013 00:10:21 +0900 Subject: [PATCH] Update sample script for Greasemonkey to test multiple links --- tests/fixtures/GM_openInTab.user.js | 46 +++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/tests/fixtures/GM_openInTab.user.js b/tests/fixtures/GM_openInTab.user.js index 58ea257e8..db8d28331 100644 --- a/tests/fixtures/GM_openInTab.user.js +++ b/tests/fixtures/GM_openInTab.user.js @@ -1,9 +1,43 @@ // ==UserScript== -// @name Google First Result in New Tab -// @namespace google_firstresult.user.js -// @description Open a new tab for the first search result of Google. -// @include http*://www.google.*/search?q=* -// +// @name test +// @namespace google_GM_openInTab.user.js +// @include http*://www.google.*/search?q=* +// @require http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js +// @run-at document-idle +// see: https://github.com/piroor/treestyletab/issues/517 // ==/UserScript== -GM_openInTab(document.querySelector('h3 a').href); +function init() +{ + $("div#res.med").prepend('
Use GM_openInTab


'); + $('#use_GM_openInTab').click(function() + { + useGMopenIn(); + }); + + $("div#res.med").prepend('
Use window.open
'); + $('#use_windowOpen').click(function() + { + useWinOpen(); + }); +} + +function useGMopenIn() +{ + $('.r a').each(function (i, e) + { + var linkURI = $(e).attr('href'); + GM_openInTab(linkURI, true); + }); return false; +} + +function useWinOpen() +{ + $('.r a').each(function (i, e) + { + var linkURI = $(e).attr('href'); + window.open(linkURI, "_blank"); + }); return false; +} + +init(); \ No newline at end of file