Last active
January 3, 2016 14:51
-
-
Save harishvc/ed7d1affdb1d43277632 to your computer and use it in GitHub Desktop.
mapit - content.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
chrome.extension.onMessage.addListener(function(msg, sender, sendResponse) { | |
//tab loaded | |
if (msg.action == 'start') { | |
if (DEBUG === true) { console.log("tab loaded");} | |
Start(); | |
} | |
}); | |
function Start(){ | |
var today = document.getElementsByClassName('lv-location'); | |
for (i=0;i<today.length;i++) { | |
var mapDiv = document.createElement("span"); | |
mapDiv.setAttribute('class', "calendar-clicksaver-maplink"); | |
var a = document.createElement('a'); | |
var b = today[i].innerText; | |
b = b.replace(/^\s-\s/,''); | |
var eb = encodeURIComponent(b).replace(/\(/g, '%28').replace(/\)/g, '%29').replace(/%20/g, ' ');; | |
var c = 'https://maps.google.com/maps?q=' + eb + "&source=calendar"; | |
a.href = c; | |
a.innerHTML = b; | |
mapDiv.appendChild(a); | |
//Replace all existing content | |
today[i].innerText = " - "; | |
today[i].appendChild(mapDiv); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment