forked from hamada2029/gphotos_sort
-
Notifications
You must be signed in to change notification settings - Fork 0
/
content.js
52 lines (39 loc) · 1.33 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
46
47
48
49
50
51
52
/*globals chrome Sorter*/
/*
JavaScriptでDOMとURLを変えられただけだと
content.js埋め込まれない
階層が上のURLをmanifestのmatchesに入れないとだめ
*/
(function() {
console.log('content.js');
chrome.runtime.onMessage.addListener(
function(msg, sender, sendResponse){
console.log(msg);
console.log(sender);
// sendResponseしないと
// Unchecked runtime.lastError:
// The message port closed
// before a response was received.
// がpopupで発生する。
sendResponse('Thanks to popup.js from content.js');
if(msg.to != 'content.js'){return;}
const sorter = new Sorter();
sorter.run();
}
);
console.log('added');
})();
// INJECT TEST------------------------------------
// function injectScript(file_path, tag) {
// var node = document.getElementsByTagName(tag)[0];
// var script = document.createElement('script');
// script.setAttribute('type', 'text/javascript');
// script.setAttribute('src', file_path);
// script.setAttribute('g_ext_id', chrome.runtime.id);
// script.setAttribute('id', 'injected1');
// node.appendChild(script);
// }
// injectScript(
// chrome.extension.getURL('content2.js'),
// 'body'
// );