37 lines
1.1 KiB
JavaScript
37 lines
1.1 KiB
JavaScript
let _params = new URLSearchParams(window.location.search);
|
|
let img = document.querySelector('img');
|
|
let h1 = document.querySelector('h1');
|
|
let url = document.querySelector('#url');
|
|
let btnUnSuspend = document.querySelector('button.un-suspend');
|
|
|
|
function setFavicon(favImg){
|
|
let headTitle = document.querySelector('head');
|
|
let setFavicon = document.createElement('link');
|
|
setFavicon.setAttribute('rel','shortcut icon');
|
|
setFavicon.setAttribute('href',favImg);
|
|
headTitle.appendChild(setFavicon);
|
|
}
|
|
|
|
function unSuspend() {
|
|
if(history.length > 1) {
|
|
history.back();
|
|
} else {
|
|
location.href = _params.get('url');
|
|
}
|
|
}
|
|
btnUnSuspend.onclick = unSuspend;
|
|
|
|
document.title = _params.get('title') + ' [zzZ]';
|
|
img.src = _params.get('favIconUrl') || 'img/logo.svg';
|
|
setFavicon(_params.get('favIconUrl') || 'img/logo.svg');
|
|
h1.innerText = _params.get('title');
|
|
url.innerText = _params.get('url');
|
|
url.href = _params.get('url');
|
|
|
|
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
|
|
if(message.type == 'UNSUSPEND') {
|
|
sendResponse(); // need to send before un-suspending
|
|
unSuspend();
|
|
}
|
|
});
|