TrocaHTTPporHTTPS

[PT] Troca o protocolo 'http' por 'https' (seguro) para TODOS os sites (se este nao tiver uma versao segura, causa erro)

  1. // ==UserScript==
  2. // @name TrocaHTTPporHTTPS
  3. // @namespace http://userscripts.org/scripts/show/77703
  4. // @author RASG
  5. // @description [PT] Troca o protocolo 'http' por 'https' (seguro) para TODOS os sites (se este nao tiver uma versao segura, causa erro)
  6. // @include http://*
  7. // @version 2012.01.01
  8. // ==/UserScript==
  9.  
  10. (function() {
  11. var url = window.location.href;
  12.  
  13. if (url.indexOf("http:")==0) {
  14. window.location.replace(location.href.replace(location.protocol, "https:"));
  15. }
  16.  
  17. if (url.indexOf("https:")==0) {
  18. for (var i=0,link; (link=document.links[i]); i++) {
  19. if (link.href.indexOf("http:")==0) link.href = link.href.replace(location.protocol, "https:");
  20. }
  21. }
  22.  
  23. }
  24. )();