diff --git a/functions/phone-parser.js b/functions/phone-parser.js index 09c20db..3c97d7b 100644 --- a/functions/phone-parser.js +++ b/functions/phone-parser.js @@ -24,19 +24,22 @@ function extractPhoneNumberDigits(text) { * @return boolean */ function isValidSelection(selection) { - var tenDigitNumber; + var tenDigitNumber; + const selectionText = selection.selectionText; + const alertCode = `alert('The selection needs to be a valid phone number\\nYou selected:\\n\\n' + '${selectionText}');`; + try { tenDigitNumber = extractPhoneNumberDigits(selection.selectionText); } catch(err) { - alert('The selection needs to be a number\nYou selected:\n\n' + selection.selectionText); + browser.tabs.executeScript({code : alertCode}); return false; } var numberTest = /^\d{10}$/; if( !numberTest.test(tenDigitNumber) ){ - alert('The selection needs to be a valid phone number\nYou selected:\n\n' + selection.selectionText); + browser.tabs.executeScript({code : alertCode}); return false; } return true; diff --git a/manifest.json b/manifest.json index 16964b4..5668f81 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "Guardian Group Phone Dork FF", - "version": "1.1", + "version": "1.2", "description": "A Firefox extension for invoking search queries with a phone number.",