Skip to content

Instantly share code, notes, and snippets.

@tomoconnor
Created May 10, 2013 09:46
Show Gist options
  • Select an option

  • Save tomoconnor/5553479 to your computer and use it in GitHub Desktop.

Select an option

Save tomoconnor/5553479 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name t.co securifier
// @version 0.2
// @description replace t.co link with https variant
// @match https://twitter.com/*
// @copyright 2013, Tom O'Connor
// ==/UserScript==
// a function that loads jQuery and calls a callback function when jQuery has finished loading
function addJQuery(callback) {
var script = document.createElement("script");
script.setAttribute("src", "https://ajax.microsoft.com/ajax/jquery/jquery-1.8.2.min.js");
script.addEventListener('load', function() {
var script = document.createElement("script");
script.textContent = "(" + callback.toString() + ")();";
document.body.appendChild(script);
}, false);
document.body.appendChild(script);
}
// the guts of this userscript
function main(){
$().ready(function(){
$('a.twitter-timeline-link').each(function(){
if($(this).attr('href').search("https") == -1){
$(this).attr('href',$(this).attr('href').replace("http","https"));
}
});
});
}
// load jQuery and execute the main function
addJQuery(main);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment