/*
* @title call nostalk
* @description nostalkに喋らせる
* @include https://*
* @license CC0 1.0
* @require
*/
(async () => {
const ifghost = 'ノス民,none';
const message = '\\0\_q\オアーッ!!/\\e';
const sspServerURL = 'http://localhost:9801';
const callNostalk = async () => {
const mes = [
'NOTIFY SSTP/1.1',
'Charset: UTF-8',
'Sender: SSTP-bookmarklet',
'SecurityLevel: external',
'Event: OnNostrCallNostalk',
'Option: nobreak',
`IfGhost: ${ifghost}`,
`Script: ${message}`,
'',
''
].join('\n');
const res = await postData(sspServerURL + '/api/sstp/v1', mes);
console.log(mes, '----------\n', res, '----------\n');
};
const postData = async (url = '', data = '') => {
const param = {
method: 'POST',
headers: {
'Content-Type': 'text/plain',
Origin: sspServerURL
},
body: data
};
try {
const response = await fetch(url, param);
return response.text();
} catch (error) {
console.log(error);
return '';
}
};
callNostalk();
})();