Greasy Fork is available in English.

GitHub Issue Show Status

A userscript that adds an obvious indicator showing if an issue or pull request is open or closed

2019-01-29 या दिनांकाला. सर्वात नवीन आवृत्ती पाहा.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name        GitHub Issue Show Status
// @version     1.0.5
// @description A userscript that adds an obvious indicator showing if an issue or pull request is open or closed
// @license     MIT
// @author      Rob Garrison
// @namespace   https://github.com/Mottie
// @include     https://github.com/*
// @run-at      document-end
// @grant       GM_addStyle
// @require     https://greasyfork.org/scripts/28721-mutations/code/mutations.js?version=666427
// @icon        https://assets-cdn.github.com/pinned-octocat.svg
// ==/UserScript==
(() => {
	"use strict";

	// classes added to the body in case you want to add extra styling
	// via a userstyle
	const bodyClasses = [
			"github-issue-status-open",
			"github-issue-status-closed",
			"github-issue-status-merged"
		],
		// class names applied to the issue status label
		states = {
			"State--red": "Closed",
			"State--purple": "Merged",
			"State--green": "Open"
		};

	/* Make the sidebar sticky;
	 * support: http://caniuse.com/#search=sticky
	 */
	GM_addStyle(`
		.discussion-sidebar {
			position: sticky;
		}
		.github-issue-show-status {
			width:100%;
			margin-top:5px;
		}
	`);

	function getStatus() {
		const statusElm = $("#partial-discussion-header .gh-header-meta .State"),
			status = statusElm.className.match(/(State--\w+)/);
		return status && status[0] || "";
	}

	function addLabel(status) {
		$("body").classList.remove(...bodyClasses);
		const sidebar = $(".discussion-sidebar");
		let el = $(".github-issue-show-status", sidebar),
			txt = states[status] || "";
		// remove previous indicator, just in case this function is called
		// multiple times
		if (el) {
			el.parentNode.removeChild(el);
		}
		if (status && sidebar) {
			el = document.createElement("div");
			el.className = "github-issue-show-status State " + status;
			el.textContent = txt;
			sidebar.insertBefore(el, sidebar.childNodes[0]);
			$("body").classList.add("github-issue-status-" + txt.toLowerCase());
		}
	}

	function checkPage() {
		if ($("#partial-discussion-header")) {
			const status = getStatus();
			addLabel(status);
		}
	}

	function $(str, el) {
		return (el || document).querySelector(str);
	}

	document.addEventListener("ghmo:container", checkPage);
	// needed in case the issue is closed while the issue is shown in the browser
	document.addEventListener("ghmo:comments", checkPage);
	checkPage();
})();