Skip to content

Commit

Permalink
Several bugfixes 2
Browse files Browse the repository at this point in the history
Fix. Unsafe assignment to innerHTML
Translations
Add. gecko in manifiest
  • Loading branch information
damufo committed Apr 16, 2018
1 parent 420493b commit 45df5fb
Show file tree
Hide file tree
Showing 5 changed files with 192 additions and 22 deletions.
11 changes: 6 additions & 5 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@
"linksInvalidLabel": { "message": "Invalid Links" },
"linksInvalidCaptionLabel": { "message": "Highlight color for links that returned header, but it wasn't http/https header" },
"secondsTimeOutLabel": { "message": "Time out (in seconds)" },
"secondsTimeOutCaptionLabel": { "message": "How many seconds before we say this link has timed out" },

"advancedLabel": { "message": "Advanced" },
"whatTagsShouldCheckLabel": { "message": "What xHTML tags should to analyze?" },
"anchor": { "message": "Anchor" },
"option": { "message": "Option" },
"area": { "message": "Area" },
"anchorLabel": { "message": "Anchor" },
"optionLabel": { "message": "Option" },
"areaLabel": { "message": "Area" },
"hintsToRecongnizeLabel": { "message": "Hints to recognize link to omit" },
"hintsToRecongnizeCaptionLabel": { "message": "Separate by ','" },

Expand All @@ -38,7 +39,7 @@
"donationCaptionLabel": { "message": "Thank you for using Link Analyzer.<br>Your support will be a big encouragement, as I continue to develop the add-on.<br>If you like Link Analyzer, I would be pleased if you could consider donating." },
"addonPageLabel": { "message": "Add-on page" },
"addonUrl": {
"message": "https:\/\/addons.mozilla.org\/en-US\/firefox\/addon\/link-analyer\/?src=optionpage"
"message": "https:\/\/addons.mozilla.org\/en-US\/firefox\/addon\/link-analyzer\/?src=optionpage"
},

"errorCheck": { "message": "Link analyzer failed" },
Expand All @@ -52,7 +53,7 @@
"linksBrokenPopup": { "message": "The link returned code was either 404, or some of other 'can't get here'." },
"linksTimeOutPopup": { "message": "The link has {secondsTimeOut} seconds to open and return header. But one didn't make it." },
"linksInvalidPopup": { "message": "The link didn't return any valid header. Either is server down, or it's redirecting to protocols others than not valid." },
"linksSkippedPopup": { "message": "The link wasn't tested. It can be either anchor to this page (\"#\"), or javascript, etc..." },
"linksSkippedPopup": { "message": "The link wasn't tested. It can be either anchor to this page (#), or javascript, etc..." },

"seconds": { "message": "seconds" },
"restoreDefaultValues": { "message": "Restore default values" }
Expand Down
15 changes: 8 additions & 7 deletions _locales/gl/messages.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"extensionName": { "message": "Link Analyzer" },
"extensionDescription": { "message": "Analiza o estado das ligazóns nunha páxina completa ou nunha selección de texto." },
"menuAll": { "message": "Analiza todas as ligazóns" },
"menuSel": { "message": "Analyze as ligazóns da selección" },
"menuAll": { "message": "Analizar todas as ligazóns" },
"menuSel": { "message": "Analizar as ligazóns da selección" },

"settingsLabel": { "message": "Configuración" },
"informationLabel": { "message": "Información" },
Expand All @@ -22,12 +22,13 @@
"linksInvalidLabel": { "message": "Ligazóns incorrectas" },
"linksInvalidCaptionLabel": { "message": "Cor para realzar as ligazóns que devolveron unha cabeceira, pero esta non foi http/https/file" },
"secondsTimeOutLabel": { "message": "Tempo de espera (en segundos)" },
"secondsTimeOutCaptionLabel": { "message": "Cantos segundos antes de dicir que esta ligazón esgotou o tempo de espera" },

"advancedLabel": { "message": "Avanzado" },
"whatTagsShouldCheckLabel": { "message": "Que etiquedas xHTML debería analizar?" },
"anchor": { "message": "Ancora" },
"option": { "message": "Opción" },
"area": { "message": "Área" },
"anchorLabel": { "message": "Ancora" },
"optionLabel": { "message": "Opción" },
"areaLabel": { "message": "Área" },
"hintsToRecongnizeLabel": { "message": "Consellos para recoñecer a ligazón a omitir" },
"hintsToRecongnizeCaptionLabel": { "message": "Separados por ','" },

Expand All @@ -38,7 +39,7 @@
"donationCaptionLabel": { "message": "Grazas por empregar o Link Analyzer. O seu apoio será un gran estímulo, para continuar desenvolvendo o engadido.<br> Se lle gusta o Link Analyzer, estarei satisfeito se considera facer unha doazón." },
"addonPageLabel": { "message": "Páxina do engadido" },
"addonUrl": {
"message": "https:\/\/addons.mozilla.org\/en-US\/firefox\/addon\/link-analyer\/?src=optionpage"
"message": "https:\/\/addons.mozilla.org\/en-US\/firefox\/addon\/link-analyzer\/?src=optionpage"
},

"errorCheck": { "message": "Fallou o Link analyzer" },
Expand All @@ -52,7 +53,7 @@
"linksBrokenPopup": { "message": "A ligazón devolveu o código 404 ou outro non pode conquerir." },
"linksTimeOutPopup": { "message": "A ligazón tivo {secondsTimeOut} segundos para abrir e devolver a cabeceira. Pero non o fixo." },
"linksInvalidPopup": { "message": "A ligazón non devolveu ningunha cabeceira válida. Ou o servidor está caído, ou está redirixido a un protocolo diferente dos válidos." },
"linksSkippedPopup": { "message": "A ligazón non foi probada. Pode que sexa unha áncora a esta páxina («#»), ou javascript, etc." },
"linksSkippedPopup": { "message": "A ligazón non foi probada. Pode que sexa unha áncora a esta páxina (#), ou javascript, etc." },

"seconds": { "message": "segundos" },
"restoreDefaultValues": { "message": "Restaurar valores predeterminados" }
Expand Down
176 changes: 169 additions & 7 deletions content/content-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ linkAnalyzer.popup = {
linkAnalyzer.css ( stats , { position: "fixed",
top: "100px",
left: "30%",
width: "470px",
width: "570px",
height: "315px",
zIndex: "100",
background: "#fff",
Expand All @@ -475,7 +475,155 @@ linkAnalyzer.popup = {
"overflow-y": "auto" });

var secondsTimeOut = linkAnalyzer.pref.secondsTimeOut;
var statistics =
var element;
var content;
var styleH2;
var styleSup;
var sup;
var line;

styleH2 = "font-size: 20px; color: #000; font-weight: bold; padding-bottom: 5px; margin-bottom: 5px;";

element = document.createElement("H2");
element.style.cssText = styleH2

content = document.createTextNode(browser.i18n.getMessage("extensionName"));
element.appendChild(content);
stats.appendChild(element);

styleSup = "color: #666666; font-size: 10px";

line = document.createElement("P");

// Links Fine
sup = document.createElement("SUP");
sup.style.cssText = styleSup
content = document.createTextNode("1");
sup.appendChild(content);

line.appendChild(sup);
content = document.createTextNode(browser.i18n.getMessage('linksFineLabel') + ": " + linkAnalyzer.statistics.linkFine.length );
line.appendChild(content);
line.appendChild(document.createElement("BR"));

// Links Broken
sup = document.createElement("SUP");
sup.style.cssText = styleSup
content = document.createTextNode("2");
sup.appendChild(content);

line.appendChild(sup);
content = document.createTextNode(browser.i18n.getMessage("linksBrokenLabel") + ": " + linkAnalyzer.statistics.linkBroken.length );
line.appendChild(content);
line.appendChild(document.createElement("BR"));


// Links Time Out
sup = document.createElement("SUP");
sup.style.cssText = styleSup
content = document.createTextNode("3");
sup.appendChild(content);

line.appendChild(sup);
content = document.createTextNode(browser.i18n.getMessage("linksTimeOutLabel") + ": " + linkAnalyzer.statistics.linkTimeOut.length );
line.appendChild(content);
line.appendChild(document.createElement("BR"));

// Links Invalid
sup = document.createElement("SUP");
sup.style.cssText = styleSup
content = document.createTextNode("4");
sup.appendChild(content);

line.appendChild(sup);
content = document.createTextNode(browser.i18n.getMessage("linksInvalidLabel") + ": " + linkAnalyzer.statistics.linkInvalid.length );
line.appendChild(content);
line.appendChild(document.createElement("BR"));

stats.appendChild(line);

// Links Skipped
sup = document.createElement("SUP");
sup.style.cssText = styleSup
content = document.createTextNode("5");
sup.appendChild(content);

line.appendChild(sup);
content = document.createTextNode(browser.i18n.getMessage("linksSkippedLabel") + ": " + linkAnalyzer.statistics.linkSkipped.length );
line.appendChild(content);
line.appendChild(document.createElement("BR"));

stats.appendChild(line);

line = document.createElement("P");
content = document.createTextNode(browser.i18n.getMessage("testDuration") + ": " + linkAnalyzer.statistics.diff + " " + browser.i18n.getMessage("seconds"));
line.appendChild(content);

stats.appendChild(line);

// legends
line = document.createElement("P");

// Links Fine
sup = document.createElement("SUP");
sup.style.cssText = styleSup
content = document.createTextNode("1");
sup.appendChild(content);

line.appendChild(sup);
content = document.createTextNode(browser.i18n.getMessage("linksFinePopup"));
line.appendChild(content);
line.appendChild(document.createElement("BR"));

// Links Broken
sup = document.createElement("SUP");
sup.style.cssText = styleSup
content = document.createTextNode("2");
sup.appendChild(content);

line.appendChild(sup);
content = document.createTextNode(browser.i18n.getMessage("linksBrokenPopup"));
line.appendChild(content);
line.appendChild(document.createElement("BR"));


// Links Time Out
sup = document.createElement("SUP");
sup.style.cssText = styleSup
content = document.createTextNode("3");
sup.appendChild(content);

line.appendChild(sup);
content = document.createTextNode(browser.i18n.getMessage("linksTimeOutPopup").replace("{secondsTimeOut}", linkAnalyzer.pref.secondsTimeOut));
line.appendChild(content);
line.appendChild(document.createElement("BR"));

// Links Invalid
sup = document.createElement("SUP");
sup.style.cssText = styleSup
content = document.createTextNode("4");
sup.appendChild(content);

line.appendChild(sup);
content = document.createTextNode(browser.i18n.getMessage("linksInvalidPopup"));
line.appendChild(content);
line.appendChild(document.createElement("BR"));

stats.appendChild(line);

// Links Skipped
sup = document.createElement("SUP");
sup.style.cssText = styleSup
content = document.createTextNode("5");
sup.appendChild(content);

line.appendChild(sup);
content = document.createTextNode(browser.i18n.getMessage("linksSkippedPopup"));
line.appendChild(content);
line.appendChild(document.createElement("BR"));

stats.appendChild(line);
/*
stats.innerHTML = "<h2 style=\"font-size: 20px; color: #000; font-weight: bold; text-decoration: underline; padding-bottom: 5px; margin-bottom: 5px;\">" + browser.i18n.getMessage("extensionName") + "</h2>" +
"<p>" +
"<sup style=\"color: #666666; font-size: 10px\">1</sup> " + browser.i18n.getMessage('linksFineLabel') + ": " + linkAnalyzer.statistics.linkFine.length + "<br />" +
Expand All @@ -484,22 +632,36 @@ linkAnalyzer.popup = {
"<sup style=\"color: #666666; font-size: 10px\">4</sup> " + browser.i18n.getMessage("linksInvalidLabel") + ": " + linkAnalyzer.statistics.linkInvalid.length + "<br />" +
"<sup style=\"color: #666666; font-size: 10px\">5</sup> " + browser.i18n.getMessage("linksSkippedLabel") + ": " + linkAnalyzer.statistics.linkSkipped.length + "</p>" +
"<p>" + browser.i18n.getMessage("testDuration") + ": " + linkAnalyzer.statistics.diff + " " + browser.i18n.getMessage("seconds") + "</p>";
// let's explain what is what
// let's explain what is what
stats.innerHTML += "<p style=\"color: #666666; font-size: 10px\">" +
"<sup>1</sup> " + browser.i18n.getMessage("linksFinePopup") + "<br />" +
"<sup>2</sup> " + browser.i18n.getMessage("linksBrokenPopup") + "<br />" +
"<sup>3</sup> " + browser.i18n.getMessage("linksTimeOutPopup").replace("{secondsTimeOut}", linkAnalyzer.pref.secondsTimeOut) + "<br />" +
"<sup>4</sup> " + browser.i18n.getMessage("linksInvalidPopup") + "<br />" +
"<sup>5</sup> " + browser.i18n.getMessage("linksSkippedPopup") + "<br /></p>";

*/
// show broken link if exists
if (linkAnalyzer.statistics.linkBroken.length > 0) {
stats.innerHTML += "<h2 style=\"font-size: 20px; color: #000; font-weight: bold; text-decoration: underline; padding-bottom: 5px; margin-bottom: 5px;\">" + browser.i18n.getMessage("linksBrokenLabel") + "</h2><p>";
//stats.innerHTML += "<h2 style=\"font-size: 20px; color: #000; font-weight: bold; text-decoration: underline; padding-bottom: 5px; margin-bottom: 5px;\">" + browser.i18n.getMessage("linksBrokenLabel") + "</h2><p>";
styleH2 = "color: #000; font-weight: bold; padding-bottom: 5px; margin-bottom: 5px;";
element = document.createElement("H2");
element.style.cssText = styleH2
content = document.createTextNode(browser.i18n.getMessage("linksBrokenLabel"));
element.appendChild(content);

stats.appendChild(element);

line = document.createElement("P");
// loop through each broken links
for (var i = 0; i < linkAnalyzer.statistics.linkBroken.length; i++) {
stats.innerHTML += "<b>" + (linkAnalyzer.statistics.linkBroken[i].innerHTML || linkAnalyzer.attr (linkAnalyzer.statistics.linkBroken[i], "alt")).replace("<", "&lt;").replace(">", "&gt;") + "</b><br />";
//stats.innerHTML += "<b>" + (linkAnalyzer.statistics.linkBroken[i].innerHTML || linkAnalyzer.attr (linkAnalyzer.statistics.linkBroken[i], "alt")).replace("<", "&lt;").replace(">", "&gt;") + "</b><br />";
content = document.createTextNode((linkAnalyzer.statistics.linkBroken[i].innerHTML || linkAnalyzer.attr (linkAnalyzer.statistics.linkBroken[i], "alt")).replace("<", "&lt;").replace(">", "&gt;"));
line.appendChild(content);
line.appendChild(document.createElement("BR"));
}
stats.innerHTML += "</p>";
//stats.innerHTML += "</p>";
stats.appendChild(line);
}
},

Expand Down
6 changes: 6 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@

"homepage_url": "https://github.com/damufo/link-analyzer",

"applications": {
"gecko": {
"id": "link-analyzer@damufo"
}
},

"icons": {
"16": "icons/icon-app.svg",
"32": "icons/icon-app.svg",
Expand Down
6 changes: 3 additions & 3 deletions options/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
<ul class="childElements">
<li class="optionContainer">
<div class="optionText">
<p class="checkAnchorLabel">Anchor</p>
<p class="anchorLabel">Anchor</p>
</div>
<div class="optionForm">
<label>
Expand All @@ -156,7 +156,7 @@
</li>
<li class="optionContainer">
<div class="optionText">
<p class="checkOptionLabel">Option</p>
<p class="optionLabel">Option</p>
</div>
<div class="optionForm">
<label>
Expand All @@ -167,7 +167,7 @@
</li>
<li class="optionContainer">
<div class="optionText">
<p class="checkAreaLabel">Area</p>
<p class="areaLabel">Area</p>
</div>
<div class="optionForm">
<label>
Expand Down

0 comments on commit 45df5fb

Please sign in to comment.