check GD (works with greasemonkey for firefox)

is newgrounds song allowed in geometry dash?

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name        check GD (works with greasemonkey for firefox)
// @namespace   https://gdccdated.glitch.me/
// @description is newgrounds song allowed in geometry dash?
// @author      BZZZZ
// @license     GPLv3
// @include     /^https?\:\/\/www\.newgrounds\.com\/audio\/listen\/[0-9]+\/?(?:[?#]|$)/
// @version     0.1
// @grant       GM.xmlHttpRequest
// @run-at      document-end
// @inject-into content
// ==/UserScript==

'use strict'
try{
	const reqobj={
		'data':`songID=${/^https?\:\/\/www\.newgrounds\.com\/audio\/listen\/([0-9]+)\/?(?:[?#]|$)/.exec(location.href)[1]}&secret=Wmfd2893gb7`,
		'url':'http://www.boomlings.com/database/getGJSongInfo.php',
		'headers':{
			'Content-Type':'application/x-www-form-urlencoded',
			'Origin':'',
			'User-Agent':''
		},
		'responseType':'text',
		'method':'POST',
		'onreadystatechange':r=>{
			if(r.readyState!==4)return
			btn.disabled=false
			btn.style.cursor='pointer'
			if(r.status===200){
				if(r.responseText.includes('|'))btn.value='\u2611 allowed in GD'
				else btn.value='\u2612 not allowed in GD'
			}else btn.value=`\u2370 HTTP error ${r.status} ${r.statusText}`
		}
	}
	const btn=document.createElementNS('http://www.w3.org/1999/xhtml','input')
	btn.type='button'
	btn.value='check GD'
	btn.style.fontSize='18px'
	btn.style.padding='0'
	btn.style.cursor='pointer'
	btn.addEventListener('click',()=>{
		try{
			GM.xmlHttpRequest(reqobj)
		}catch(error){
			console.error('check GD:',error)
			btn.value='\u2370 JS error (see console)'
			return
		}
		btn.style.cursor='wait'
		btn.disabled=true
		btn.value='loading'
	},{'passive':true})
	const span=document.createElementNS('http://www.w3.org/1999/xhtml','span')
	span.attachShadow({'mode':'closed'}).appendChild(btn)
	document.querySelector('.pod-head').appendChild(span)
}catch(error){
	console.error('check GD:',error)
}