|
// ==UserScript== |
|
// @name Add contact page link to Google Contacts |
|
// @namespace http://tampermonkey.net/ |
|
// @version 0.1 |
|
// @description try to take over the world! |
|
// @author nimrodolev |
|
// @match https://contacts.google.com/* |
|
// @require https://code.jquery.com/jquery-3.5.1.slim.min.js |
|
// @grant none |
|
// @downloadURL https://gist.githubusercontent.com/nimrodolev/6f102608c7229acdf46b402cd9f5d990/raw/google-contacts-link-buttons |
|
// @updateURL https://gist.githubusercontent.com/nimrodolev/6f102608c7229acdf46b402cd9f5d990/raw/google-contacts-link-buttons |
|
// ==/UserScript== |
|
|
|
(function() { |
|
'use strict'; |
|
|
|
function onElementInserted(containerSelector, elementSelector, callback) { |
|
var onMutationsObserved = function(mutations) { |
|
mutations.forEach(function(mutation) { |
|
if (mutation.addedNodes.length) { |
|
var elements = $(mutation.addedNodes).find(elementSelector); |
|
for (var i = 0, len = elements.length; i < len; i++) { |
|
try { |
|
callback(elements[i]); |
|
} |
|
catch(e) { |
|
console.log(e); |
|
} |
|
} |
|
} |
|
}); |
|
}; |
|
|
|
var target = $(containerSelector)[0]; |
|
var config = { childList: true, subtree: true }; |
|
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver; |
|
var observer = new MutationObserver(onMutationsObserved); |
|
observer.observe(target, config); |
|
} |
|
onElementInserted('body', '[data-id]', (element) => { |
|
const personId = element.getAttribute("data-id"); |
|
const url = `https://contacts.google.com/person/${personId}`; |
|
const title = element.querySelector('[role="button"]'); |
|
const anchor = document.createElement('a'); |
|
anchor.style.content = 'url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAQElEQVR42qXKwQkAIAxDUUdxtO6/RBQkQZvSi8I/pL4BoGw/XPkh4XigPmsUgh0626AjRsgxHTkUThsG2T/sIlzdTsp52kSS1wAAAABJRU5ErkJggg==)'; |
|
anchor.style.margin = '0 3px 0 5px'; |
|
anchor.target = '_blank'; |
|
anchor.href = url; |
|
anchor.onclick = (e) => e.stopPropagation(); |
|
title.appendChild(anchor); |
|
|
|
}); |
|
})(); |
Hello, got to you via a reply of yours in StackExchange
Is this script supposed to still be working?
If so, would you mind helping me troubleshoot why it isn't on my chrome or what I may be missing? Where is the link button? (❁´◡`❁)
Please & Thank you
Narf