מעלה הגיפים של ניב

מאפשר להעלות תמונות גיפ לפרופיל בקלות

  1. // ==UserScript==
  2. // @name מעלה הגיפים של ניב
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.3
  5. // @description מאפשר להעלות תמונות גיפ לפרופיל בקלות
  6. // @author Muffin24
  7. // @match https://www.fxp.co.il/member.php*
  8. // @grant none
  9. // ==/UserScript==
  10. function uploadImage(x) {
  11. const body = new FormData();
  12. body.append('fileToUpload', x);
  13. return new Promise(e => fetch("/uploads/difup.php", { method: "POST", body }).then(x => x.json())
  14. .then(x => e(x.image_link.replace("i.imagesup.co", "profile.fcdn.co.il"))));
  15. }
  16.  
  17. function setProfileImage(x) {
  18. let body = new FormData();
  19. body.append("do", "update_profile_pic");
  20. body.append("profile_url", x);
  21. body.append("user_id", USER_ID_FXP);
  22. body.append("securitytoken", SECURITYTOKEN);
  23. return new Promise(e => fetch("/private_chat.php",{ method: "POST", body }).then(x => x.text()).then(x => "ok" == x && e()));
  24. }
  25.  
  26. function openFileDialog() {
  27. const element = document.createElement("input");
  28. element.type = "file";
  29. element.accept = "image/gif";
  30. element.onchange = (x => uploadImage(x.srcElement.files[0]).then(x => setProfileImage(x).then(() => location.reload())));
  31. element.click();
  32. }
  33.  
  34. const profileElement = document.querySelector('[href="profile.php?do=buddylist"]');
  35. if (!document.contains(profileElement)){
  36. return;
  37. }
  38. const text = "העלאת גיפ לפרופיל";
  39.  
  40. const img = document.createElement("img");
  41. img.src = "//static.fcdn.co.il/images_new/buttons/edit_40b.png";
  42. img.alt = text
  43. img.title = text
  44. img.className = "inlineimg initial loading";
  45.  
  46. const a = document.createElement("a");
  47. a.href = "javascript:void(0)";
  48. a.onclick = openFileDialog;
  49. a.append(img, text)
  50.  
  51. const li = document.createElement("li");
  52. li.append(a);
  53. document.querySelector("#usermenu").append(li);