mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-07-04 20:46:39 +02:00
parent
1556ee45c2
commit
9353f71455
7 changed files with 73 additions and 28 deletions
|
@ -27,6 +27,38 @@
|
|||
return id;
|
||||
};
|
||||
|
||||
scope.parseTranslation = function parseTranslation(message){
|
||||
const container = document.createDocumentFragment();
|
||||
|
||||
message.split(/(\{[^}]+\})/).forEach(function(part){
|
||||
if (part.startsWith("{") && part.endsWith("}")){
|
||||
part = part.substring(1, part.length - 1);
|
||||
const args = part.split(":");
|
||||
switch (args[0]){
|
||||
case "image": {
|
||||
const image = document.createElement("img");
|
||||
image.className = "noticeImage";
|
||||
image.src = args.slice(1).join(":");
|
||||
container.appendChild(image);
|
||||
break;
|
||||
}
|
||||
case "link": {
|
||||
const link = document.createElement("a");
|
||||
link.target = "_blank";
|
||||
link.textContent = args[1];
|
||||
link.href = args.slice(2).join(":");
|
||||
container.appendChild(link);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
container.appendChild(document.createTextNode(part));
|
||||
}
|
||||
});
|
||||
return container;
|
||||
};
|
||||
|
||||
scope.extensionID = browserAvailable? browser.extension.getURL(""): "extensionID";
|
||||
|
||||
scope.inIncognitoContext = browserAvailable? browser.extension.inIncognitoContext: false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue