Changed content type sent to server #2

This commit is contained in:
MrFry 2020-03-25 22:07:14 +01:00
parent ac127afb99
commit a524d9cdf5

View file

@ -21,7 +21,7 @@
// ==UserScript==
// @name Moodle/Elearning/KMOOC test help
// @version 2.0.0.4
// @version 2.0.0.5
// @description Online Moodle/Elearning/KMOOC test help
// @author MrFry
// @match https://elearning.uni-obuda.hu/main/*
@ -58,8 +58,9 @@
var addEventListener // add event listener function
const serverAdress = 'https://qmining.frylabs.net/'
const apiAdress = 'https://api.frylabs.net/'
// const serverAdress = 'http://localhost:8080/'
const apiAdress = 'https://api.frylabs.net/'
// const apiAdress = 'http://localhost:8080/'
const ircAddress = 'https://kiwiirc.com/nextclient/irc.sub.fm/#qmining'
// forcing pages for testing. unless you test, do not set these to true!
@ -978,7 +979,7 @@
sentData.id = GetId()
sentData.quiz = quiz
console.log('SENT DATA', sentData)
SendXHRMessage('datatoadd=' + JSON.stringify(sentData)).then((res) => {
SendXHRMessage(JSON.stringify(sentData)).then((res) => {
next(res.success, sentData, res.newQuestions)
})
} catch (e) {
@ -1574,10 +1575,15 @@
}
function GetXHRInfos () {
const url = apiAdress +
'infos?version=true&motd=true&subjinfo=true&cversion=' +
info().script.version +
'&cid=' + GetId()
return new Promise((resolve, reject) => {
xmlhttpRequest({
method: 'GET',
url: apiAdress + 'infos?version=true&motd=true&subjinfo=true&cversion=' + info().script.version,
url: url,
onload: function (response) {
try {
const res = JSON.parse(response.responseText)
@ -1607,7 +1613,9 @@
}
params.push(key + '=' + encodeURIComponent(val))
})
url += params.join('&')
url += params.join('&') +
'&cversion=' + info().script.version +
'&cid=' + GetId()
xmlhttpRequest({
method: 'GET',
@ -1651,7 +1659,7 @@
url: url,
data: message,
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
'Content-Type': 'application/json'
},
onerror: function (e) {
Log('Data send error', e)