Greasy Fork - More Install button

Add install button on script Code, Versions and Feedback page.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

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.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

/* This program is free software. It comes without any warranty, to
 * the extent permitted by applicable law. You can redistribute it
 * and/or modify it under the terms of the Do What The Fuck You Want
 * To Public License, Version 2, as published by Sam Hocevar. See
 * http://www.wtfpl.net/ for more details. */

// ==UserScript==
// @id              greasy-fork-more-install-button@loucypher
// @name            Greasy Fork - More Install button
// @namespace       https://github.com/LouCypher/userscripts
// @description     Add install button on script Code, Versions and Feedback page.
// @version         2.0
// @author          LouCypher
// @license         WTFPL
// @contributionURL http://loucypher.github.io/userscripts/donate.html?Greasy+Fork+-+More+Install+button
// @homepageURL     https://greasyfork.org/scripts/173
// @supportURL      https://greasyfork.org/scripts/173/feedback
// @resource        CHANGELOG https://raw.github.com/LouCypher/userscripts/master/greasyfork/install-button/CHANGELOG.txt
// @resource        LICENSE https://raw.github.com/LouCypher/userscripts/master/licenses/WTFPL/LICENSE.txt
// @include         https://greasyfork.org/scripts/*/code
// @include         https://greasyfork.org/scripts/*/versions
// @include         https://greasyfork.org/scripts/*/feedback
// @grant           none
// ==/UserScript==

var blocked = /\/scripts\/(94|115|116|117|119|120|121|122|123|172)\//;
var header, title;
header = document.querySelector("#script-info header")
if (header)
  title = header.querySelector("h2");

if (title) {
  /* Get CSRF authenticity token */
  var csrfToken = document.head.children["csrf-token"];
  var authToken = csrfToken ? "?authenticity_token=" +
                              encodeURIComponent(csrfToken.content)
                            : null;

  /* Add Install button */
  var scriptId = location.href.match(/\d+/);
  var span = header.insertBefore(document.createElement("span"), title);
  var link = span.appendChild(document.createElement("a"));
  link.href = "/scripts/" + scriptId + "/code.user.js";
  link.dataset.pingUrl = "/scripts/" + scriptId + "/install-ping"
                       + (authToken ? authToken : "");
  link.textContent = "Install";
  link.className = "install-link";
  link.style.cssFloat = "right";

  if (blocked.test(location.href)) {
    link.href = "/scripts/under-assessment";
    link.style.backgroundColor = "maroon";
    link.addEventListener("click", function(aEvent) {
      aEvent.preventDefault();
      alert("This script is currently under review");
    });
  }
}

else
  throw new Error("Sam Ting Wen Wong!");  // Terminate