popup-timer/bookmark/script.js
2025-08-05 17:14:23 +02:00

29 lines
861 B
JavaScript

var link = location.protocol + "//" + location.host + "/link" + location.search;
var popupLink = location.protocol + "//" + location.host + "/popup" + location.search;
history.replaceState(null, "", link);
document.title = parseQueryParams().name + " - Popup Timer";
document.getElementById("open-popup").onclick = function() {
window.open(
popupLink,
"PopupTimer" + Date.now(),
"width=250,height=100,menubar=no,toolbar=no,location=no,status=no,resizable=no,scrollbars=no"
);
}
function parseQueryParams() {
if (location.search === "" || location.search.indexOf("?") !== 0) return {};
var result = {};
location.search.substr(1).split("&").forEach(function(str) {
var key = str.split("=")[0];
var value;
if (str.split("=").length > 1) value = str.split("=")[1];
else value = null;
result[key] = value;
});
return result
}