diff --git a/addon/options.html b/addon/options.html index 73df42b..07ec980 100644 --- a/addon/options.html +++ b/addon/options.html @@ -36,6 +36,12 @@ +
'; spinnerHtml.style.cssText = "position: absolute; z-index: 1000"; - spinnerHtml.style.top = ( pw.top + top / 2 ) + "px"; - spinnerHtml.style.left = ( pw.left - pw.height + pw.width ) + "px"; - spinnerHtml.style.height = ( pw.height * 0.9 ) + "px"; - spinnerHtml.style.width = ( pw.height * 0.9 ) + "px"; + spinnerHtml.style.top = (pw.top + top / 2) + "px"; + spinnerHtml.style.left = (pw.left - pw.height + pw.width) + "px"; + spinnerHtml.style.height = (pw.height * 0.9) + "px"; + spinnerHtml.style.width = (pw.height * 0.9) + "px"; document.body.appendChild(spinnerHtml); } diff --git a/package.json b/package.json index 151b551..bbf7150 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,9 @@ "extract-loader": "^3.1.0", "file-loader": "^5.0.2", "node-sass": "^4.13.1", + "postcss-inline-svg": "^4.1.0", "postcss-loader": "^3.0.0", + "postcss-svgo": "^4.0.2", "sass-loader": "^8.0.2", "web-ext": "^4.0.0", "webextension-polyfill": "^0.6.0", diff --git a/scss/popup.scss b/scss/popup.scss index 87fec00..84a92cd 100644 --- a/scss/popup.scss +++ b/scss/popup.scss @@ -26,6 +26,20 @@ body { +.link__login { + background-color: #ff0000; + display: block !important; + width: 20px !important; + height: 20px !important; +} + +.link__password { + background: #9b231d; + display: block !important; + width: 20px !important; + height: 20px !important; +} + %box { diff --git a/webpack.config.js b/webpack.config.js index ae64724..1b8e61c 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -43,10 +43,10 @@ module.exports = { outputPath: './' } }, - { loader: 'extract-loader' }, - { loader: 'css-loader' }, - { loader: 'postcss-loader' }, - { loader: 'sass-loader' } + {loader: 'extract-loader'}, + {loader: 'css-loader'}, + {loader: 'postcss-loader'}, + {loader: 'sass-loader'} ] } ] diff --git a/yarn.lock b/yarn.lock index ae3a752..a90a4a4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1697,7 +1697,7 @@ css-select-base-adapter@^0.1.1: resolved "https://registry.yarnpkg.com/css-select-base-adapter/-/css-select-base-adapter-0.1.1.tgz#3b2ff4972cc362ab88561507a95408a1432135d7" integrity sha512-jQVeeRG70QI08vSTwf1jHxp74JoZsr2XSgETae8/xC8ovSnL2WF87GTLO86Sbwdt2lK4Umg4HnnwMO4YF3Ce7w== -css-select@^2.0.0: +css-select@^2.0.0, css-select@^2.0.2: version "2.1.0" resolved "https://registry.yarnpkg.com/css-select/-/css-select-2.1.0.tgz#6a34653356635934a81baca68d0255432105dbef" integrity sha512-Dqk7LQKpwLoH3VovzZnkzegqNSuAziQyNZUcrdDM401iY+R5NkGBXGmtO05/yaXQziALuPogeG0b7UAgjnTJTQ== @@ -2052,7 +2052,7 @@ dom-serializer@0: domelementtype "^2.0.1" entities "^2.0.0" -dom-serializer@~0.1.1: +dom-serializer@^0.1.1, dom-serializer@~0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/dom-serializer/-/dom-serializer-0.1.1.tgz#1ec4059e284babed36eec2941d4a970a189ce7c0" integrity sha512-l0IU0pPzLWSHBcieZbpOKgkIn3ts3vAh7ZuFyXNwJxJXk/c4Gwj9xaTJwIDVQCXawWD0qb3IzMGH5rglQaO0XA== @@ -3385,7 +3385,7 @@ html-comment-regex@^1.1.0: resolved "https://registry.yarnpkg.com/html-comment-regex/-/html-comment-regex-1.1.2.tgz#97d4688aeb5c81886a364faa0cad1dda14d433a7" integrity sha512-P+M65QY2JQ5Y0G9KKdlDpo0zK+/OHptU5AaBwUfAIDJZk1MYf32Frm84EcOytfJE0t5JvkAnKlmjsXDnWzCJmQ== -htmlparser2@^3.9.1: +htmlparser2@^3.10.1, htmlparser2@^3.9.1: version "3.10.1" resolved "https://registry.yarnpkg.com/htmlparser2/-/htmlparser2-3.10.1.tgz#bd679dc3f59897b6a34bb10749c855bb53a9392f" integrity sha512-IgieNijUMbkDovyoKObU1DUhm1iwNYE/fuifEoEHfd1oZKZDaONBSkal7Y01shxsM49R4XaMdGez3WnF9UfiCQ== @@ -5363,6 +5363,17 @@ postcss-discard-overridden@^4.0.1: dependencies: postcss "^7.0.0" +postcss-inline-svg@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/postcss-inline-svg/-/postcss-inline-svg-4.1.0.tgz#54e9199632242cc181af5b55f0f0691ad1020f95" + integrity sha512-0pYBJyoQ9/sJViYRc1cNOOTM7DYh0/rmASB0TBeRmWkG8YFK2tmgdkfjHkbRma1iFtBFKFHZFsHwRTDZTMKzSQ== + dependencies: + css-select "^2.0.2" + dom-serializer "^0.1.1" + htmlparser2 "^3.10.1" + postcss "^7.0.17" + postcss-value-parser "^4.0.0" + postcss-load-config@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/postcss-load-config/-/postcss-load-config-2.1.0.tgz#c84d692b7bb7b41ddced94ee62e8ab31b417b003" @@ -5651,7 +5662,7 @@ postcss@7.0.24: source-map "^0.6.1" supports-color "^6.1.0" -postcss@^7.0.0, postcss@^7.0.1, postcss@^7.0.14, postcss@^7.0.16, postcss@^7.0.23, postcss@^7.0.26, postcss@^7.0.5, postcss@^7.0.6: +postcss@^7.0.0, postcss@^7.0.1, postcss@^7.0.14, postcss@^7.0.16, postcss@^7.0.17, postcss@^7.0.23, postcss@^7.0.26, postcss@^7.0.5, postcss@^7.0.6: version "7.0.26" resolved "https://registry.yarnpkg.com/postcss/-/postcss-7.0.26.tgz#5ed615cfcab35ba9bbb82414a4fa88ea10429587" integrity sha512-IY4oRjpXWYshuTDFxMVkJDtWIk2LhsTlu8bZnbEJA4+bYT16Lvpo8Qv6EvDumhYRgzjZl489pmsY3qVgJQ08nA== + diff --git a/javascript/options.js b/javascript/options.js index 97eeaf9..3834117 100644 --- a/javascript/options.js +++ b/javascript/options.js @@ -46,12 +46,18 @@ function storeSettings() { return password.value; } + function getDropdown() { + const dropdown = document.querySelector("#dropdown"); + return dropdown.checked; + } + const url = getUrl(); const token = getToken(); const password = getPassword(); + const dropdown = getDropdown(); if (isURL(url) && token !== '' && token !== '') { - checkApi(url, token, password); + checkApi(url, token, password, dropdown); } else { message('Oops, could not save preferences', 'error'); } @@ -66,13 +72,16 @@ function updateUI(restoredSettings) { const password = document.querySelector('#password'); password.value = restoredSettings.password || ''; + + const dropdown = document.querySelector('#dropdown'); + dropdown.checked = restoredSettings.dropdown === true ? true : ''; } function onError(e) { console.error(e); } -function checkApi(url, token, password) { +function checkApi(url, token, password, dropdown) { return fetch(url + '/api.php', { method: 'POST', headers: { @@ -93,7 +102,8 @@ function checkApi(url, token, password) { browser.storage.local.set({ url, token, - password + password, + dropdown }); message("Preferences saved.\n SysPass connection established", 'success'); diff --git a/javascript/popup.js b/javascript/popup.js index 2cdfc49..30f0b23 100644 --- a/javascript/popup.js +++ b/javascript/popup.js @@ -8,15 +8,19 @@ const currentTab = browser.tabs.query({currentWindow: true, active: true}) * Get addon settings */ gettingStoredSettings.then(function (data) { - let settingsSearch = Object.assign({ "method": 'account/search' }, data); - settings = data; + let settingsSearch = Object.assign({"method": 'account/search'}, data); + settings = data; - currentTab.then((tabs) => { + currentTab.then((tabs) => { let url = new URL(tabs[0].url); - chrome.runtime.sendMessage({contentScriptQuery: "accountSearch", text: url.hostname, settings: settingsSearch}, data => createList(data)); - }); -}); + chrome.runtime.sendMessage({ + contentScriptQuery: "accountSearch", + text: url.hostname, + settings: settingsSearch + }, data => createList(data)); + }); +}); /** @@ -26,24 +30,27 @@ gettingStoredSettings.then(function (data) { * @returns {[]} */ function createList(data) { - let popUpList = document.querySelector("#popup-list"); - popUpList.innerHTML = ''; - - data.result.result.forEach(function (item) { - let link = document.createElement('div'); - link.setAttribute('data-login', item.login); - link.innerText = item.name; - link.className = "popup-list__item"; - link.addEventListener('click', function (e) { - currentTab.then((tabs) => { - browser.tabs.sendMessage(tabs[0].id, { - command: "fillOutForm", - login: item.login, - id: item.id, + let popUpList = document.querySelector("#popup-list"); + popUpList.innerHTML = ''; + + data.result.result.forEach(function (item) { + let link = document.createElement('div'); + let login = item.login === '' ? '' : ` ( ${item.login} )`; + + link.setAttribute('data-login', item.login); + link.innerText = item.name + login; + link.className = "popup-list__item"; + link.addEventListener('click', function (e) { + currentTab.then((tabs) => { + browser.tabs.sendMessage(tabs[0].id, { + command: "fillOutForm", + login: item.login, + id: item.id, + }); + }); }); - }); - }) - popUpList.appendChild(link); - }); + popUpList.appendChild(link); + }); } + diff --git a/javascript/syspass.js b/javascript/syspass.js index be5da6f..62236db 100644 --- a/javascript/syspass.js +++ b/javascript/syspass.js @@ -8,29 +8,26 @@ let settings, usernameField = '', passwordField = ''; * Get addon settings */ gettingStoredSettings.then(function (data) { - let settingsSearch = Object.assign({ "method": 'account/search' }, data); + let settingsSearch = Object.assign({"method": 'account/search'}, data); settings = data; - chrome.runtime.sendMessage({contentScriptQuery: "accountSearch", text: window.location.host, settings: settingsSearch}, data => selectLogin(data)); + chrome.runtime.sendMessage({ + contentScriptQuery: "accountSearch", + text: window.location.host, + settings: settingsSearch + }, data => selectLogin(data)); }); browser.runtime.onMessage.addListener(request => { - if(request.command === 'fillOutForm') { - let form = passwordField.closest('form'); - let password = document.querySelector('input[type=password]'); - let username = form.querySelectorAll('input[type="text"]')[0]; - username.value = request.login; + if (request.command === 'fillOutForm') { + usernameField.value = `${request.login}`; spinner(); - let settingsPassword = Object.assign({ "method": 'account/viewPass', id: request.id }, settings); + let settingsPassword = Object.assign({"method": 'account/viewPass', id: request.id}, settings); chrome.runtime.sendMessage({contentScriptQuery: "getPassword", settings: settingsPassword}, data => { - password.value = data.result.result.password; + passwordField.value = data.result.result.password; document.getElementById('syspass-spinner').remove(); }); - - - } - return Promise.resolve({response: "Login set ..."}); }); /** @@ -53,7 +50,7 @@ function autocompleteField(field, data) { onSelect: function (item) { usernameField.value = item.value; spinner(); - let settingsPassword = Object.assign({ "method": 'account/viewPass', id: item.id }, settings); + let settingsPassword = Object.assign({"method": 'account/viewPass', id: item.id}, settings); chrome.runtime.sendMessage({contentScriptQuery: "getPassword", settings: settingsPassword}, data => { passwordField.value = data.result.result.password document.getElementById('syspass-spinner').remove(); @@ -76,14 +73,16 @@ function selectLogin(data) { passwordField = document.querySelector('input[type=password]'); usernameField = passwordField.closest('form').querySelectorAll('input[type="text"]')[0]; - if (usernameField !== undefined) { - usernameField.setAttribute('autocomplete', 'off'); - autocompleteField(usernameField, list); - } + if (settings.dropdown === false) { + if (usernameField !== undefined) { + usernameField.setAttribute('autocomplete', 'off'); + autocompleteField(usernameField, list); + } - if (passwordField !== undefined) { - passwordField.setAttribute('autocomplete', 'off'); - autocompleteField(passwordField, list); + if (passwordField !== undefined) { + passwordField.setAttribute('autocomplete', 'off'); + autocompleteField(passwordField, list); + } } }, 100); } @@ -110,14 +109,14 @@ function processList(data) { function spinner() { let spinnerHtml = document.createElement('div'); let pw = passwordField.getBoundingClientRect(); - let top = pw.height - ( pw.height * 0.9 ); + let top = pw.height - (pw.height * 0.9); spinnerHtml.innerHTML = '