Show current URL

Show the current URL in an alert

目前为 2024-09-12 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Show current URL
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Show the current URL in an alert
  6. // @author You
  7. // @match *://*/*
  8. // @license MIT
  9. // ==/UserScript==
  10.  
  11. var button = document.createElement("button");
  12. button.textContent = "Show current URL";
  13. button.onclick = function() {
  14. var currentUrl = window.location.href;
  15. alert(currentUrl);
  16. };
  17.  
  18. var buttonContainer = document.createElement('div');
  19. buttonContainer.style.position = 'fixed';
  20. buttonContainer.style.top = '10px';
  21. buttonContainer.style.right = '10px';
  22. buttonContainer.style.zIndex = '9999';
  23. buttonContainer.appendChild(button);
  24. document.body.appendChild(buttonContainer);