Discussions » Development

Open Multi Links + button

§
Posted: 2021-01-13
hi, i should fix a script that doesn't work for me. I would like to open several sites simultaneously by pressing the "OPEN LINKS" button. The button appears but nothing happens when I click on it. Can you help me understand the problem? thank you so much

// ==UserScript==
// @name Link Opener
// @description Opens links when the button on the top right of each page is clicked.
// @include *
// ==/UserScript==

// Add new links here.
var links = [
'http://www.google.com',
'http://example.com'
];

// Don't touch below here
var e = document.createElement('button');
e.textContent = 'Open Links';
e.setAttribute('style', 'position: fixed !important; top: 0 !important; right: 0 !important;');
e.addEventListener('click', function() {
for (var i = 0; i < links.length; i++) {
GM_openInTab(links[i]);
}
}, false);
document.body.appendChild(e);
§
Posted: 2021-01-13
Edited: 2021-01-13
GM_openInTab is not defined

Fixed version below


// ==UserScript==
// @name Link Opener
// @description Opens links when the button on the top right of each page is clicked.
// @include *
// @grant GM_openInTab
// ==/UserScript==

// Add new links here.
var links = [
'http://www.google.com',
'http://example.com'
];

// Don't touch below here
var e = document.createElement('button');
e.textContent = 'Open Links';
e.setAttribute('style', 'position: fixed !important; top: 0 !important; right: 0 !important;');
e.addEventListener('click', function() {
for (var i = 0; i < links.length; i++) {
GM_openInTab(links[i]);
}
}, false);
document.body.appendChild(e);
§
Posted: 2021-01-16
Edited: 2021-01-16
GM_openInTab is not defined

Fixed version below


// ==UserScript==
// @name Link Opener
// @description Opens links when the button on the top right of each page is clicked.
// @include *
// @grant GM_openInTab
// ==/UserScript==

// Add new links here.
var links = [
'http://www.google.com',
'http://example.com'
];

// Don't touch below here
var e = document.createElement('button');
e.textContent = 'Open Links';
e.setAttribute('style', 'position: fixed !important; top: 0 !important; right: 0 !important;');
e.addEventListener('click', function() {
for (var i = 0; i < links.length; i++) {
GM_openInTab(links[i]);
}
}, false);
document.body.appendChild(e);
thank you a lot but it doesn't work... i'm trying it :( when i click on button, it happens nothing
anyway the two codes look identical, aren't they?
§
Posted: 2021-01-16
Edited: 2021-01-16

the two codes look identical, aren't they

Difference is:

// ==UserScript==
// @grant GM_openInTab
// ==/UserScript==

doesn't work

Works in Chrome with Tampermonkey. What is your setup? What errors in a console?

§
Posted: 2021-01-16
Edited: 2021-01-16
The two codes look identical but they are not identical, I've added 1 single line to the script, as Konf said.

The script works in Opera Browser With Tampermonkey.

Please answer what Konf asked you...
§
Posted: 2021-01-17
thank you for your avaibitliy. I'm using Greasemonkey (Firefox)
§
Posted: 2021-01-17
Edited: 2021-01-17
thank you for your avaibitliy. I'm using Greasemonkey (Firefox)
What errors do you see in the browser dev console?

Install tampermonkey on your firefox and try using the script on tampermonkey.
§
Posted: 2021-01-18
Good morning! So, on greasemonkey there is no error, I just click on the 'open links' button but nothing happens. The click fails, as if the button were empty.

your script works with Tapermonkey, but not with Greasemonkey.
The problem is that on Tapermonkey it doesn't do what I want: my aim is to open a set of websites from the container it is in. With tapermonkey opens all websites but they are 'container-free'. While with Greasemonkey (setting a single website in the script, it works) opens the website perfectly within the same container.
§
Posted: 2021-01-18

What is container?

§
Posted: 2021-01-18
Edited: 2021-01-18
This still doesn't make any sense because we don't know what you want to do.

There are "3 types of storage" on tampermonkey, localstorage, storage in the tampermonkey itself (gmset), no storage at all (var).

Just use one of these, I'm almost sure that they will meet your expectatives and do what you want.

Tampermonkey can (or not) keep your settings (the variables you change) during a private natigation, you could just use a private window to do what you want, and set tampermonkey to keep the changes permanent or not while using a private window in the extension settings. I guess that this is what you want...
§
Posted: 2021-01-19
To solve I would just like to run the script with Greasemonkey. There is not much to understand about the purpose and the modalities.

Post reply

Sign in to post a reply.