Skip to content

Commit

Permalink
Merge pull request #1 from JakubJachym/feat/samesite_option
Browse files Browse the repository at this point in the history
Implement SameSite + Secure Cookie options
  • Loading branch information
JakubJachym authored Nov 9, 2020
2 parents c3af64b + c2ef114 commit 3c5476f
Show file tree
Hide file tree
Showing 9 changed files with 333 additions and 218 deletions.
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
MIT License

Copyright (c) 2020 Jakub Jáchym
Copyright (c) 2017 Loïc HALL

Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Xdebug-ext
# Xdebug-ext+

This is an extension for Mozilla Firefox 57+ (Quantum). You can download it from there : https://addons.mozilla.org/en-US/developers/addon/xdebug-ext-quantum/
This is an extension for Mozilla Firefox 57+ (Quantum). It can be installed to Firefox from
[Mozilla Add-on directory](https://addons.mozilla.org/en-US/firefox/addon/xdebug-ext-plus/).

It is a port of the Easiest Xdebug extension, but only the XDEBUG_SESSION cookie is supported for nom. Feel free to ask for other features if you need them.
It is a fork of [Xdebug-ext extension](https://github.com/lhall-adexos/xdebug-ext/).

## Bug report

If you feel something is wrong, feel free to submit an issue : https://github.com/lhall-adexos/xdebug-ext/issues
If you feel something is wrong, feel free to submit an [issue at GitHub](https://github.com/JakubJachym/xdebug-ext-plus/issues).
125 changes: 59 additions & 66 deletions background.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,27 @@
var currentTab;
var currentState;
let currentTab;
let currentState;

/*
* Enable or disable Debugging
*/
function toggleButton(event) {
console.log('toggleButton');
console.log(typeof event);
console.log(event);

function onExecuted(result) {
browser.tabs.executeScript(
currentTab.id, {
file: "cookies.js"
});
}

function onError(error) {
console.log(`Can't execute script: ${error}, for current tab ID ` + currentTab.id);
}

var userTriggered = typeof event === 'object';
var executing = browser.tabs.executeScript(
currentTab.id, {
code: "var currentState = "+ currentState +"; var userTriggered = " + userTriggered + ";"
});
executing.then(onExecuted, onError);
function onExecuted() {
browser.tabs.executeScript(
currentTab.id, {
file: "cookies.js"
});
}

function onError(error) {
console.log(`Can't execute script: ${error}, for current tab ID ` + currentTab.id);
}

const userTriggered = (typeof event === 'object');
const executing = browser.tabs.executeScript(
currentTab.id, {
code: "var currentState = " + currentState + "; var userTriggered = " + userTriggered + ";"
});
executing.then(onExecuted, onError);
}

browser.browserAction.onClicked.addListener(toggleButton);
Expand All @@ -34,50 +30,48 @@ browser.browserAction.onClicked.addListener(toggleButton);
* Switches currentTab to reflect the currently active tab
*/
function updateActiveTab(e) {
console.log('Event', e);
function isSupportedProtocol(urlString) {
var supportedProtocols = ["https:", "http:", "ftp:", "file:"];
var url = document.createElement('a');
url.href = urlString;
return supportedProtocols.indexOf(url.protocol) != -1;
}

function updateTab(tabs) {
if (tabs[0]) {
currentTab = tabs[0];
console.log('Current tab is ' + currentTab.id);
if (isSupportedProtocol(currentTab.url)) {
toggleButton();
}
}
function isSupportedProtocol(urlString) {
const supportedProtocols = ["https:", "http:", "ftp:", "file:"];
let url = document.createElement('a');
url.href = urlString;

return (supportedProtocols.indexOf(url.protocol) !== -1);
}

function updateTab(tabs) {
if (tabs[0]) {
currentTab = tabs[0];
if (isSupportedProtocol(currentTab.url)) {
toggleButton();
}
}
}

var gettingActiveTab = browser.tabs.query({active: true, currentWindow: true});
gettingActiveTab.then(updateTab);
const gettingActiveTab = browser.tabs.query({active: true, currentWindow: true});
gettingActiveTab.then(updateTab);

}

function updateButton(result) {
if (typeof currentTab.id === 'undefined') {
console.log('No current tab yet')
return;
}

browser.browserAction.setIcon({
path: result ? {
32: "data/icons/debug_32_active.png",
48: "data/icons/debug_32_active.png"
} : {
32: "data/icons/debug_48_inactive.png",
48: "data/icons/debug_48_inactive.png"
},
tabId: currentTab.id
});

browser.browserAction.setTitle({
title: result ? 'Disable Debugging' : 'Enable Debugging',
tabId: currentTab.id
});
if (typeof currentTab.id === 'undefined') {
return;
}

browser.browserAction.setIcon({
path: result ? {
32: "data/icons/debug_32_active.png",
48: "data/icons/debug_32_active.png"
} : {
32: "data/icons/debug_48_inactive.png",
48: "data/icons/debug_48_inactive.png"
},
tabId: currentTab.id
});

browser.browserAction.setTitle({
title: result ? 'Disable Debugging' : 'Enable Debugging',
tabId: currentTab.id
});
}

// listen to tab URL changes
Expand All @@ -93,11 +87,10 @@ browser.windows.onFocusChanged.addListener(updateActiveTab);
//browser.browserAction.onClicked.addListener(updateActiveTab);

function notify(message) {
console.log(message);
if (typeof message.state !== 'undefined') {
updateButton(message.state);
currentState = message.state;
}
if (typeof message.state !== 'undefined') {
updateButton(message.state);
currentState = message.state;
}
}

// Listen to content scripts messages
Expand Down
Loading

0 comments on commit 3c5476f

Please sign in to comment.