forked from tusharpasricha/tabX
-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.js
32 lines (23 loc) · 1.11 KB
/
app.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
25
26
27
28
29
30
31
32
const whatsappBtn = document.getElementById('whatsapp-btn');
const facebookBtn = document.getElementById('facebook-btn');
const twitterBtn = document.getElementById('twitter-btn');
const redditBtn = document.getElementById('reddit-btn');
const telegramBtn = document.getElementById('telegram-btn');
function init()
{
chrome.tabs.query({active: true,lastFocusedWindow: true}, function(tabs) {
var tab = tabs[0];
console.log(tab.url);
// alert(tab.url);
//let postUrl = encodeURI(window.location.href) ;
// console.log(postUrl);
// console.log(postUrl);
let postTitle = encodeURI("Check this out.") ;
twitterBtn.setAttribute("href", `https://twitter.com/share?url=${tab.url}&text=${postTitle}`);
facebookBtn.setAttribute("href", `https://www.facebook.com/sharer.php?u=${tab.url}`);
whatsappBtn.setAttribute("href", `https://web.whatsapp.com/send?text=${postTitle} ${tab.url}`);
redditBtn.setAttribute("href", `https://reddit.com/submit?url=${tab.url}&title=${postTitle}`);
telegramBtn.setAttribute("href", `https://t.me/share/url?url=${tab.url}&text=${postTitle}`);
});
}
init();