Non-popup dialogs for gcup

Opens profile information (and a few other) pages on gcup.ru as new tabs instead of popups.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name        Non-popup dialogs for gcup
// @description Opens profile information (and a few other) pages on gcup.ru as new tabs instead of popups.
// @description:ru Открывает информацию о профиле (и несколько других страниц) на gcup.ru как новые вкладки, а не всплывающие окна.
// @namespace   http://yal.cc
// @include     http://gcup.ru/*
// @version     1
// @grant       none
// ==/UserScript==
var list = document.getElementsByTagName("a");
var rxWindowOpen = /window\.open\('([^']+)'[^)]+\);return false;/;
for (var i = 0; i < list.length; i++) {
	var a = list[i];
	if (a.href == "javascript://") { // handled via JS
		var js = a.getAttribute("onclick"), m;
		if (js.indexOf("window.open") == 0) { // starts with `window.open`
			m = rxWindowOpen.exec(js);
			if (m != null) { // matches the `window.open('...'); return false;`
				a.href = m[1]; // set href to `...`
				a.target = "_blank"; // open in new tab
				a.removeAttribute("onclick"); // onclick no longer needed.
			}
		}
	}
}