-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent.js
45 lines (37 loc) · 1.43 KB
/
content.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
33
34
35
36
37
38
39
40
41
42
43
44
45
// alert("Hello from your Chrome extension!")
// var firstHref = $("a[href^='http']").eq(0).attr("href");
var obj={"key": {"k2": "v2"}};
console.log(obj);
console.log('inside content.js');
chrome . runtime . onMessage . addListener (
function ( request , sender , sendResponse ) {
// console.log('content.js called, request', request);
if ( request.message == "clicked_browser_action" ) {
// console.log('inside if');
// var firstHref = $ ( " a[href^='http'] " ). eq ( 0 ). attr ( " href " );
// console . log ( firstHref );
alert('extension icon clicked!!!');
}
}
);
// $( "*" ).each(function( index ) {
// $( this ).append(' ');
// });
// let cloneBody = $('body').clone().find('script').remove().end().find('style').remove().end();
// var str = cloneBody.text();
// //Of course you have to trim duplicated blank spaces.
// str = str.replace(/\s\s+/g, ' ');
// console.log('body str ', str);
// // $('#new').text(str);
// // console.log(firstHref);
// $("body").click(function(){
// var s = window.getSelection();
// s.modify('extend','backward','word');
// var b = s.toString();
// s.modify('extend','forward','word');
// var a = s.toString();
// s.modify('move','forward','character');
// var c=b+a;
// // c=_meaning(c); // _meaning() is the api call to wiki to get the keyword description
// // alert(b+a);
// });