diff --git a/package.json b/package.json index 211e9eb..edadc84 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tabnews-google-search", - "version": "0.0.2", + "version": "0.0.4", "author": "Karytonn DEV", "license": "ISC", "scripts": { diff --git a/src/manifest.json b/src/manifest.json index 69662a6..16ea92d 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -1,9 +1,8 @@ { "name": "TabNews Google Search", "description": "A simple search for the TabNews", - "version": "0.0.2", + "version": "0.0.4", "manifest_version": 3, - "permissions": ["scripting"], "action": { "default_popup": "index.html", "default_icon": "icon48.png" diff --git a/src/search.js b/src/search.js index e355b99..1c9fc9f 100644 --- a/src/search.js +++ b/src/search.js @@ -5,18 +5,28 @@ const input = document.querySelector('#search-input'); const GOOGLE_BASE_URL = "https://www.google.com/search?q="; const GOOGLE_HACKING_SITE = "site%3Atabnews.com.br"; +const encodeSearchText = (text) => + encodeURIComponent(text) + .replace(/\-/g, '%2D') + .replace(/\_/g, '%5F') + .replace(/\./g, '%2E') + .replace(/\!/g, '%21') + .replace(/\~/g, '%7E') + .replace(/\*/g, '%2A') + .replace(/\'/g, '%27') + .replace(/\(/g, '%28') + .replace(/\)/g, '%29') + //by default "#" is encoded to %23 + form.addEventListener('submit', (event) => { event.preventDefault(); if(input.value) { - - const textFindSanitized = input.value.replace(/\s/g, '%20') - const url = `${GOOGLE_BASE_URL}${textFindSanitized}+${GOOGLE_HACKING_SITE}` - + const url = `${GOOGLE_BASE_URL}${encodeSearchText(input.value)}+${GOOGLE_HACKING_SITE}`; window.open(url, "_target"); } else { - alert("😬 acho que esqueceu de inserir algo no campo de busca.") + alert("😬 acho que esqueceu de inserir algo no campo de busca."); } }); \ No newline at end of file diff --git a/src.zip b/v-0-0-1.zip similarity index 100% rename from src.zip rename to v-0-0-1.zip diff --git a/v-0-0-3.zip b/v-0-0-3.zip new file mode 100644 index 0000000..65e9b75 Binary files /dev/null and b/v-0-0-3.zip differ