mirror of
https://github.com/Kenshin/simpread.git
synced 2026-01-18 14:19:55 +00:00
Add exclusion to menu.
This commit is contained in:
parent
163a9c61e9
commit
634c982c5b
@ -64,6 +64,8 @@ menu.OnClicked( ( info, tab ) => {
|
||||
browser.tabs.create({ url: browser.extension.getURL( "options/options.html#later" ) });
|
||||
} else if ( info.menuItemId == "whitelist" ) {
|
||||
browser.tabs.sendMessage( tab.id, msg.Add( msg.MESSAGE_ACTION.menu_whitelist, {url: info.pageUrl } ));
|
||||
} else if ( info.menuItemId == "exclusion" ) {
|
||||
browser.tabs.sendMessage( tab.id, msg.Add( msg.MESSAGE_ACTION.menu_exclusion, {url: info.pageUrl } ));
|
||||
} else {
|
||||
if ( !tab.url.startsWith( "chrome://" ) ) browser.tabs.sendMessage( tab.id, msg.Add(info.menuItemId));
|
||||
}
|
||||
|
||||
@ -112,9 +112,15 @@ browser.runtime.onMessage.addListener( function( request, sender, sendResponse )
|
||||
localStorage.removeItem( "sr-update-site" );
|
||||
break;
|
||||
case msg.MESSAGE_ACTION.menu_whitelist:
|
||||
storage.read.whitelist.push( request.value.url );
|
||||
storage.Write( () => {
|
||||
case msg.MESSAGE_ACTION.menu_exclusion:
|
||||
if ( request.type == msg.MESSAGE_ACTION.menu_whitelist ) {
|
||||
storage.read.whitelist.push( request.value.url );
|
||||
new Notify().Render( "已加入到白名单。" );
|
||||
} else if ( request.type == msg.MESSAGE_ACTION.menu_exclusion ) {
|
||||
storage.read.exclusion.push( request.value.url );
|
||||
new Notify().Render( "已加入到排除列表。" );
|
||||
}
|
||||
storage.Write( () => {
|
||||
watch.SendMessage( "option", true );
|
||||
});
|
||||
break;
|
||||
|
||||
@ -127,6 +127,10 @@ export default class LabsOpt extends React.Component {
|
||||
thumbedColor="#3F51B5" trackedColor="#7986CB" waves="md-waves-effect"
|
||||
label="是否显示「加入白名单」?"
|
||||
onChange={ (s)=>this.onChange(s, "option", "menu", "whitelist" ) } />
|
||||
<Switch width="100%" checked={ this.props.option.menu.exclusion }
|
||||
thumbedColor="#3F51B5" trackedColor="#7986CB" waves="md-waves-effect"
|
||||
label="是否显示「加入到排除列表」?"
|
||||
onChange={ (s)=>this.onChange(s, "option", "menu", "exclusion" ) } />
|
||||
</div>
|
||||
|
||||
<div className="label">聚焦模式</div>
|
||||
|
||||
@ -13,6 +13,7 @@ const context = {
|
||||
link : { id: "", menu: {} },
|
||||
list : { id: "", menu: {} },
|
||||
whitelist : { id: "", menu: {} },
|
||||
exclusion : { id: "", menu: {} },
|
||||
},
|
||||
menu = {
|
||||
"type" : "normal",
|
||||
@ -25,6 +26,7 @@ Object.assign( context.read.menu, menu, { id: "read", "title" : "阅读模式"
|
||||
Object.assign( context.list.menu, menu, { id: "list", "title" : "打开稍后读" });
|
||||
Object.assign( context.link.menu, menu, { id: "link", "title" : "使用阅读模式打开此链接", contexts: [ "link" ] });
|
||||
Object.assign( context.whitelist.menu, menu, { id: "whitelist", "title" : "将当前页面加入到白名单" });
|
||||
Object.assign( context.exclusion.menu, menu, { id: "exclusion", "title" : "将当前页面加入到排除列表" });
|
||||
|
||||
/**
|
||||
* Listen contextMenus message
|
||||
@ -51,6 +53,9 @@ function createAll() {
|
||||
|
||||
storage.option.menu.whitelist &&
|
||||
( context.whitelist.id = browser.contextMenus.create( context.whitelist.menu ));
|
||||
|
||||
storage.option.menu.exclusion &&
|
||||
( context.exclusion.id = browser.contextMenus.create( context.exclusion.menu ));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -11,6 +11,7 @@ const action = {
|
||||
close_tab : "close_tab",
|
||||
menu : "menu",
|
||||
menu_whitelist : "menu_whitelist",
|
||||
menu_exclusion : "menu_exclusion",
|
||||
updated : "updated",
|
||||
save_verify : "save_verify",
|
||||
storage : "storage", // only firefox
|
||||
|
||||
@ -116,6 +116,7 @@ const name = "simpread",
|
||||
link : true,
|
||||
list : false,
|
||||
whitelist: false,
|
||||
exclusion: false,
|
||||
},
|
||||
origins : [],
|
||||
blacklist : [
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user