ajax log gm

ajax log library for GM usage

Αυτός ο κώδικας δεν πρέπει να εγκατασταθεί άμεσα. Είναι μια βιβλιοθήκη για άλλους κώδικες που περιλαμβάνεται μέσω της οδηγίας meta // @require https://update.greasyfork.org/scripts/39411/258015/ajax%20log%20gm.js

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το 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        ajax log gm
// @namespace   https://greasyfork.org/users/174399
// @description ajax log library for GM usage
// @version     0.5.1
// ==/UserScript==

window.GM_xmlhttpRequest = window.GM_xmlhttpRequest || function(){
	alert("Error: your script doesn't include GM_xmlhttpRequest API!\r\n" +
	"In order to script works you should include GM_xmlhttpRequest");
};
(function(){
	var _ajaxLog = {},
		inited = null,
		scriptName = 'ajax log',
		scriptVersion = '0.5.1',
		url = "https://greasyfork.org/scripts/39403-ajax-log/code/ajax%20log.js?version=258004",
		link;
	Object.defineProperties( _ajaxLog, {
		'name': {
			get(){return scriptName;},
			enumerable: true,
		},
		'version': {
			get(){return scriptVersion;},
			enumerable: true,
		},
		'nameVer': {
			get(){return scriptName + ' v' + scriptVersion;},
			enumerable: true,
		},
		'start': {
			value: function(){
				if( !inited )
					startLog();
				inited = true;
			},
			enumerable: true,
		},
	});
	function startLog()
	{
		console.log('document.readyState: ', document.readyState );
		var handleDOMLoad = function handleDOMLoad(){
			startLog();
			this.removeEventListener('DOMContentLoaded', handleDOMLoad);
		};
		switch(document.readyState)
		{
			case 'loading': return document.addEventListener('DOMContentLoaded', handleDOMLoad);
			case 'interactive':
			case 'complete':
			break;
			default: return;
		}
		console.log(_ajaxLog.nameVer + ' start');
		var s = new Promise(function(f){
			GM_xmlhttpRequest({
				url: getLocation(url),
				method: 'GET',
				headers: {'Referer': getLocation(url, 'origin')},
				onload: function(r){f(r.response);},
			});
		}).then(function(r){
			var script = document.createElement('script'),
				body = document.body || document.querySelector('body');
			script.type = 'text/javascript';
			script.innerHTML = r;
			body.appendChild(script);
			setTimeout(function(){body.removeChild(script);}, 1e4);
		});
	}
	Object.defineProperty(window, 'ajaxLog', {
		get(){return _ajaxLog;},
		enumerable: true,
	});
	function getLocation(u, p)
	{
		link = link || document.createElement('a');
		link.href = u;
		return link[p||'href'];
	}
})();