Skip to content

Commit

Permalink
Update background.js
Browse files Browse the repository at this point in the history
  • Loading branch information
astitva1905 authored Dec 31, 2020
1 parent 6fdf89e commit 970a0a5
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions src/background.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,32 @@

function notifications(){

chrome.notifications.create(
{
title:'Prithvi: A greener future',
message:'If you\'re planning to buy something, greener alternatives are just a click away!',
title:'Prithvi: A Greener Future',
message:'If you\'re planning to buy something, Greener alternatives are just a click away!',
type:'basic',
iconUrl:'icon.png'
}
)
}


var quer1;
chrome.tabs.onUpdated.addListener(function (changeInfo, tab) {

var quer1;
chrome.tabs.onUpdated.addListener(function (tabID, changeInfo, tab) {
if (changeInfo.status == 'complete') {

let url = tab.url;
var start = url.indexOf("q=")+2;
var end = url.indexOf("&", start);
quer1 = url.substring(start, end);
console.log(quer1);

var allKeys=["buy","price","cheap", "product", "shop", "sale","amazon","flipkart","myntra","purchase","ecological"];

var counter=0;
for(i=0;i<allKeys.length;i++){
if(quer1.includes(allKeys[i])&&counter==0){
notifications();

if(quer1.includes(allKeys[i])&&counter==0){

notifications();
counter++;
}
counter++;
}
}
});
}
});

0 comments on commit 970a0a5

Please sign in to comment.