show piwik URL
This commit is contained in:
parent
a5d7d79d2a
commit
04fc762427
3 changed files with 29 additions and 16 deletions
|
@ -71,11 +71,16 @@ tests = {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
|
info: {
|
||||||
|
piwikURL: this.URLtoPiwikJS()
|
||||||
|
},
|
||||||
|
results: {
|
||||||
piwikUsesHTTPS: this.piwikUsesHTTPS(),
|
piwikUsesHTTPS: this.piwikUsesHTTPS(),
|
||||||
noProtocolRelativeURL: this.noProtocolRelativeURL(),
|
noProtocolRelativeURL: this.noProtocolRelativeURL(),
|
||||||
noMixedContent: this.noMixedContent(),
|
noMixedContent: this.noMixedContent(),
|
||||||
isScriptAsync: this.isScriptAsync(),
|
isScriptAsync: this.isScriptAsync(),
|
||||||
isPageUTF8: this.isPageUTF8()
|
isPageUTF8: this.isPageUTF8()
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
21
js/panel.js
21
js/panel.js
|
@ -7,9 +7,9 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||||
var tbl = document.querySelector('.table');
|
var tbl = document.querySelector('.table');
|
||||||
tbl.innerHTML = "";
|
tbl.innerHTML = "";
|
||||||
|
|
||||||
for (var testname in data.inject) {
|
for (var testname in data.tests) {
|
||||||
if (data.inject.hasOwnProperty(testname)) {
|
if (data.tests.hasOwnProperty(testname)) {
|
||||||
var response = data.inject[testname];
|
var response = data.tests[testname];
|
||||||
var tr = tbl.insertRow();
|
var tr = tbl.insertRow();
|
||||||
tr.title = testname;
|
tr.title = testname;
|
||||||
var status = tr.insertCell(0), details = tr.insertCell(1);
|
var status = tr.insertCell(0), details = tr.insertCell(1);
|
||||||
|
@ -48,10 +48,11 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||||
// Listen to messages from the background page
|
// Listen to messages from the background page
|
||||||
port.onMessage.addListener(function(message) {
|
port.onMessage.addListener(function(message) {
|
||||||
if (message.action === 'injectResponse') {
|
if (message.action === 'injectResponse') {
|
||||||
data.inject = message.data;
|
data.tests = message.data.results;
|
||||||
|
data.info = message.data.info;
|
||||||
var piwikNotFoundHeading = document.getElementById("piwikNotFoundHeading");
|
var piwikNotFoundHeading = document.getElementById("piwikNotFoundHeading");
|
||||||
var piwikNotFound = document.getElementById("piwikNotFound");
|
var piwikNotFound = document.getElementById("piwikNotFound");
|
||||||
if (!data.inject) {
|
if (!data.tests) {
|
||||||
piwikNotFoundHeading.innerText = chrome.i18n.getMessage("piwikNotFoundHeading");
|
piwikNotFoundHeading.innerText = chrome.i18n.getMessage("piwikNotFoundHeading");
|
||||||
piwikNotFound.innerText = chrome.i18n.getMessage("piwikNotFound");
|
piwikNotFound.innerText = chrome.i18n.getMessage("piwikNotFound");
|
||||||
piwikNotFound.style.display = "inline-block";
|
piwikNotFound.style.display = "inline-block";
|
||||||
|
@ -59,7 +60,13 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||||
} else {
|
} else {
|
||||||
piwikNotFound.style.display = "none";
|
piwikNotFound.style.display = "none";
|
||||||
piwikNotFoundHeading.style.display = "none";
|
piwikNotFoundHeading.style.display = "none";
|
||||||
|
var urlElement = document.getElementById("piwikURL");
|
||||||
|
urlElement.innerText = data.info.piwikURL;
|
||||||
|
if (data.tests.noProtocolRelativeURL.success) {
|
||||||
|
urlElement.href = data.info.piwikURL.slice(0, -8); // remove "piwik.js" from link
|
||||||
|
} else {
|
||||||
|
urlElement.href = "https:" + data.info.piwikURL.slice(0, -8);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// port.postMessage(message);
|
// port.postMessage(message);
|
||||||
} else if (message.action === "requestResponse" && message.file) {
|
} else if (message.action === "requestResponse" && message.file) {
|
||||||
|
@ -73,7 +80,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||||
chrome.runtime.sendMessage({action: "inject", tabId: chrome.devtools.inspectedWindow.tabId});
|
chrome.runtime.sendMessage({action: "inject", tabId: chrome.devtools.inspectedWindow.tabId});
|
||||||
chrome.runtime.sendMessage({action: "request", tabId: chrome.devtools.inspectedWindow.tabId});
|
chrome.runtime.sendMessage({action: "request", tabId: chrome.devtools.inspectedWindow.tabId});
|
||||||
document.querySelector('#start').addEventListener('click', function() {
|
document.querySelector('#start').addEventListener('click', function() {
|
||||||
|
chrome.devtools.inspectedWindow.reload();
|
||||||
chrome.runtime.sendMessage({action: "inject", tabId: chrome.devtools.inspectedWindow.tabId});
|
chrome.runtime.sendMessage({action: "inject", tabId: chrome.devtools.inspectedWindow.tabId});
|
||||||
// chrome.runtime.sendMessage({action: "request", tabId: chrome.devtools.inspectedWindow.tabId});
|
|
||||||
}, false);
|
}, false);
|
||||||
});
|
});
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
<style>
|
<style>
|
||||||
button {
|
button {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top:5px;
|
top: 5px;
|
||||||
right:5px;
|
right: 5px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script src="../js/panel.js"></script>
|
<script src="../js/panel.js"></script>
|
||||||
|
@ -15,10 +15,11 @@
|
||||||
<body>
|
<body>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<h2>Piwik Checker <span id="piwikNotFoundHeading" class="badge badge-warning"></span></h2>
|
<h2>Piwik Checker <span id="piwikNotFoundHeading" class="badge badge-warning"></span></h2>
|
||||||
|
<small><a href="#" id="piwikURL" target="_blank"></a></small>
|
||||||
<p id="piwikNotFound"></p>
|
<p id="piwikNotFound"></p>
|
||||||
<button class="btn btn-secondary" id="start">Reload</button>
|
<button class="btn btn-secondary" id="start">Reload</button>
|
||||||
<table class="table"></table>
|
<table class="table"></table>
|
||||||
<samp id="json"></samp>
|
<pre id="json"></pre>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
Reference in a new issue