Files
chrome_extensions/GetAllGCCodes/getallgccodes.js
2025-04-13 20:29:39 +02:00

28 lines
756 B
JavaScript

function copyToClipboard(text) {
const input = document.createElement('input');
input.style.position = 'fixed';
input.style.opacity = 0;
input.value = text;
document.body.appendChild(input);
input.select();
document.execCommand('Copy');
document.body.removeChild(input);
};
chrome.browserAction.onClicked.addListener(function() {
var toClipboard = ""
var separator = "";
chrome.tabs.query({}, function(tabs) {
$.each(tabs, function() {
var url = new URL(this.url);
var domain = url.hostname;
if ((domain == "geocaching.com" || domain == "www.geocaching.com") && url.pathname.startsWith("/geocache")) {
toClipboard += separator + this.title.split(" ")[0];
separator = ",";
}
});
copyToClipboard(toClipboard);
});
});