Chrome | TamperMonkey script - Open all links in new tab

Viewed 1205

I need to open all the search results of each link new tab automatically. I have tried below script which I have found from here. I am unable to achieve the expected outcome. I am absolute new to scripting and help me fix or guide me through achieve the outcome.

// ==UserScript==
// @name     AutoClicker
// @match        https://www.google.com/*
// @require  https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js
// @grant    GM_openInTab
// ==/UserScript==

var TargetLink = $("a:contains('example')");

if (TargetLink.length)
    GM_openInTab (TargetLink[0].href);

Error 1

Error 1

Error 2

Error 2

1 Answers

I made this script ages ago, tell me if it doesn't work.

// ==UserScript==
// @name         Open All Links in New Tab
// @namespace    http://tampermonkey.net/
// @version      3.5.6
// @author       Firey Chicken
// @match        *
// @match https://*/*
// @match http://*/*
// @match *//*/*
// @grant       GM_addStyle
// @grant        window.close
// @require      http://code.jquery.com/jquery-3.4.1.min.js
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...
})();
var $ = window.jQuery;
$(document).on('click', 'a', function(e){
    e.preventDefault();
    var url = $(this).attr('href');
    window.open(url, '_blank');
});

Related