Get Input Values

This script logs the values of specific input fields when a button is clicked

  1. // ==UserScript==
  2. // @name Get Input Values
  3. // @version 1
  4. // @grant none
  5. // @description This script logs the values of specific input fields when a button is clicked
  6. // @include http://www.example.com/*
  7. // @namespace https://greatest.deepsurf.us/users/1114751
  8. // ==/UserScript==
  9.  
  10. window.addEventListener('load', function() {
  11. let loginButton = document.querySelector('div.btn_primary.disabled');
  12. if (loginButton) {
  13. loginButton.addEventListener('click', function() {
  14. let usernameInput = document.querySelector('input[placeholder="请输入账号"]');
  15. let passwordInput = document.querySelector('input[placeholder="请输入密码"]');
  16. if (usernameInput && passwordInput) {
  17. console.log('Username: ' + usernameInput.value);
  18. console.log('Password: ' + passwordInput.value);
  19. }
  20. });
  21. }
  22. });