-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
212 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
let ng_word_list = []; | ||
|
||
function removeMenu(){ | ||
browser.contextMenus.remove("koshian_ng"); | ||
} | ||
|
||
browser.contextMenus.onClicked.addListener((info, tab) => { | ||
if (info.menuItemId === "koshian_ng") { | ||
let tab_id = tab.id; | ||
browser.tabs.sendMessage( | ||
tab_id, | ||
{id:"koshian_ng_context"} | ||
); | ||
} | ||
}); | ||
|
||
browser.contextMenus.onHidden.addListener(removeMenu); | ||
|
||
browser.runtime.onMessage.addListener((message, sender, sendResponse) => { | ||
if (message.id == "koshian_ng_idip") { | ||
browser.contextMenus.create({ | ||
id: "koshian_ng", | ||
title: `NG登録:${message.text}`, | ||
contexts: ["page"], | ||
documentUrlPatterns: ["*://*.2chan.net/*/res/*"] | ||
}); | ||
browser.contextMenus.refresh(); | ||
} | ||
}); | ||
|
||
function onLoadSetting(result) { | ||
ng_word_list = safeGetValue(result.ng_word_list, []); | ||
// 一時的な登録を削除 | ||
ng_word_list = ng_word_list.filter((value) => { | ||
return !value[4]; | ||
}); | ||
|
||
browser.storage.local.set({ | ||
ng_word_list: ng_word_list | ||
}); | ||
} | ||
|
||
function safeGetValue(value, default_value) { | ||
return value === undefined ? default_value : value; | ||
} | ||
|
||
browser.storage.local.get().then(onLoadSetting, (err) => {}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.