Skip to content

Instantly share code, notes, and snippets.

@Utopiah
Last active January 3, 2022 08:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Utopiah/525718c8a60ee2d9e25d7724e9dbb355 to your computer and use it in GitHub Desktop.
Save Utopiah/525718c8a60ee2d9e25d7724e9dbb355 to your computer and use it in GitHub Desktop.
// 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