Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // JDownloader2 EventScript - Import context menu test code
- //
- function rebuildMenu(x)
- {
- function r(m)
- {
- //-----------------------------------------
- // Set default value
- if (! ('visible' in m)) m['visible'] = true;
- if (! ('shortcut'in m)) m['shortcut'] = null;
- if (! ('mnemonic'in m)) m['mnemonic'] = null;
- if (! ('iconKey' in m)) m['iconKey'] = null;
- //-----------------------------------------
- if (('items' in m) && m['items'].length)
- {
- m['type'] = 'CONTAINER';
- m['className'] = 'org.jdownloader.controlling.contextmenu.MenuContainer';
- m['actionData'] = {};
- m['items'].forEach(function(val,idx,list){
- r(list[idx]);
- });
- }
- else if (m['name']=='セパレータ')
- {
- m['type'] = 'ACTION';
- m['className'] = 'org.jdownloader.controlling.contextmenu.SeparatorData';
- m['actionData'] = {};
- m['items'] = [];
- }
- else
- {
- m['type'] = 'ACTION';
- m['className'] = null;
- m['actionData'] = {'clazzName':'org.jdownloader.extensions.eventscripter.GenericEventScriptTriggerContextMenuAction'};
- m['items'] = [];
- }
- }
- if (Array.isArray(x))
- x.forEach(function(val,idx,list){r(list[idx]);});
- else
- (r)(x);
- }
- var menu_items =
- [
- {"name" : "セパレータ"},
- {
- "name" : "リネーム - ファイル名を揃える",
- "iconKey" : "edit",
- "items" : [
- {"name" : "パッケージ名でファイル名を揃える"},
- {"name" : "このファイル名でパッケージ内を全て揃える"},
- {"name" : "セパレータ"},
- {"name" : "ファイル名を揃える"},
- {"name" : "ファイル名(作者名)を揃える"},
- {"name" : "ファイル名(タイトル)を揃える"},
- {"name" : "ファイル名(カテゴリ+作者名+タイトル)を揃える"},
- {"name" : "セパレータ"},
- {"name" : "[]内のスワップ"},
- {"name" : "[]内の末尾切り捨て"},
- {"name" : "[]内のxを×に変換"},
- {"name" : "セパレータ"},
- {"name" : "先頭括弧を後方送り"},
- {"name" : "末尾の括弧削除"},
- {"name" : "第○○巻化"}
- ]
- },
- {
- "name" : "リネーム - 修正/追加/置換",
- "iconKey" : "edit",
- "items" : [
- {"name" : "(一般コミック) >>"},
- {"name" : "(一般コミック・少女) >>"},
- {"name" : "(一般コミック) [雑誌] >>"},
- {"name" : "(一般小説) >>"},
- {"name" : "(成年コミック) >>"},
- {"name" : "(成年コミック) [雑誌] >>"},
- {"name" : "(同人誌) >>"},
- {"name" : "(18禁アニメ) >>"},
- {"name" : "セパレータ"},
- {"name" : "<< 別スキャン"},
- {"name" : "<< 透かし有り"},
- {"name" : "<< 寄せ集め"}
- ]
- },
- {
- "name" : "移動/ファイル/再登録",
- "iconKey" : "folder_add",
- "items" : [
- {
- "name" : "この名前を使用して新しいパッケージに移動",
- "iconKey" : "folder_add"
- },
- {
- "name" : "同じ名前のパッケージをまとめる"
- },
- {"name" : "セパレータ"},
- {
- "name" : "リンクグラバーへ再登録",
- "iconKey" : "linkgrabber"
- },
- {"name" : "セパレータ"},
- {
- "name" : "RAR5をZipに変換",
- "iconKey" : "extract"
- }
- ]
- },
- {
- "name" : "EveryThingで検索(作者名)",
- "iconKey" : "search",
- "shortcut" : "pressed F1"
- },
- {
- "name" : "EveryThingで検索(タイトル)",
- "iconKey" : "search"
- },
- {
- "name" : "WEBで検索",
- "iconKey" : "url",
- "items" : [
- {"name" : "********nfo"},
- {"name" : "********om"},
- {"name" : "********org"},
- {"name" : "********net"},
- {"name" : "********"},
- {"name" : "セパレータ"},
- {"name" : "google.com (作者)"},
- {"name" : "google.com (タイトル)"},
- ]
- }
- ];
- rebuildMenu(menu_items);
- var root_container = getRootContextMenu("DownloadTableContext");
- if (root_container && root_container.type == 'CONTAINER' && Array.isArray(root_container.items))
- {
- if (Array.isArray(menu_items))
- menu_items.forEach(function(menu_item){root_container.items.push(menu_item);});
- else
- root_container.items.push(menu_items);
- setRootContextMenu(root_container, "DownloadTableContext");
- callAPI("system","restartJD");
- }
- function getRootContextMenu(context) {
- var storage = "cfg/menus_v2/" + context;
- var interface = "org.jdownloader.controlling.contextmenu.ContextMenuConfigInterface";
- var root_menu = callAPI(
- "config", "get",
- interface,
- storage,
- "menu"
- );
- return root_menu;
- }
- function setRootContextMenu(root_menu, context) {
- var storage = "cfg/menus_v2/"+context;
- var interface = "org.jdownloader.controlling.contextmenu.ContextMenuConfigInterface";
- return callAPI(
- "config", "set",
- interface,
- storage,
- "menu",
- root_menu
- );
- }
- //
- // [appendix]
- //
- // test code for export menu, *.jdDLMenu/*.jdLGMenu/...
- //
- // context: <DownloadTableContext|LinkgrabberContext|DownloadTabBottomBar|LinkgrabberTabBottomBar|MYJDDownloadTableContext|MainMenu|MainToolbar|TrayIcon>
- //
- function getExportedMenu(context) {
- var storage = "cfg/menus_v2/"+context;
- var interface = "org.jdownloader.controlling.contextmenu.ContextMenuConfigInterface";
- var exported_menu = {};
- // object
- exported_menu['root'] = callAPI(
- "config", "get",
- interface,
- storage,
- "menu"
- );
- // array
- exported_menu['unused'] = callAPI(
- "config", "get",
- interface,
- storage,
- "unuseditems"
- );
- return (exported_menu['root']) ? exported_menu : null;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement