diff --git a/javascript/popup.js b/javascript/popup.js index 24445db..bce3cdd 100644 --- a/javascript/popup.js +++ b/javascript/popup.js @@ -639,69 +639,91 @@ function showCodes(result) { document.getElementById('infoAction').className = ''; document.getElementById('editAction').setAttribute('edit', 'false'); document.getElementById('editAction').innerHTML = ''; - for (var i = 0; i < _secret.length; i++) { - try { - _secret[i].issuer = decodeURIComponent(_secret[i].issuer); - } catch (e) {} - try { - _secret[i].account = decodeURIComponent(_secret[i].account); - } catch (e) {} - var el = document.createElement('div'); - el.id = 'codeBox-' + i; - el.className = 'codeBox'; - el.innerHTML = '
' + - ('hotp' === _secret[i].type ? '
' : '
') + - (_secret[i].issuer ? ('
' + _secret[i].issuer + '
') : '') + - '
' + - '
••••••
' + - '
' + _secret[i].account + '
' + - '
' + - '
' + - '
'; - document.getElementById('codeList').appendChild(el); - //if (!_secret[i].encrypted) { - // el.setAttribute('unencrypted', 'true'); - // var warning = document.createElement('div'); - // warning.className = 'warning'; - // warning.innerText = chrome.i18n.getMessage('unencrypted_secret_warning'); - // warning.onclick = function () { - // document.getElementById('security').className = 'fadein'; - // setTimeout(function () { - // document.getElementById('security').style.opacity = 1; - // }, 200); - // }; - // el.appendChild(warning); - //} + var _secret_domain = []; + var _secret_domain_rest = []; + chrome.tabs.query({ + active : true, + lastFocusedWindow : true + }, function (tabs) { + var tab = tabs[0]; + var parser = document.createElement('a'); + parser.href = tab.url; + var host = parser.host; + for (var i = 0; i < _secret.length; i++) { + try { + _secret[i].issuer = decodeURIComponent(_secret[i].issuer); + } catch (e) {} + if (_secret[i].issuer && _secret[i].issuer.split('::')[1] && host.indexOf((_secret[i].issuer.split('::')[1])) > -1 && host.indexOf((_secret[i].issuer.split('::')[1])) + _secret[i].issuer.split('::')[1].length === host.length) { + _secret_domain.push(_secret[i]); + } else { + _secret_domain_rest.push(_secret[i]); + } + } + _secret_domain = _secret_domain.concat(_secret_domain_rest); + for (var i = 0; i < _secret_domain.length; i++) { + try { + _secret_domain[i].issuer = decodeURIComponent(_secret_domain[i].issuer); + } catch (e) {} + try { + _secret_domain[i].account = decodeURIComponent(_secret_domain[i].account); + } catch (e) {} + var el = document.createElement('div'); + el.id = 'codeBox-' + i; + el.className = 'codeBox'; + el.innerHTML = '
' + + ('hotp' === _secret_domain[i].type ? '
' : '
') + + (_secret_domain[i].issuer ? ('
' + _secret_domain[i].issuer.split('::')[0] + '
') : '') + + '
' + + '
••••••
' + + '
' + _secret_domain[i].account + '
' + + '
' + + '
' + + '
'; + document.getElementById('codeList').appendChild(el); + //if (!_secret_domain[i].encrypted) { + // el.setAttribute('unencrypted', 'true'); + // var warning = document.createElement('div'); + // warning.className = 'warning'; + // warning.innerText = chrome.i18n.getMessage('unencrypted_secret_domain_warning'); + // warning.onclick = function () { + // document.getElementById('security').className = 'fadein'; + // setTimeout(function () { + // document.getElementById('security').style.opacity = 1; + // }, 200); + // }; + // el.appendChild(warning); + //} - } - var codeCopy = document.getElementsByClassName('code'); - for (var i = 0; i < codeCopy.length; i++) { - codeCopy[i].onclick = copyCode; - } - var deleteAction = document.getElementsByClassName('deleteAction'); - for (var i = 0; i < deleteAction.length; i++) { - deleteAction[i].onclick = deleteCode; - } - var showQrAction = document.getElementsByClassName('showqr'); - for (var i = 0; i < showQrAction.length; i++) { - showQrAction[i].onclick = showQr; - } - var counterAction = document.getElementsByClassName('counter'); - for (var i = 0; i < counterAction.length; i++) { - counterAction[i].onclick = getNewHotpCode; - } - var accountEditBox = document.getElementsByClassName('accountEditBox'); - for (var i = 0; i < accountEditBox.length; i++) { - accountEditBox[i].onblur = saveAccount; - } - var issuerEditBox = document.getElementsByClassName('issuerEditBox'); - for (var i = 0; i < issuerEditBox.length; i++) { - issuerEditBox[i].onblur = saveIssuer; - } - updateCode(); - update(); - clearInterval(updateInterval); - updateInterval = setInterval(update, 500); + } + var codeCopy = document.getElementsByClassName('code'); + for (var i = 0; i < codeCopy.length; i++) { + codeCopy[i].onclick = copyCode; + } + var deleteAction = document.getElementsByClassName('deleteAction'); + for (var i = 0; i < deleteAction.length; i++) { + deleteAction[i].onclick = deleteCode; + } + var showQrAction = document.getElementsByClassName('showqr'); + for (var i = 0; i < showQrAction.length; i++) { + showQrAction[i].onclick = showQr; + } + var counterAction = document.getElementsByClassName('counter'); + for (var i = 0; i < counterAction.length; i++) { + counterAction[i].onclick = getNewHotpCode; + } + var accountEditBox = document.getElementsByClassName('accountEditBox'); + for (var i = 0; i < accountEditBox.length; i++) { + accountEditBox[i].onblur = saveAccount; + } + var issuerEditBox = document.getElementsByClassName('issuerEditBox'); + for (var i = 0; i < issuerEditBox.length; i++) { + issuerEditBox[i].onblur = saveIssuer; + } + updateCode(); + update(); + clearInterval(updateInterval); + updateInterval = setInterval(update, 500); + }); } } diff --git a/manifest.json b/manifest.json index b090a0c..d4ce8c3 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "__MSG_extName__", "short_name": "__MSG_extShortName__", - "version": "4.17", + "version": "4.18", "default_locale": "en", "description": "__MSG_extDesc__", "icons": {