flocabulary

hello

  1. // ==UserScript==
  2. // @name flocabulary
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description hello
  6. // @match https://www.flocabulary.com/subjects/?sso_success=True&backend=google-oauth2
  7. // @grant none
  8. // @license MIT
  9. // ==/UserScript==
  10.  
  11. const images = [
  12. 'https://th.bing.com/th/id/OIP.uPXrerYRv8zelqHt7mHVnQHaJQ?rs=1&pid=ImgDetMain',
  13. 'https://th.bing.com/th/id/OIP.rNk35A83LujcEE_kh4owHwHaLU?rs=1&pid=ImgDetMain',
  14. 'https://th.bing.com/th/id/OIP.jA4L_Dkca1P4hi6vWJ4JoQHaFm?rs=1&pid=ImgDetMain',
  15. 'https://editors.dexerto.com/wp-content/uploads/2023/09/23/McDonalds-Japanese-Advert.jpg',
  16. 'https://preview.redd.it/who-tf-is-the-designer-of-this-ad-v0-u2ovdsz1qbga1.jpg?width=640&crop=smart&auto=webp&s=b526d748dc2884c2986733a3951b9bc5e8af850b',
  17. 'https://setupad.com/wp-content/uploads/2022/05/Screenshot-2022-05-20-at-10.13.10-1024x501.jpg'
  18. ];
  19.  
  20. function getRandomPosition() {
  21. const x = Math.floor(Math.random() * (window.innerWidth - 200)); // Adjust for width of popup
  22. const y = Math.floor(Math.random() * (window.innerHeight - 100)); // Adjust for height of popup
  23. return { x, y };
  24. }
  25.  
  26. function createPopup() {
  27. const { x, y } = getRandomPosition();
  28. const popup = document.createElement('div');
  29. popup.style.position = 'fixed';
  30. popup.style.top = `${y}px`;
  31. popup.style.left = `${x}px`;
  32. popup.style.border = '1px solid #000';
  33. popup.style.backgroundColor = '#fff';
  34. popup.style.zIndex = '1000';
  35. popup.style.padding = '20px';
  36. popup.style.cursor = 'move';
  37. popup.style.boxSizing = 'border-box';
  38.  
  39. const closeButton = document.createElement('button');
  40. closeButton.innerText = 'X';
  41. closeButton.style.color = 'red';
  42. closeButton.style.border = 'none';
  43. closeButton.style.background = 'none';
  44. closeButton.style.fontSize = '16px';
  45. closeButton.style.position = 'absolute';
  46. closeButton.style.top = '10px';
  47. closeButton.style.right = '10px'; // Position to the right
  48. closeButton.style.cursor = 'pointer';
  49.  
  50. closeButton.onclick = function() {
  51. popup.remove();
  52. createPopup(); // Create a new popup on close
  53. };
  54.  
  55. popup.appendChild(closeButton);
  56. const img = document.createElement('img');
  57. img.src = images[Math.floor(Math.random() * images.length)];
  58. img.alt = "Ad";
  59. img.style.maxWidth = '100%';
  60. img.style.height = 'auto';
  61. popup.appendChild(img);
  62.  
  63. document.body.appendChild(popup);
  64.  
  65. // Drag functionality
  66. let isDragging = false;
  67. let offsetX, offsetY;
  68.  
  69. popup.onmousedown = function(e) {
  70. isDragging = true;
  71. offsetX = e.clientX - popup.getBoundingClientRect().left;
  72. offsetY = e.clientY - popup.getBoundingClientRect().top;
  73. document.body.style.cursor = 'move';
  74. };
  75.  
  76. document.onmouseup = function() {
  77. isDragging = false;
  78. document.body.style.cursor = 'default';
  79. };
  80.  
  81. document.onmousemove = function(e) {
  82. if (isDragging) {
  83. popup.style.left = `${e.clientX - offsetX}px`;
  84. popup.style.top = `${e.clientY - offsetY}px`;
  85. }
  86. };
  87. }
  88.  
  89. // Start the first popup
  90. createPopup();