Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup #35

Merged
merged 4 commits into from Dec 8, 2020
Merged

Cleanup #35

Changes from all commits
Commits
File filter
Filter file types
Jump to
Jump to file
Failed to load files.

Always

Just for now

@@ -43,16 +43,6 @@ class AccessToken {
}
}

function parseJwt(token) {
var base64Url = token.split('.')[1];
var base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
var jsonPayload = decodeURIComponent(atob(base64).split('').map(function(c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
}).join(''));

return JSON.parse(jsonPayload);
};

const cookieListener = (changeInfo) => {
const { cookie, removed, cause } = changeInfo;
if (cookie.domain !== AUTH_DOMAIN) {
@@ -3,35 +3,23 @@
(async function () {

function cleanup() {
const $content = document.querySelector('.other-search-engines');
const $searchEngines = document.querySelector('.searchengines');
if ($searchEngines) {
$content.removeChild($searchEngines);
const $searchEngines = document.querySelector('.search-engines');
while ($searchEngines.firstChild) {
$searchEngines.removeChild(searchEngines.firstChild);
}
}

async function addSearchEngines() {
const query = new URLSearchParams(window.location.search).get('q');
const $content = document.querySelector('.other-search-engines');
const $searchEngineTemplate = document.querySelector('#search-engine-template');
const searchEngines = await browser.runtime.sendMessage({
action: 'getSearchEngines',
});
const $searchEnginesWrapper = document.createElement('div');
$searchEnginesWrapper.classList.add('searchengines');
$searchEnginesWrapper.style.display = 'flex';
$searchEnginesWrapper.style.flexDirection = 'row';
$searchEnginesWrapper.style.margin = '40px 0 40px 0';
$searchEnginesWrapper.style.flexWrap = 'wrap';
const $searchEngines = document.querySelector('.search-engines');

searchEngines.forEach(engine => {
const $engine = document.createElement('a');
$engine.style.display = 'flex';
$engine.style.flexDirection = 'column';
$engine.style.alignItems = 'center';
$engine.style.margin = '10px 7px';
$engine.style.textDecoration = 'none';
$engine.style.color = 'black';
$engine.style.cursor = 'pointer';
const $engine = $searchEngineTemplate.content.cloneNode(true);
$engine.querySelector('.search-engine-name').innerText = engine.name;
$engine.addEventListener('click', () => {
browser.runtime.sendMessage({
action: 'search',
@@ -42,25 +30,8 @@
});
});

const $favicon = document.createElement('img');
$favicon.setAttribute('src', engine.favIconUrl);
$favicon.style.height = '24px';
$favicon.style.width = '24px';
$favicon.style.boxShadow = 'inset 0 0 0 1px rgba(249, 249, 250, 0.2), 0 1px 8px 0 rgba(12, 12, 13, 0.2)';
$favicon.style.transition = 'box-shadow 150ms';
$favicon.style.borderRadius = '5px';
$favicon.style.backgroundColor = 'white';
$engine.appendChild($favicon);

const $title = document.createElement('span');
$title.innerText = engine.name;
$title.style.marginTop = '5px';
$engine.appendChild($title);

$searchEnginesWrapper.appendChild($engine);
$searchEngines.appendChild($engine);
});

$content.appendChild($searchEnginesWrapper);
}

if (document.readyState === 'complete' || document.readyState === 'interactive') {
@@ -4,7 +4,9 @@

function cleanup() {
const $topsites = document.querySelector('.top-sites');
$topsites.innerHTML = '';
while ($topsites.firstChild) {
$topsites.removeChild(topsites.firstChild);
}
}

async function loadTopSites() {
@@ -20,11 +20,20 @@
"content_scripts": [{
"matches": [
"https://*.ghosterysearch.com/",
"http://localhost/*"
"https://*.ghosterysearch.com/?*",
This conversation was marked as resolved by chrmod

This comment has been minimized.

@sammacbeth

sammacbeth Dec 8, 2020
Contributor

Does this match only if there is a query string, or did it previously not match when a query string was present? Or does this change do something else?

"http://localhost/",
"http://localhost/?*"
],
"js": [
"content/top-sites.js",
"content/search-bar.js",
"content/search-bar.js"
]
}, {
"matches": [
"https://*.ghosterysearch.com/*",
"http://localhost/*"
],
"js": [
"content/is-ghostery-browser.js"
]
}, {
ProTip! Use n and p to navigate between commits in a pull request.