Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// in Trydactil bind <C-X> js fetch('
// note that as a 1-liner ; are mandatory.
const month = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ][new Date().getMonth()];
const year = new Date().getFullYear();
const url = `https://fabien.benetou.fr/PersonalInformationStream/WithoutNotes${month}${year}`;
fetch(url+'?action=source') .then( response => { return response.text() } ) .then( data => {
var writeURL = url + '?action=edit';
var selection = window.getSelection().toString();
var content = "post=1&author=PIM_Trydactil&authpw=edit_password&text="+data+'%0a* '
+ window.location.href.replace(/\?utm_source.*/,'');
if (selection) content += '%0a** ' + selection;
fetch(writeURL, { method: 'POST', headers: {'Content-Type':'application/x-www-form-urlencoded'}, body: content })
.then(res => res).then(res => {
var div = document.createElement("div");
div.innerText = "Status adding URL to PIM : " + res.status;
div.onclick = _ => window.open(url);
div.style = "position:absolute; top:100px; left:100px; z-index:999; color:red; background-color:yellow;";
document.body.appendChild( div ); setTimeout( _ => div.style.display = "none", 2000);
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment