Advertisement
swaggboi

someJs

Nov 1st, 2021
1,379
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  * This bit of JS prints a "you are now logging into:
  3.  * $hostname" blurb on the page and eliminates duplicate login
  4.  * button that sometimes shows up
  5.  */
  6.  
  7. let duplicateLogin, uParam;
  8.  
  9. // Ancient browsers don't support URLSearchParams() method
  10. try {
  11.     // Get the 'u' parameter, strip the path
  12.     uParam = new URLSearchParams(window.location.search)
  13.         .get('u')
  14.         .replace(/(https?:\/\/[a-zA-Z0-9\-\._]{1,63})\/.*/, "$1");
  15. } catch (error) {
  16.     console.log(error);
  17. }
  18.  
  19. // Send it
  20. if (uParam) {
  21.     document
  22.         .getElementById("uParam")
  23.         .textContent = 'You are now logging into: ' + uParam;
  24. }
  25.  
  26. // Get the duplicate login button
  27. duplicateLogin = document.getElementById("login");
  28. // Hide duplicate login button
  29. if (duplicateLogin) duplicateLogin.style.display = "none";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement