Last active
May 10, 2024 09:49
-
-
Save iambibhas/b0d1d15e518aca8a08e9fc23572ec23b to your computer and use it in GitHub Desktop.
Adds a google maps search link beside apartment complex listings when you open them on map view
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
// ==UserScript== | |
// @name NoBroker Google Maps | |
// @namespace http://tampermonkey.net/ | |
// @version 2024-05-09 | |
// @description Adds a google maps search link beside apartment complex listings when you open them on map view | |
// @author Bibhas D | |
// @match https://www.nobroker.in/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=nobroker.in | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
// Specify the URL for the new anchor tag | |
const newUrl = 'http://maps.google.com/?q='; | |
// Function to add new anchor tag | |
function addAnchorTag() { | |
const gmap = document.querySelector('#gmap'); | |
if(gmap) { | |
gmap.remove(); | |
} | |
// Find all anchor tags with "|" in the text | |
document.querySelectorAll('a').forEach(function(anchor) { | |
if (anchor.innerText.includes('|')) { | |
// Create a new anchor tag | |
const newAnchor = document.createElement('a'); | |
const query = anchor.innerText.split('|')[1]; | |
newAnchor.href = newUrl + query; | |
newAnchor.id = 'gmap'; | |
newAnchor.target = '_blank'; | |
newAnchor.innerText = 'Gmap'; | |
// Insert the new anchor tag beside the existing one | |
anchor.parentNode.insertBefore(newAnchor, anchor.nextSibling); | |
} | |
}); | |
} | |
// Run the addAnchorTag function every 2 seconds | |
setInterval(addAnchorTag, 2000); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment