Advertisement
NewBestPastebins

Gigachad calculator V2.1

Sep 12th, 2023 (edited)
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.83 KB | None | 0 0
  1. var button = document.createElement("Button");
  2. button.innerHTML = "💪🗿Gigachad Calculator🗿💪";
  3. button.style = "top:80px;left:825px;position:absolute;z-index:99999;padding:15px;margin-top:80px;border:5px solid black;border-radius:16px;font-size:15px;cursor:pointer;";
  4. document.body.appendChild(button);
  5. button.onclick = function(){
  6. var options = ["1. Procent af et givent tal (fx. 20% af 100)", "2. Find originale tal efter en stigning (fx. tallet et 120 efter en stigning på 20%, hvad var det originale tal?)", "3. Hvor meget har jeg sparet? (fx. et produkt koster 80kr, fordi der er et tilbud på 20 procent. Hvor meget sparer jeg, hvis jeg køber produktet?)", "option 4", "option 5", "option 6", "option 7", "option 8", "option 9", "option 10", "option 11", "option 12", "option 13", "option 14", "option 15", "option 16", "option 17", "option 18", "option 19", "option 20"];
  7.  
  8. // Create a string of options separated by newlines
  9. var optionsString = options.join("\n\n");
  10.  
  11. // Show a prompt with the options and ask for a choice
  12. var choice = prompt("Vælg en af de følgende valg muligheder:\n\n" + optionsString);
  13.  
  14. // Convert the choice to a number
  15. var choiceNumber = Number(choice);
  16.  
  17. // Check if the choice is valid
  18. if (choiceNumber >= 1 && choiceNumber <= 20) {
  19. // Execute the code for the chosen option
  20. switch (choiceNumber) {
  21. case 1:
  22. // Ask for a number and a percentage
  23. var number = prompt("Skriv tallet du vil tage en procent af:");
  24. var percentage = prompt("Skriv den procentdel, der skal tages af tallet:");
  25.  
  26. // Calculate the certain percentage of the number
  27. var answer = number * (percentage / 100);
  28.  
  29. // Display the answer in an alert
  30. alert(percentage + "% af " + number + " er: " + answer + ".");
  31.  
  32. break;
  33. case 2:
  34. // Ask for the value of rise in percent and number
  35. var rise = prompt("Skriv stigningen i procent (uden % tegn):");
  36. var number = prompt("Skriv tallet:");
  37.  
  38. // Calculate the original number before the rise
  39. var original = number / (1 + rise / 100);
  40.  
  41. // Display the answer in an alert
  42. alert("Det originale tal er: " + original);
  43.  
  44. break;
  45. case 3:
  46. var currentPrice = prompt("Skriv den nuværende pris på varen:");
  47. var offerPercentage = prompt("Skriv hvor stort tilbudet er i procent (uden % tegn):");
  48.  
  49. // Calculate the original price before the offer
  50. var originalPrice = currentPrice / (1 - offerPercentage / 100);
  51.  
  52. // Calculate the amount of money saved
  53. var moneySaved = originalPrice - currentPrice;
  54.  
  55. // Display the money saved in an alert
  56. alert("Du sparer: " + moneySaved + " på produktet");
  57. break;
  58. // ... and so on for the rest of the options
  59. default:
  60. break;
  61. }
  62. // Show an alert with the chosen option
  63. alert("Du valgte: " + options[choiceNumber - 1]);
  64. } else {
  65. // Show an alert with an invalid choice
  66. alert("Vælg venligst et tal imellem 1 og 20.");
  67. }
  68. };
  69. // Create a search field and a button
  70. var searchField = document.createElement("input");
  71. searchField.type = "text";
  72. searchField.placeholder = "Skriv dit regnestykke her!";
  73.  
  74. // Add some CSS to the search field
  75. searchField.style.border = "2px solid black"; // Give it a black border
  76. searchField.style.borderRadius = "10px"; // Make it have rounded edges
  77. searchField.style.padding = "5px"; // Add some space inside the field
  78.  
  79. var searchButton = document.createElement("button");
  80. searchButton.textContent = "Udregn";
  81. searchButton.onclick = function() {
  82. // Get the value of the search field
  83. var query = searchField.value;
  84. // Replace spaces with "+" to make the query more accurate
  85. query = query.replace(/\s/g, "+");
  86. // Encode the query to prevent special characters from being deleted
  87. query = encodeURIComponent(query);
  88. // Create a Google window inside the current window
  89. var googleWindow = window.open("https://www.google.com/search?q=" + query, "Google", "width=800, height=600");
  90. };
  91.  
  92. // Add some CSS to the button
  93. searchButton.style.border = "2px solid black"; // Give it a black border
  94. searchButton.style.borderRadius = "10px"; // Make it have rounded edges
  95. searchButton.style.padding = "5px"; // Add some space inside the button
  96. searchButton.style.marginLeft = "10px"; // Add some space between the button and the field
  97.  
  98. // Create a div element to wrap the search field and the button
  99. var searchDiv = document.createElement("div");
  100.  
  101. // Add some CSS to the div element
  102. searchDiv.style.position = "fixed"; // Make it fixed on the screen
  103. searchDiv.style.top = "70px"; // Position it 10 pixels from the top
  104. searchDiv.style.right = "675px"; // Position it 10 pixels from the right
  105.  
  106. // Append the search field and the button to the div element
  107. searchDiv.appendChild(searchField);
  108. searchDiv.appendChild(searchButton);
  109.  
  110. // Append the div element to the document body
  111. document.body.appendChild(searchDiv);
  112.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement