Skip to content

Firefox support #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.git
./*.DS_Store
./*DS_Store
.idea

web-ext-artifacts/
.web-extension-id
55 changes: 29 additions & 26 deletions devtools.html
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
<!--
/**
* MageSpecialist
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @category MSP
* @package MSP_DevTools
* @copyright Copyright (c) 2017 Skeeller srl (http://www.magespecialist.it)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
-->
<!DOCTYPE html>
<html>
<head>
<script src="js/jquery.js"></script>
<script src="js/devtools.js"></script>
</head>
<body></body>
</html>
<head>
<!--
/**
* MageSpecialist
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @category MSP
* @package MSP_DevTools
* @copyright Copyright (c) 2017 Skeeller srl (http://www.magespecialist.it)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
-->
<meta charset="utf-8">
<script src="js/browser.js"></script>
<script src="js/jquery.js"></script>
<script src="js/devtools.js"></script>
</head>
<body></body>
</html>
46 changes: 25 additions & 21 deletions inspector.html
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
<!--
/**
* MageSpecialist
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @category MSP
* @package MSP_DevTools
* @copyright Copyright (c) 2017 Skeeller srl (http://www.magespecialist.it)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
-->
<!DOCTYPE html>
<html>
<head>
<!--
/**
* MageSpecialist
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @category MSP
* @package MSP_DevTools
* @copyright Copyright (c) 2017 Skeeller srl (http://www.magespecialist.it)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
-->
<meta charset="utf-8">

<script src="js/browser.js"></script>
<script src="js/jquery.js"></script>
<script src="js/renderer.js"></script>
<script src="js/inspector.js"></script>
Expand Down Expand Up @@ -59,4 +63,4 @@ <h4>No DevTools information detected here.</h4>
</div>
</div>
</body>
</html>
</html>
6 changes: 3 additions & 3 deletions js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

var mspPorts = {};

chrome.runtime.onConnect.addListener(function (port) {
browser.runtime.onConnect.addListener(function (port) {
var portName = port.name;
var tabId = 0;

Expand Down Expand Up @@ -52,9 +52,9 @@ chrome.runtime.onConnect.addListener(function (port) {
console.log("Icon: " + msg.payload);

if (msg.payload === 'online') {
chrome.browserAction.setIcon({path: "images/icon.png", tabId: msg.tabId});
browser.browserAction.setIcon({path: "images/icon.png", tabId: msg.tabId});
} else {
chrome.browserAction.setIcon({path: "images/icon_off.png", tabId: msg.tabId});
browser.browserAction.setIcon({path: "images/icon_off.png", tabId: msg.tabId});
}
}

Expand Down
5 changes: 5 additions & 0 deletions js/browser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
window.browser = (function () {
return window.msBrowser ||
window.browser ||
window.chrome;
})();
2 changes: 1 addition & 1 deletion js/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

var port = chrome.runtime.connect({name: "content"});
var port = browser.runtime.connect({name: "content"});

function addDocumentInformation() {
var blocks = [];
Expand Down
24 changes: 12 additions & 12 deletions js/devtools.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,18 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

var port = chrome.runtime.connect({
name: "devtools:" + chrome.devtools.inspectedWindow.tabId
});

var port = browser.runtime.connect({
name: "devtools:" + browser.devtools.inspectedWindow.tabId
});
// alert(port);
function updateDevToolsInformation() {
function onUpdateMessage() {
return window.mspDevTools;
}

chrome.devtools.inspectedWindow.eval('(' + onUpdateMessage.toString() + ')()', {}, function (res) {
var tabId = chrome.devtools.inspectedWindow.tabId;
browser.devtools.inspectedWindow.eval('(' + onUpdateMessage.toString() + ')()', {}, function (res) {
var tabId = browser.devtools.inspectedWindow.tabId;

port.postMessage({
tabId: tabId,
Expand All @@ -38,26 +39,25 @@ function updateDevToolsInformation() {
});
}

chrome.devtools.panels.create(
browser.devtools.panels.create(
"Magento",
null,
"panel/panel.html",
null
'images/icon.png',
"/panel/panel.html"
);

chrome.devtools.panels.elements.createSidebarPane(
browser.devtools.panels.elements.createSidebarPane(
"Magento",
function (sidebar) {
sidebar.setPage('inspector.html');
}
);

port.onMessage.addListener(function (msg, sender, sendResponse) {
if (msg.tabId === chrome.devtools.inspectedWindow.tabId) {
if (msg.tabId === browser.devtools.inspectedWindow.tabId) {
if (msg.type === 'update') {
updateDevToolsInformation();
}
}
});

updateDevToolsInformation();
updateDevToolsInformation();
8 changes: 6 additions & 2 deletions js/inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function onItemInspected() {
return {};
}

chrome.devtools.inspectedWindow.eval('(' + onSelectionChange.toString() + ')($0)', {}, function (res) {
browser.devtools.inspectedWindow.eval('(' + onSelectionChange.toString() + ')($0)', {}, function (res) {
$('#inspected').css('display', 'none');
$('#missing').css('display', 'none');
$('#no-data').css('display', 'none');
Expand All @@ -78,11 +78,15 @@ function onItemInspected() {
} else {
$('#inspected').css('display', 'block');
$('#inspected').html(getBlockInfo(res));
$('.phpstormlink').click(function(e) {
e.preventDefault();
fetch(e.target.href);
})
}
});
}

chrome.devtools.panels.elements.onSelectionChanged.addListener(function () {
browser.devtools.panels.elements.onSelectionChanged.addListener(function () {
onItemInspected();
});

Expand Down
18 changes: 7 additions & 11 deletions js/panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@

var dataTables = {};

var port = chrome.runtime.connect({
name: "panel:" + chrome.devtools.inspectedWindow.tabId
var port = browser.runtime.connect({
name: "panel:" + browser.devtools.inspectedWindow.tabId
});
port.onMessage.addListener(function (msg, sender, sendResponse) {
if (msg.tabId === chrome.devtools.inspectedWindow.tabId) {
if (msg.tabId === browser.devtools.inspectedWindow.tabId) {
if (msg.type === 'update') {
if (msg.payload) {
if (!msg.payload['_protocol'] || (msg.payload['_protocol'] < 3)) {
Expand Down Expand Up @@ -92,10 +92,6 @@ function renderTableTab(tabId, values) {
var dataExplode = $($colsTd[i]).attr('data-explode');
var label = $($colsTd[i]).html();

if (!dataWidth) {
dataWidth = 0;
}

if (!colIndex) {
continue;
}
Expand Down Expand Up @@ -196,13 +192,13 @@ function renderTableTab(tabId, values) {
$('#panel-' + tabId + ' a.inspect-block').click(function (e) {
e.preventDefault();
var blockId = $(this).attr('href');
chrome.devtools.inspectedWindow.eval("inspect(jQuery('[data-mspdevtools=" + blockId + "]')[0])");
browser.devtools.inspectedWindow.eval("inspect(jQuery('[data-mspdevtools=" + blockId + "]')[0])");
});

$('#panel-' + tabId + ' a.inspect-ui-component').click(function (e) {
e.preventDefault();
var blockId = $(this).attr('href');
chrome.devtools.inspectedWindow.eval("inspect(jQuery('[data-mspdevtools-ui=" + blockId + "]')[0])");
browser.devtools.inspectedWindow.eval("inspect(jQuery('[data-mspdevtools-ui=" + blockId + "]')[0])");
});

$('#panel-' + tabId + ' a.show-details').click(function (e) {
Expand All @@ -217,7 +213,7 @@ function renderTableTab(tabId, values) {

$(function () {
port.postMessage({
tabId: chrome.devtools.inspectedWindow.tabId,
tabId: browser.devtools.inspectedWindow.tabId,
to: 'devtools',
type: 'update',
payload: {}
Expand All @@ -244,4 +240,4 @@ $(function () {
$me.css('height', ($win.height() - top - 30) + 'px');
});
});
});
});
2 changes: 2 additions & 0 deletions js/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,11 @@ function getPhpStormLinks(data) {

for (var i = 0; i < phpStormLinks.length; i++) {
var $link = $('<a></a>')
.addClass('phpstormlink')
.attr('href', phpStormLinks[i]['link'])
.text(phpStormLinks[i]['file']);


var $dr = $('<div></div>').addClass('definition-row');
var $dd = $('<div></div>').addClass('definition-data');

Expand Down
7 changes: 4 additions & 3 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

"name": "MageSpecialist DevTools for Magento",
"description": "This extension can be used with MSP_DevTools module for Magento",
"version": "3.3.3",
"version": "3.3.4",

"icons": {
"16": "images/icon16x16.png",
Expand All @@ -24,14 +24,15 @@
],
"background": {
"scripts": [
"js/browser.js",
"js/background.js"
]
},
"content_scripts": [
{
"matches": ["*://*/*"],
"js": ["js/jquery.js", "js/content.js"]
"js": ["js/browser.js", "js/jquery.js", "js/content.js"]
}
],
"devtools_page": "devtools.html"
}
}
Loading