Greasy Fork - Script Counter

Add number of scripts on user's profile page

Version vom 18.03.2014. Aktuellste Version

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

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.

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

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.

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

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

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

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

// ==UserScript==
// @id              greasy-fork-script-counter@loucypher
// @name            Greasy Fork - Script Counter
// @namespace       https://github.com/LouCypher/userscripts
// @description     Add number of scripts on user's profile page
// @version         2.1
// @author          LouCypher
// @license         WTFPL
// @screenshot      https://raw.github.com/LouCypher/userscripts/master/greasyfork/script-counter/screenshot.png
// @contributionURL http://loucypher.github.io/userscripts/donate.html?Greasy+Fork+-+Script+Counter
// @homepageURL     https://greasyfork.org/scripts/180
// @supportURL      https://greasyfork.org/scripts/180/feedback
// @resource        CHANGELOG https://raw.github.com/LouCypher/userscripts/master/greasyfork/script-counter/CHANGELOG.txt
// @resource        LICENSE https://raw.github.com/LouCypher/userscripts/master/licenses/WTFPL/LICENSE.txt
// @run-at          document-end
// @include         https://greasyfork.org/users/*
// @grant           none
// ==/UserScript==
/* 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. */



function showError() {
  var pAlert = document.querySelector("p.alert");
  if (pAlert) {  // Display error notification
    pAlert.classList.add("important");
    pAlert.innerHTML = '<a href="/scripts/180">Script Counter</a>'
                     + ' user script detects an error.'
                     + ' Please <a href="/forum/post/discussion?'
                     + 'Discussion/ScriptID=180">notify</a>'
                     + ' the author.';
  }
  else  // Show error in console
    throw new Error("Some thing went wrong.");
}

var scripts;

var scriptList = document.querySelectorAll("#user-script-list > li");
if (scriptList.length)
  scripts = scriptList.length;  // User has script(s)

if (scripts) {  // If user has script(s)
  var username = document.querySelector("h2");
  var title = document.querySelector("body > section:not([id]) h3");
  if (title)  // add number of script(s) in Scripts section
    title.appendChild(document.createTextNode(" (" + scripts + ")"));
  else
    showError(); // Sam ting wen wong
}
// else user didn't post any scripts