forked from alanhuang122/fl-oneclick-wiki
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent.js
24 lines (21 loc) · 796 Bytes
/
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
// Here we inject our code into the context of the page itself, since we need to patch its XHR mechanisms.
var s = document.createElement('script');
s.src = chrome.runtime.getURL('inject.js');
s.onload = function () {
this.remove();
};
(document.head || document.documentElement).appendChild(s);
window.addEventListener("message", function (event) {
if (event.source !== window)
return;
if (event.data.action && event.data.action === "openInFLWiki") {
let sanitized = event.data.title
.replaceAll(" ", "_")
let encoded = encodeURIComponent(sanitized)
chrome.runtime.sendMessage({
encodedTitle: encoded,
entityId: event.data.entityId,
filterCategories: event.data.filterCategories
});
}
});