This repository has been archived on 2023-02-22. You can view files and clone it, but cannot push or open issues or pull requests.
redirect-extention-chrome/popup.js
2022-12-26 23:08:35 +01:00

39 lines
1.0 KiB
JavaScript

const searchButton = document.getElementById('searchButton');
var shlinkAppBtnRdUrl = `${config.shlinkAppUrl}`;
document.getElementById('title').innerHTML = config.customName;
if (searchButton) {
searchButton.addEventListener('click', () => {
searchRedirect();
});
}
const newButton = document.getElementById('newButton');
if (newButton) {
newButton.addEventListener('click', () => {
newRedirect();
});
}
const copyShortUrlBtn = document.getElementById('copyShortUrl-btn');
if (copyShortUrlBtn) {
copyShortUrlBtn.addEventListener('click', () => {
copyShortUrl();
});
}
const openShlinkAppBtn = document.getElementById('openShlinkApp-btn');
if (openShlinkAppBtn) {
openShlinkAppBtn.addEventListener('click', () => {
chrome.tabs.create({url:shlinkAppBtnRdUrl});
});
}
function copyShortUrl () {
var shortUrlOut = document.getElementById("output-shortUrl");
shortUrlOut.select();
shortUrlOut.setSelectionRange(0, 99999);
navigator.clipboard.writeText(shortUrlOut.value);
}