Greasy Fork镜像 is available in English.

HTTP-to-HTTPS redirector

Replace http:// with https:// in the address bar, to make sure you're using the SSL-encrypted version of a page. Only enable for pages that you know are SSL enabled.

< Valutazione su HTTP-to-HTTPS redirector

Recensione: OK - lo script funziona, ma ha degli errori.

§
Pubblicato: 27/09/2014
Modificato: 27/09/2014

Some improvements

Hey. Thanks for writing this script. I'd like to make some minor suggestions to improve it.

1. Everything inside the wrapping anonymous function can be replaced with a single statement:
location.protocol = "https";

2. If for some reason the first suggestion is rejected (I'm not entirely sure if it works on every browser), you can make the regex replace version error-proof by adding a "^" to the beginning of the regex, so that it would only match at the beginning of the URL string.
location.href.replace(/^http\:/, 'https');

3. As per Greasemonkey documentation, adding the meta-block imperative @grant none to every userscript that doesn't use special APIs is a good security measure (at least for those who are for some reason still using GM 1.x).

Cheers.

§
Pubblicato: 27/09/2014

Woops, I forgot the most important suggestion.

Please add the following metadata imperative:

// @run-at document-start

This causes the redirection to occur *before* the page is loaded, which is a lot faster, bandwidth-friendly, and saves the user from a potentially frustrating redirection that occurs after the page has been loaded.

(Full info in documentation page.)

Thanks again.

Pubblica risposta

Accedi per pubblicare una risposta.

长期地址
遇到问题?请前往 GitHub 提 Issues,或加Q群1031348184

赞助商

Fishcpy

广告

Rainyun

注册一下就行

Rainyun

一年攒够 12 元