Advertisement
Game_Logic

Draggable Alert Executor Program

Oct 27th, 2020 (edited)
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. document.body.outerHTML = '<div id="mydiv" style="position: absolute;"><div style="background: blue; width: 500px; height: 25px; top: 11px; left: 9px;"><a style="color:white">⠀⠀⠀⠀⠀Website Alerter v2.11</a>⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀<a onclick="closeAlert()" style="color:red">[X]</a></div><div style="background-color: lightgray;border-color: black;width: 500px;height: 20px";>⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀<button onclick="setAlertMod()">Set Alert Text</button><button onclick="modmenualert()">Execute!</button></div></div>'+document.body.outerHTML;
  2. // Make the DIV element draggable:
  3. dragElement(document.getElementById("mydiv"));
  4.  
  5. function dragElement(elmnt) {
  6. var pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
  7. if (document.getElementById(elmnt.id + "header")) {
  8. // if present, the header is where you move the DIV from:
  9. document.getElementById(elmnt.id + "header").onmousedown = dragMouseDown;
  10. } else {
  11. // otherwise, move the DIV from anywhere inside the DIV:
  12. elmnt.onmousedown = dragMouseDown;
  13. }
  14.  
  15. function dragMouseDown(e) {
  16. e = e || window.event;
  17. e.preventDefault();
  18. // get the mouse cursor position at startup:
  19. pos3 = e.clientX;
  20. pos4 = e.clientY;
  21. document.onmouseup = closeDragElement;
  22. // call a function whenever the cursor moves:
  23. document.onmousemove = elementDrag;
  24. }
  25.  
  26. function elementDrag(e) {
  27. e = e || window.event;
  28. e.preventDefault();
  29. // calculate the new cursor position:
  30. pos1 = pos3 - e.clientX;
  31. pos2 = pos4 - e.clientY;
  32. pos3 = e.clientX;
  33. pos4 = e.clientY;
  34. // set the element's new position:
  35. elmnt.style.top = (elmnt.offsetTop - pos2) + "px";
  36. elmnt.style.left = (elmnt.offsetLeft - pos1) + "px";
  37. }
  38.  
  39. function closeDragElement() {
  40. // stop moving when mouse button is released:
  41. document.onmouseup = null;
  42. document.onmousemove = null;
  43. }
  44. }; function modmenualert() { confirm(alertModPrompt); };
  45. function closeAlert() { document.getElementById("mydiv").outerHTML = ""; };
  46. function setAlertMod() { var glizzyX = prompt("What do you want the alert to say?"); alertModPrompt = glizzyX; };
  47. var alertModPrompt = "error";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement