diff --git a/README.md b/README.md index 9f36ae4da345c602f3b5cbe57a257de701823925..6e676399f45cbaca9aba16e018eb66ecad7f32a5 100644 --- a/README.md +++ b/README.md @@ -8,12 +8,18 @@ The rules table contains lines with the following parameters : - action : add, modify or delete a header field - header field name - header field value +- comment : a comment - status : on if the modification is active , off otherwise -We can choose the urls on which the modifications applies by modifying the url pattern. +We can choose the urls on which the modifications applies by modifying the url pattern. The url pattern must follow the syntaxe define by https://developer.chrome.com/extensions/match_patterns To save and apply the modification , you need to click on the save button +It's possible to: +- export the configuration in a file (json format) +- import the configuration from a file , it support the format of the Modifyheaders plugin + + The extension can be start and stop via the button on the top right. The code is opensource under Mozilla Public License 2.0 diff --git a/background.js b/background.js index f5b552ed5a8826c8ad6f9bca0ad9ea5e8982da92..0be886ffacef3b57d6d5f5b8b37d0bfd1795641c 100644 --- a/background.js +++ b/background.js @@ -4,7 +4,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * @author didierfred@gmail.com - * @version 0.1 + * @version 0.2 */ @@ -149,7 +149,7 @@ function notify(message) function addListener() { var target = config.target_page; - if ((target=="*")||(target=="")||(target==" "))target="<all_urls>"; + if ((target=="*")||(target=="")||(target==" ")) target="<all_urls>"; browser.webRequest.onBeforeSendHeaders.addListener(rewriteHeader, {urls: [target]}, diff --git a/popup/config.html b/popup/config.html index bd2224cf7905195a809d229b6e00efad8050e525..43c568070022e8c4c74299b95f5f92b4b55afa30 100644 --- a/popup/config.html +++ b/popup/config.html @@ -53,7 +53,7 @@ color: #008CBA; <td width="450"> - Url Pattern* : <input size="50" id="targetPage" type="text" value=""></input> + Url Pattern* : <input size="50" id="targetPage" type="text" value=""> </td> <td width="270" align="right"> diff --git a/popup/config.js b/popup/config.js index 9d9c60be638fe74052a9f9b57413b792c3df2c67..289824cdb8ca4f8feb5e62c5eb31d38af6100069 100644 --- a/popup/config.js +++ b/popup/config.js @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * @author didierfred@gmail.com - * @version 0.1 + * @version 0.2 */ @@ -21,6 +21,7 @@ window.onload = function() { document.getElementById('add_button').addEventListener('click',function (e) {appendLine("add","-","-","","off");}); document.getElementById('start_img').addEventListener('click',function (e) {start_modify();}); document.getElementById('targetPage').value=config.target_page; + document.getElementById('targetPage').addEventListener('keyup',function (e) {checkTargetPageField();}); started = localStorage.getItem("started"); if (started=="on") document.getElementById("start_img").src = "img/stop.png"; } ; @@ -69,17 +70,24 @@ function create_configuration_data() return JSON.stringify(to_export); } +// check if url pattern is valid , if not , set the font color to red +function checkTargetPageField() +{ +if (isTargetValid(document.getElementById('targetPage').value)) document.getElementById('targetPage').style.color="black"; +else document.getElementById('targetPage').style.color="red"; +} + // check if url pattern is valid function isTargetValid(target) { if (target=="") return true; if (target==" ") return true; if (target=="*") return true; - return target.match("(http|https):\/\/.[^\*]*\/"); + return target.match("(http|https|[\*]):\/\/([\*][\.][^\*]*|[^\*]*|[\*])\/"); } -function save_data () +function save_data() { if (!isTargetValid(document.getElementById('targetPage').value)) { @@ -143,6 +151,8 @@ function readSingleFile(e) // check file format if (config.format_version && config.target_page) { + // if url pattern invalid , set to "" + if (!isTargetValid(config.target_page)) config.target_page=""; // store the conf in the local storage localStorage.setItem("config",contents); // load the new conf diff --git a/screenshot.png b/screenshot.png index 56ca713532131689a02e23d3a2334e2ee3177597..585c6ddb234dddd8c7cd95568515ef66c06fe1b0 100644 Binary files a/screenshot.png and b/screenshot.png differ