Last active
April 5, 2018 14:09
-
-
Save marzocchi/11354602 to your computer and use it in GitHub Desktop.
Chrome extension that overrides navigator.geolocation with Mocklocation in all pages
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
{ | |
"manifest_version": 2, | |
"name": "Mocklocation", | |
"description": "Override navigator.geolocation with Mocklocation", | |
"version": "0.1", | |
"permissions": [ | |
"http://*/*", | |
"https://*/*" | |
], | |
"content_scripts": [ | |
{ | |
"matches": ["http://*/*"], | |
"js": ["trigger.js"] | |
}, | |
{ | |
"matches": ["https://*/*"], | |
"js": ["trigger.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
(function(html) { | |
html.setAttribute('class', html.getAttribute('class') + ' mock-geolocation'); | |
var head = html.querySelector('head'); | |
var scripts = [ | |
'//dl.dropboxusercontent.com/u/577031/mocklocation/mocklocation.js', | |
'//cdn.leafletjs.com/leaflet-0.7.2/leaflet.js' | |
]; | |
var styles = [ | |
'//dl.dropboxusercontent.com/u/577031/mocklocation/mocklocation.css', | |
'//cdn.leafletjs.com/leaflet-0.7.2/leaflet.css' | |
]; | |
scripts.forEach(function(url) { | |
var script = document.createElement('script'); | |
script.setAttribute('src', url); | |
head.insertBefore(script, head.firstChild); | |
}); | |
styles.forEach(function(url) { | |
var style = document.createElement('link'); | |
style.setAttribute('rel', 'stylesheet'); | |
style.setAttribute('href', url); | |
head.insertBefore(style, head.firstChild); | |
}); | |
}(document.querySelector('html'))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment