Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * JDownloader2 EventScript - リネーム系アクション集用メニュー自動設定
- *
- * リネーム系アクション集に対応したメニュー項目を
- * JD2のコンテキストメニューに登録するEventScript
- *
- * 実行後は必ずJDを再起動し、
- * 追加されたメニュー項目をメニュー管理画面から
- * 適宜、移動・編集・削除してください
- *
- *
- * 【使い方】
- *
- * 0. [WEBで検索] 部分(173行目から183行目辺り)を自分用に書き換える
- *
- * 1. [設定]→[イベントスクリプト]→[+追加]ボタンを押す
- * →追加された項目の[編集]ボタンを押す
- * (※ ここで追加した無名スクリプトは、後で削除してください)
- *
- * 2. このスクリプトファイルの内容を全てコピーして貼り付ける
- *
- * 3. [試行]ボタンを押す
- *
- * 4. 登録したいメニューで「はい」を選ぶ
- *
- * 5. JD2を再起動
- *
- * 6. ダウンロードリスト画面、リンクグラバー画面
- * それぞれのメニュー管理画面から好きなように編集
- *
- *
- * 【履歴】
- * 2025/01/07 - JDにshowConfirmDialog()が追加されたので置き換え
- * 2025/01/20 - リネームスクリプト更新に合わせて色々更新
- *
- */
- // -----【設定ここから】-----
- // 検索メニュー
- //(先に「リネーム系アクション集」のUserConfig.web_search_tableを編集し、
- // その名前に合わせて書き換えてください)
- const search_items = [
- "888**.ps",
- "x3**.net",
- "*****-zip.info",
- "bs***.com",
- "raw*****.cc",
- "-",
- "******core.com",
- "******omg.com",
- "nhentai.net",
- "-",
- "google.com (Author)",
- "google.com (Title)",
- ];
- // -----【設定ここまで】-----
- function getSearchItems(separator)
- {
- return search_items.map(function(i){return {'name':(i=='-'?separator:i)}});
- }
- const separator_name_ja='セパレータ';
- const separator_name_en='Separator';
- //SeparatorData_SeparatorData=セパレータ
- /**
- * @typedef {object} menuItem
- * @prop {string} name メニュー名
- * @prop {string} [iconKey=null] アイコン名
- * @prop {string} [shortcut=null] ショートカットキー
- * @prop {menuItem[]} [items] サブメニューのmenuItem配列
- * ----------------------------------
- * @prop {string} [type]
- * @prop {string} [className]
- * @prop {object} [actionData={}]
- * @prop {string} [mnemonic=null]
- * @prop {boolean} [visible=true]
- */
- var menu_items = {};
- /** @type {menuItem[]} Japanese data, 追加するメニューデータ 編集可 */
- menu_items.ja =
- [
- {"name":separator_name_ja},
- {
- "name":"リネーム - ファイル名を揃える",
- "iconKey":"edit",
- "items":[
- {
- "name":"パッケージ名でファイル名を揃える",
- // "shortcut" :"pressed F7",
- },
- {"name":"このファイル名でパッケージ内を全て揃える"},
- {"name":separator_name_ja},
- {"name":"名前を揃える"},
- {"name":"名前を揃える(作者名)"},
- {"name":"名前を揃える(タイトル)"},
- {"name":"名前を揃える(カテゴリ+作者名)"},
- {"name":"名前を揃える(カテゴリ+作者名+タイトル)"},
- {"name":separator_name_ja},
- {"name":"[]内のスワップ"},
- {"name":"[]内の末尾切り捨て"},
- {"name":"[]内のxを×に変換"},
- {"name":separator_name_ja},
- {"name":"第○○巻化"},
- {"name":"名前の数字部分の桁を揃える"},
- {"name":separator_name_ja},
- {"name":"先頭括弧を後方送り"},
- {"name":"末尾の括弧削除"},
- ]
- },
- {
- "name":"リネーム - 修正/追加/置換",
- "iconKey":"edit",
- "items":[
- {"name":"<< 別スキャン"},
- {"name":"<< 単行本"},
- {"name":"<< 透かし有り"},
- {"name":"<< 寄せ集め"},
- {"name":separator_name_ja},
- {"name":"(一般コミック) >>"},
- {"name":"(一般コミック・少女) >>"},
- {"name":"(一般コミック) [雑誌] >>"},
- {"name":"(一般小説) >>"},
- {"name":"(一般書籍) >>"},
- {"name":"(成年コミック) >>"},
- {"name":"(成年コミック) [雑誌] >>"},
- {"name":"(同人誌) >>"},
- {"name":"(同人CG集) >>"},
- {"name":"(18禁アニメ) >>"},
- ]
- },
- {
- "name":"移動/ファイル/再登録",
- "iconKey":"folder_add",
- "items":[
- {
- "name":"この名前を使用して新しいパッケージに移動",
- "iconKey":"package_new",
- // "iconKey":"folder_add",
- // "shortcut" :"pressed F9",
- },
- {"name":"同じ名前のパッケージをまとめる"},
- {"name":"リンクを同じ名前のパッケージに移動"},
- {"name":separator_name_ja},
- {"name":"タイトルで並べ替え(昇順)"},
- {"name":"タイトルで並べ替え(降順)"},
- {"name":"作者名で並べ替え(昇順)"},
- {"name":"作者名で並べ替え(降順)"},
- {"name":"追加日時で並べ替え(昇順)"},
- {"name":"追加日時で並べ替え(降順)"},
- {"name":separator_name_ja},
- {"name":"リンクグラバーへ再登録","iconKey":"linkgrabber"},
- {"name":separator_name_ja},
- {"name":"JDバックアップフォルダを開く"},
- {"name":"登録元ページを開く","iconKey":"search"},
- {"name":separator_name_ja},
- {"name":"ブラウザで開く - rosefile.net のみ","iconKey":"search"},
- ]
- },
- {
- "name":"有効/無効",
- "iconKey":"checkbox_true",
- "items":[
- {"name":"優先ホスト(単一)以外を無効"},
- {"name":"優先ホスト(複数)以外を無効"},
- {"name":separator_name_ja},
- {"name":"frdl.to以外を無効"},
- {"name":"dailyuploads.net以外を無効"},
- {"name":"hexload.com以外を無効"},
- {"name":"mexa.sh以外を無効"},
- {"name":"katfile.com以外を無効"},
- {"name":"rapidgator.net以外を無効"},
- {"name":"dashfile.net以外を無効"},
- {"name":"btafile.com以外を無効"},
- {"name":separator_name_ja},
- {"name":"rosefile.netを無効"},
- {"name":"takefile.linkを無効"},
- ]
- },
- {
- "name":"EveryThingで検索(作者名)",
- "iconKey":"search",
- // "shortcut" :"pressed F1",
- },
- {
- "name":"EveryThingで検索(タイトル)",
- "iconKey":"search",
- },
- {
- "name":"ブラウザで開く",
- "iconKey":"search",
- },
- {
- "name":"WEBで検索",
- "iconKey":"url",
- "items":getSearchItems(separator_name_ja),
- }
- ];
- /** @type {menuItem[]} English data */
- menu_items.en =
- [
- {"name":separator_name_en},
- {
- "name":"rename - align",
- "iconKey":"edit",
- "items":[
- {
- "name":"Rename links to package name",
- // "shortcut" :"pressed F7"
- },
- {"name":"Rename package and links to this link name"},
- {"name":separator_name_en},
- {"name":"Rename links to this link name"},
- {"name":"Rename links to this link name(Author)"},
- {"name":"Rename links to this link name(Title)"},
- {"name":"Rename links to this link name(Category+Author)"},
- {"name":"Rename links to this link name(Category+Author+Title)"},
- {"name":separator_name_en},
- {"name":"Rename Author - swap"},
- {"name":"Rename Author - chop last author"},
- {"name":"Rename Author - x to ×"},
- {"name":separator_name_en},
- {"name":"Rename Numbering to comic format"},
- {"name":"Rename links to align the digits length"},
- {"name":separator_name_en},
- {"name":"Rename links to move starting brackets to end"},
- {"name":"Rename to removing trailed brackets"},
- ]
- },
- {
- "name":"rename - add/replace",
- "iconKey":"edit",
- "items":[
- {"name":"<< 別スキャン"},
- {"name":"<< 単行本"},
- {"name":"<< 透かし有り"},
- {"name":"<< 寄せ集め"},
- {"name":separator_name_en},
- {"name":"(一般コミック) >>"},
- {"name":"(一般コミック・少女) >>"},
- {"name":"(一般コミック) [雑誌] >>"},
- {"name":"(一般小説) >>"},
- {"name":"(一般書籍) >>"},
- {"name":"(成年コミック) >>"},
- {"name":"(成年コミック) [雑誌] >>"},
- {"name":"(同人誌) >>"},
- {"name":"(同人CG集) >>"},
- {"name":"(18禁アニメ) >>"},
- ]
- },
- {
- "name":"move/sort/...",
- "iconKey":"folder_add",
- "items":[
- {
- "name":"Move to new package with this name",
- "iconKey":"package_new",
- // "iconKey":"folder_add",
- // "shortcut" :"pressed F9"
- },
- {"name":"Merge same packages"},
- {"name":"Move links to same name package"},
- {"name":separator_name_en},
- {"name":"Sort packages by Title(ASC)"},
- {"name":"Sort packages by Title(DESC)"},
- {"name":"Sort packages by Author(ASC)"},
- {"name":"Sort packages by Author(DESC)"},
- {"name":"Sort packages by Added Date(ASC)"},
- {"name":"Sort packages by Added Date(DESC)"},
- {"name":separator_name_en},
- {"name":"Add to LinkGrabber","iconKey":"linkgrabber"},
- {"name":separator_name_en},
- {"name":"Open JD Backup Folder"},
- {"name":"Open the Source Page","iconKey":"search"},
- {"name":separator_name_en},
- {"name":"Open browser - only rosefile.net","iconKey":"search"},
- ]
- },
- {
- "name":"enable/disable",
- "iconKey":"checkbox_true",
- "items":[
- {"name":"Diable links by my Rules (Single)"},
- {"name":"Diable links by my Rules (Multiple)"},
- {"name":separator_name_en},
- {"name":"Disable all but frdl.to"},
- {"name":"Disable all but dailyuploads.net"},
- {"name":"Disable all but hexload.com"},
- {"name":"Disable all but mexa.sh"},
- {"name":"Disable all but katfile.com"},
- {"name":"Disable all but rapidgator.net"},
- {"name":"Disable all but dashfile.net"},
- {"name":"Disable all but btafile.com"},
- {"name":separator_name_en},
- {"name":"Disable rosefile.net"},
- {"name":"Disable takefile.link"},
- ]
- },
- {
- "name":"EveryThing(Author)",
- "iconKey":"search",
- // "shortcut" :"pressed F1",
- },
- {
- "name":"EveryThing(Title)",
- "iconKey":"search",
- },
- {
- "name":"Open Browser",
- "iconKey":"search",
- },
- {
- "name":"Search WEB",
- "iconKey":"url",
- "items":getSearchItems(separator_name_en),
- }
- ];
- /////////////////////////////////////////////////
- const StringTable =
- {
- "Separator":"セパレータ",
- "Select the language of the menu item that you want to install.":"インストールするメニューアイテムの言語を選択してください",
- "Japanese":"日本語",
- "English":"英語",
- "Do you want to install Menu Items to the DOWNLOAD Context Menu ?":"ダウンロードリストのコンテキストメニューにメニューを追加します\r\nよろしいですか?",
- "YES":"はい",
- "NO":"いいえ",
- "Do you want to install Menu Items to the LINKGRABBER Context Menu ?":"リンクグラバーのコンテキストメニューにメニューを追加します\r\nよろしいですか?",
- "Your installation require a JDownloader restart to take effect. Restart now?":"設定の反映にはJDownloaderの再起動が必要です\r\n今すぐ再起動しますか?",
- "Restart Now":"再起動する",
- "To later...":"後にする・・・",
- };
- function I(t)
- {
- const lang = getLanguage();
- if (lang != 'ja') return t;
- return (t in StringTable) ? StringTable[t] : t;
- }
- function jdPath(path)
- {
- const sep = getPathSeparator();
- if (sep == '\\')
- path = path.replace('/', '\\');
- else if (sep == '/')
- path = path.replace('\\', '/');
- return JD_HOME+sep+path;
- }
- function DQ(s){ return '"'+ s.trim() +'"'}
- function unDQ(s){return s && s.replace(/^[\s\xA0]*"|"[\s\xA0]*$/g, '')}
- const PATH_CFG_LANGUAGE_JSON = 'cfg\\language.json';
- var getLanguage = function()
- {
- if (getLanguage.cache) return getLanguage.cache;
- const buf = unDQ(readFile(jdPath(PATH_CFG_LANGUAGE_JSON)));
- return getLanguage.cache = (buf != '' && /^([a-zA-Z][-a-zA-Z\d_]+)$/.test(buf)) ? buf : 'en';
- }
- /**
- * メニューデータを再構築
- *
- * @param {menuItem|menuItem[]} x メニューデータ
- */
- 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']==separator_name_ja || m['name']==separator_name_en)
- {
- m['type'] = 'ACTION';
- m['className'] = 'org.jdownloader.controlling.contextmenu.SeparatorData';
- m['actionData'] = {};
- m['items'] = [];
- }
- else
- {
- m['type'] = 'ACTION';
- m['className'] = null;
- if (!('actionData' in m))
- m['actionData'] = {'clazzName':'org.jdownloader.extensions.eventscripter.GenericEventScriptTriggerContextMenuAction'};
- m['items'] = [];
- }
- // if (m['visible']) true;
- }
- if (Array.isArray(x))
- x.forEach(function(val,idx,list){r(list[idx])});
- else
- (r)(x);
- }
- /**
- * コンテキストに応じたルートメニューを取得する
- *
- * @param {"DownloadTableContext"|"LinkgrabberContext"} context コンテキスト
- * @returns {menuItem} ルートメニューデータ(JSON)
- */
- function getRootContextMenu(context)
- {
- const storage = "cfg/menus_v2/" + context;
- const interface = "org.jdownloader.controlling.contextmenu.ContextMenuConfigInterface";
- const root_menu = callAPI(
- "config", "get",
- interface,
- storage,
- "menu"
- );
- return root_menu;
- }
- /**
- * メニューデータをルートとして、コンテキストに応じたメニューに設定する
- * (設定の反映にはJDの再起動が必要)
- *
- * @param {menuItem} x メニューデータ
- * @param {"DownloadTableContext"|"LinkgrabberContext"} context コンテキスト
- * @returns {boolean} 成功か失敗か
- */
- function setRootContextMenu(root_menu, context) {
- const storage = "cfg/menus_v2/"+context;
- const interface = "org.jdownloader.controlling.contextmenu.ContextMenuConfigInterface";
- return callAPI(
- "config", "set",
- interface,
- storage,
- "menu",
- root_menu
- );
- }
- /**
- * メニューデータをコンテキストに応じたルートメニューに追加して設定する
- * (設定の反映にはJDの再起動が必要)
- *
- * @param {menuItem|menuItem[]} menu_items メニューデータ
- * @param {"DownloadTableContext"|"LinkgrabberContext"} context コンテキスト
- * @returns {boolean} 成功か失敗か
- */
- function addMenuToContextMenu(menu_items, context)
- {
- const c = context||"DownloadTableContext";
- /** @type {menuItem} ルートメニュー取得 */
- const root_container = getRootContextMenu(c);
- 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, c);
- }
- }
- const menu_lang = showConfirmDialog(I("Select the language of the menu item that you want to install."),I("Japanese"),I("English"))
- ? 'ja'
- : 'en';
- rebuildMenu(menu_items[menu_lang]);
- var restart_f = 0;
- if (showConfirmDialog(I("Do you want to install Menu Items to the DOWNLOAD Context Menu ?"),I("YES"), I("NO")))
- addMenuToContextMenu(menu_items[menu_lang], "DownloadTableContext") || restart_f++;
- if (showConfirmDialog(I("Do you want to install Menu Items to the LINKGRABBER Context Menu ?"),I("YES"), I("NO")))
- addMenuToContextMenu(menu_items[menu_lang], "LinkgrabberContext") || restart_f++;
- if (restart_f && showConfirmDialog(I("Your installation require a JDownloader restart to take effect. Restart now?"),I("Restart Now"),I("To later...")))
- callAPI("system","restartJD");
Add Comment
Please, Sign In to add comment