-
Notifications
You must be signed in to change notification settings - Fork 69
/
script.js
24 lines (20 loc) · 846 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
if (document.querySelector('.twitter-token-login-popup')) {
document.querySelector('#submit').addEventListener('click', function () {
var token = document.querySelector('#token').value;
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
var tabId = tabs[0].id;
chrome.scripting.executeScript({
target: { tabId: tabId },
func: Login,
args: [token]
});
});
});
}
function modifyCookie(cookieName, cookieValue, domain, path) {
document.cookie = `${cookieName}=${cookieValue};domain=${domain};path=${path};Secure`;
}
function Login(token) {
modifyCookie('auth_token', `"${token.replace('"', '')}"`, 'twitter.com', '/');
window.location.replace('https://twitter.com');
}