DQX 思い出アルバム保存補助ブックマークレットex Firefox+dTa専用 by fashi2

  • //
    // @title DQX 思い出アルバム保存補助ブックマークレットex Firefox+dTa専用 by fashi2
    // @description DQ10 冒険者の広場 思い出アルバム(画像が9個並んでるとこ)でブックマークレットを実行してファイル名付きリンク生成 →DownThemAll!でフィルターを /smpic.*xl/ に、命名規則を *text*.jpg に変えてから保存。 /  説明とか http://vp.star-wind.info/dqx/
    // @include https://hiroba.dqx.jp/sc/character/*/picture/
    // @license MIT License
    // @require 
    //
    
    (function(){
    	var datetype = 1;
    	var callbacks=[],i=0;
    	if (!localStorage['dahe']){prompt('DownThemAll!のフィルタ指定は以下の文字列を設定してください','/smpic.*xl/');localStorage.setItem('dahe',1);}
    	var charaName = $('#myCharacterName').text();
    	$('td.contentsTable1TD1').each(function(){
    		var $this = $(this);
    		callbacks.push((function(){
    			return function() {
    				var d = $.Deferred();
    				setTimeout(function() {
    					var showLargePict = $this.find('a.showLargePict');
    					var rel = showLargePict.attr('rel');
    					var p = rel.match(/(\d+)\/picture\/detail\/(\d+)/);
    					var url = (p && p.length == 3) ? 'http://img.dqx.jp/smpicture/download/webpicture/' + p[1] + '/xl/' + p[2] + '/?dl' : '';
    					var comment = showLargePict.attr('title') ? ' 『' + showLargePict.attr('title') + '』' : '';
    					var lockicons = $this.find('div.lockIcon');
    					var lockicon = lockicons[0] ? ' !LOCKED!' : '';
    					var thumbLocationAndDate = $this.find('p.thumbLocationAndDate');
    					var dateAndLocation = thumbLocationAndDate.html().split('<br>');
    					var date = dateAndLocation && dateAndLocation[0] || '';
    					var location = dateAndLocation && dateAndLocation[1] || '';
    					$.get(rel,function(data){
    						var dateAndLocationDetail = $(data).find('#pictureDetailLocationAndDate').html().split('<br>');
    						location = dateAndLocationDetail && dateAndLocationDetail[1] || location;
    						if (datetype) {
    							dateobj = new Date(date);
    							date = localdate8(dateobj);
    						} else {
    							date = date.replace(/(\/|:)/g, '').replace(' ', '_');
    						}
    						location = location.replace(/[a-zA-Z0-9()]/g, function(s) { return String.fromCharCode(s.charCodeAt(0) - 65248);}).replace(/ /g,' ').replace(/<.+/g, "").replace(/[\x0D\x0A\x09]+/g,'');
    						var filterName = '';
    						var photoSettings_Filter = $(data).find('div.photo-settings ul li').eq(0).html().trim().split('&nbsp;');
    						console.log(photoSettings_Filter);
    						if ((photoSettings_Filter[1] !== undefined) && (photoSettings_Filter[1] != '(未設定)')){
    							filterName = ' '+photoSettings_Filter[1];
    						}
    						//var fileName = charaName + ' ' + p[2] + lockicon + comment + ' at ' + location + ' ' + date;
    						//var fileName = charaName + ' ' + date + ' 「' + location + '」(' + p[2] + ')' + comment + lockicon;
    						var fileName = 'DQX ' + date + ' ' + charaName + ' 「' + location + filterName + '」 (' + p[2] + ')' + comment + lockicon;
    						thumbLocationAndDate.append($('<br>'));
    						var link = $('<a>');
    						link.attr({
    							download: fileName + '.jpg',
    							href: url,
    						}).text(fileName).appendTo(thumbLocationAndDate);
    					}).done(function() {
    						d.resolve();
    					}).fail(function() {
    						d.reject();
    					});
    				},1500);
    				return d.promise();
    			};
    		})(i));
    		i++;
    	});
    	var dfd = $.Deferred();
    	dfd.resolve();
    	for (var i = 0; i < callbacks.length; i++) {
    		dfd = dfd.pipe(callbacks[i]);
    	}
    	function localdate8(dateobj){
    		dateobj.setHours(dateobj.getHours()-8);
    		return [
    			dateobj.getFullYear(),
    			('0' + (dateobj.getMonth() + 1)).slice(-2),
    			('0' + dateobj.getDate()).slice(-2)
    		].join('') + '_' + [
    			('0'+ (dateobj.getHours()+8)).slice(-2),
    			('0'+ dateobj.getMinutes()).slice(-2)
    		].join('');
    	}
    })();
    
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2018/05/30 23:24:44 - 2018-05-30
  2. 2018/05/30 21:46:25 - 2018-05-30
  3. 2017/07/08 21:37:21 - 2017-07-08
  4. 2017/07/08 15:17:19 - 2017-07-08
  5. 2015/12/25 01:12:29 - 2015-12-25
  6. 2014/03/19 05:43:05 - 2014-03-19
  7. 2014/03/19 04:39:59 - 2014-03-19
  8. 2014/03/14 19:25:00 - 2014-03-14
  9. 2014/03/14 19:23:58 - 2014-03-14
  10. 2014/03/13 19:11:30 - 2014-03-13