Update sample script for Greasemonkey to test multiple links
This commit is contained in:
parent
c03ad9eaff
commit
26aa32b622
46
tests/fixtures/GM_openInTab.user.js
vendored
46
tests/fixtures/GM_openInTab.user.js
vendored
@ -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('<div><img id="use_GM_openInTab" src="http://i.imgur.com/cQkJVZY.png" title="Open All Links">Use GM_openInTab<br/><br/><br/></div>');
|
||||
$('#use_GM_openInTab').click(function()
|
||||
{
|
||||
useGMopenIn();
|
||||
});
|
||||
|
||||
$("div#res.med").prepend('<div><img id="use_windowOpen" src="http://i.imgur.com/cQkJVZY.png" title="Open All Links">Use window.open<br/></div>');
|
||||
$('#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();
|
Loading…
Reference in New Issue
Block a user