Youtube: strip https from share url

Strip https from share url: youtu.be/xxxxyyyy

  1. // ==UserScript==
  2. // @name Youtube: strip https from share url
  3. // @description Strip https from share url: youtu.be/xxxxyyyy
  4. // @include https://www.youtube.com/*
  5. // @version 1.0
  6. // @author wOxxOm
  7. // @namespace https://greatest.deepsurf.us/users/2159-woxxom
  8. // @license MIT License
  9. // @run-at document-end
  10. // ==/UserScript==
  11.  
  12. window.addEventListener('load', waitForShare);
  13. window.addEventListener('spfdone', waitForShare);
  14. function waitForShare() {
  15. var panel = document.getElementById('watch-actions-share-panel');
  16. if (!panel)
  17. return;
  18. new MutationObserver(function(mutations) {
  19. this.disconnect();
  20. var input = panel.querySelector('[value*="//youtu.be"]');
  21. if (!input)
  22. return;
  23. stripProtocol();
  24. input.addEventListener('focus', stripProtocol);
  25.  
  26. function stripProtocol() {
  27. input.value = input.value.replace(/https?:\/\//, '');
  28. input.select();
  29. }
  30. }).observe(panel, {subtree: true, childList: true});
  31. }