Grease Info

Parse markdown info in userjs.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name        Grease Info
// @version     1.1.2
// @namespace   eight04.blogspot.com
// @description Parse markdown info in userjs.
// @include     https://greasyfork.org/scripts/*
// @require     https://code.jquery.com/jquery-1.11.1.min.js
// @require     https://cdnjs.cloudflare.com/ajax/libs/marked/0.3.2/marked.min.js
// @grant       GM_xmlhttpRequest
// ==/UserScript==

/*******************************************************************************
# Grease Info

Experiment implementation!

## Version History
*   Version 1.1.2 (Aug 17, 2014)
	- Add doxygen comment style support.
*	Version 1.1.1 (Aug 16, 2014)
	- Update this history.
*	Version 1.1 (Aug 16, 2014)
	- Add markdown support.
*	Version 1.0 (Aug 16, 2014)
	- First release.
*******************************************************************************/

var url, jsraw, info, parsedInfo;

var draw = function(){
	// console.log(info);
	$("#script-content").append(
		'<div id="additional-info">\
			<h3>Author\'s Description</h3>\
			<div></div>\
		</div>'
	);
	$("#additional-info>div").html(parsedInfo);
};

var parseDoxy = function(source){
	var doxyRE = /^ \*(\t| |$)/, list, i, usingDoxy = true;
	
	list = source.split(/\r?\n/);
	if(list.length > 1){
		for(i = 1; i < list.length; i++){
			if(!doxyRE.test(list[i])){
				usingDoxy = false;
				break;
			}
		}
	}
	if(usingDoxy){
		source = source.split(doxyRE).join("");
	}
	return source;
};

var parse = function(){
	// console.log("parse");
	var RE = /\/\*[* \t]*\r?\n([\u0000-\uffff]+?)\r?\n[* \t]*\*\//m;
	var m = RE.exec(jsraw);
	// console.log(m);
	info = parseDoxy(m[1]);
	// console.log(info);
	parsedInfo = marked(info);
	
	draw();
};

var getJS = function(){
	// console.log(url);
	var success = function(res){
		jsraw = res.responseText;
		parse();
	};
	
	GM_xmlhttpRequest({
		method: "GET",
		onload: success,
		url: url
	});
};

var checkJS = function(){
	// console.log("checkJS");
	if(!$(".install-link").length || $("#additional-info").length){
		return;
	}
	url = $(".install-link").prop("href");
	getJS();
};

// console.log("grease info");

checkJS();