example

test

Stan na 25-01-2015. Zobacz najnowsza wersja.

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

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

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        example
// @description test
// @namespace   http://mfish.twbbs.org/
// @include     http://jsbin.com/*
// @version     1
// @grant       GM_registerMenuCommand
// ==/UserScript==

var search = location.search
var enabled = false;
var params

function isEnabled () {
  if (search.slice(0,1) != "?") {return false;}
  var temp = search.slice(1);
  temp = temp.split("&")
  
  return temp.indexOf("pluginEnabled") >= 0
}

function rewriteLink () {
  var links = document.querySelectorAll('a');
  var newlink, temp;
  for (var i = 0; i < links.length; i++) {
    var link = links[i];
    //alert(link.href);
    temp = /(https?:\/\/.+)(\?.+)?(#.+)?/.exec(link.href.toString())
    if (temp) {
      //alert(JSON.stringify(temp));
      newlink = temp[1];
      if (!temp[2]) {
        newlink += "?pluginEnabled";
      } else {
        newlink += temp[2] + "&pluginEnabled";
      }
      if (temp[3]) {
        newlink += temp[3];
      }
      link.href = newlink
    }
  }
}

function enable () {
  alert('enabled');
  rewriteLink();
}

if (isEnabled()) {
  enable()
}

GM_registerMenuCommand("Enable", enable);