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

Add content-script to change account button to login CTA if the exten… #13

Merged
merged 1 commit into from Oct 29, 2020
Merged
Changes from all commits
Commits
File filter
Filter file types
Jump to
Jump to file
Failed to load files.

Always

Just for now

Add content-script to change account button to login CTA if the exten…

…sion has no search tokens
  • Loading branch information
sammacbeth committed Oct 29, 2020
commit c48b7ff256c613026de0b5af7e3ffb69d6d542c7
@@ -104,6 +104,13 @@ async function start() {
requestHeaders,
};
}, { urls: [`${SERP_BASE_URL}/login*`]}, ["blocking", "requestHeaders"]);

browser.runtime.onMessage.addListener(({ action }) => {
if (action === 'getTokenCount') {
return Promise.resolve(tokenPool.tokens.length);
}
return false;
})
}

start();
@@ -0,0 +1,16 @@
"use strict"

const loginButton = document.querySelector('#login-button');
const signInTemplate = document.querySelector('#signin-button-template');

browser.runtime.sendMessage({
action: 'getTokenCount'
}).then((result) => {
if (loginButton && signInTemplate && result === 0) {
while (loginButton.firstChild) {
loginButton.firstChild.remove();
}
const signIn = signInTemplate.content.cloneNode(true);
loginButton.appendChild(signIn);
}
});
@@ -14,6 +14,13 @@
"choice-screen.js"
]
},
"content_scripts": [{
"matches": [
"https://*.ghosterysearch.com/",
"http://localhost/*"
],
"js": ["content/login-cta.js"]
}],
"manifest_version": 2,
"name": "Ghostery Search",
"permissions": [
ProTip! Use n and p to navigate between commits in a pull request.