// ==UserScript== // @name FF14外部画像参照補助スクリプト // @namespace nohohon // @author nohohon // @description FF14の外部画像参照機能を使って外部画像を楽に登録できるようにするスクリプト // @include https://jp.finalfantasyxiv.com/lodestone/my/blog/* // @include https://jp.finalfantasyxiv.com/lodestone/my/image/* // @include https://jp.finalfantasyxiv.com/lodestone/my/event/post/* // @include https://jp.finalfantasyxiv.com/lodestone/freecompany/* // @include http://jp.finalfantasyxiv.com/lodestone/my/blog/* // @include http://jp.finalfantasyxiv.com/lodestone/my/image/* // @include http://jp.finalfantasyxiv.com/lodestone/my/event/post/* // @include http://jp.finalfantasyxiv.com/lodestone/freecompany/* // @version 1.4.1 // @grant GM_getValue // @grant GM_setValue // @grant GM_deleteValue // @grant GM_log // @grant GM_registerMenuCommand // @grant GM_getResourceText // @resource usconfigcss https://cdn.rawgit.com/NohohonNohon/ff14ExternalScript/master/usconfig.css.template // @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js // @require https://cdn.rawgit.com/NohohonNohon/ff14ExternalScript/master/usconfig.js // ==/UserScript== (function($) { //共通定数 /** 画像URLリストを格納するGM_Value名称 */ var IMG_LIST_ARRAY = 'img_list_array'; /** URL入力欄表示有無 */ var HIDDEN_INPUT = {true:'非表示にする',false:'非表示にしない'}; /** URL自動登録有無 */ var UPLOAD_AUTO = {true:'アップロードする',false:'アップロードしない'}; /** 参照先 */ var GOOGOLE_SERVICE = {photo:'Googleフォト',drive:'Googleドライブ'}; //共通変数 /** 設定値 */ var settings = {hidden_input:'',upload_auto:'',google_service:''}; /** サブウインドウオブジェクト*/   var winObj = null; /** 未設定時に表示する文字列*/   var view_tip = ''; //================================================== /** FF14のページ関連処理 */ //================================================== var FF14 = (function() { /** * 外部画像参照ボタン押下時の処理 * @param {event} イベント */ function clickEmbedBtn(e) { //外部参照欄を非表示にする if(settings.hidden_input == HIDDEN_INPUT.true && $('#add_hidden_area')[0] == null) { $('#external_file_uri').wrapAll(""); $('#external_file_select').wrapAll(""); } // Googleドライブ連携ページを新規ウィンドウで表示する const subw = 600;// サブウインドウの横幅 const subh = 600;// サブウインドウの高さ var subp = '';// 表示するページ(URL) if (settings.google_service == GOOGOLE_SERVICE.photo) { subp = 'https://ff14chocopad.com/static/app/ff14-external-photo/jp/google-photo.html'; } else { subp = 'https://ff14chocopad.com/static/app/ff14-external-photo/jp/google-script.html'; } const subn = 'google-script';// サブウインドウの名称 // 表示座標の計算 const subx = ( screen.availWidth - subw ) / 2;// X座標 const suby = ( screen.availHeight - subh ) / 2;// Y座標 const features = `width=${subw},height=${subh},top=${suby},left=${subx},menubar=no,location=no,resizable=no,scrollbars=no,status=no`; winObj = window.open(subp,subn,features); } /** * サブウィンドウを閉じる */ function closeWindow() { if( (winObj) && (!winObj.closed) ){ //サブウインドウが開かれているか? winObj.close(); //サブウインドウを閉じる } winObj = null; } /** * サブウィンドウをフォーカスする */ function focusWindow() { if( (winObj) && (!winObj.closed) ){ //サブウインドウが開かれているか? winObj.focus(); //サブウインドウをフォーカスする } } var global = { /** * FF14ページ関連処理の初期処理 */ init: function() { $('#embedfiles').on('click',clickEmbedBtn); $('#select_box').on('click',closeWindow); $('.sys_upload_close').on('click',closeWindow); $(window).on('focus', focusWindow); GM_registerMenuCommand('FF14外部画像参照補助(設定)', FF14.openConfig); }, /** * アップロードした画像のURLを登録する */ setImgDataURL: function() { var img_list_array = GM_getValue(IMG_LIST_ARRAY); GM_deleteValue(IMG_LIST_ARRAY); if(img_list_array ==null ){ return false; } for(var i=0; i') .attr('src', 'https://www.google.com/jsapi?key=AIzaSyAqsQs8Saz2cWjL5zXvIw3UeTX38MUDbYs') .appendTo('head'); $('