General HTTPS Fix

Fixes some HTTP Links on encrypted sites

Click here to install Browse More Scripts
// ==UserScript==
// @name         General HTTPS Fix
// @namespace    79388f66d31425b73139f142cc994efca557b989
// @version      0.2
// @description  Fixes some HTTP Links on encrypted sites
// @author       /u/AyrA_ch
// @match        https://*/*
// @grant        none
// ==/UserScript==

// Changelog
// 0.2 - Changing match pattern
// 0.1 - Initial Release

(function () {
	'use strict';
	//Only apply to http sites
	if (location.protocol === "https:") {
		var ele = document.querySelectorAll("[href],[src],[link]");
		for (var i = 0; i < ele.length; i++) {
			var e = ele[i];
			//verify that src or href is unencrypted and from the same host
			if ((e.src && e.src.toLowerCase().indexOf("http://" + location.hostname) === 0) ||
				(e.href && e.href.toLowerCase().indexOf("http://" + location.hostname) === 0)) {
				if (e.href && e.href.indexOf("http://") === 0) {
					e.href = "https" + e.href.substr(4);
					console.log("General HTTPS Fix: rewriting unencrypted href attribute");
				}
				if (e.src && e.src.indexOf("http://") === 0) {
					e.src = "https" + e.src.substr(4);
					console.log("General HTTPS Fix: rewriting unencrypted src attribute");
				}
			}
		}
	}
})();

/*
LICENSE:
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
The full license text can be found here: http://creativecommons.org/licenses/by-nc-sa/4.0/
The link has an easy to understand version of the license and the full license text.

DISCLAIMER:
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.
*/

Copyright © 2018 by Kevin Gut 📧 | More services | Generated for 3.143.241.253