您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Auto create item lists from wowhead.com comparisons, export dressing room sets to WoW Model Viewer
当前为
// ==UserScript== // @name Dressing Room // @description Auto create item lists from wowhead.com comparisons, export dressing room sets to WoW Model Viewer // @namespace http://mogboutique.tumblr.com/ // @author http://mogboutique.tumblr.com/ // @include http://*.wowhead.com/dressing-room* // @version 0.0.5 // @grant none // ==/UserScript== var my_character = { equipment: { 1: {}, 2: {}, 3: {}, 4: {}, 5: {}, 6: {}, 7: {}, 8: {}, 9: {}, 10: {}, 11: {}, 12: {}, 13: {} }, settings: { race: 1, gender: 1, "class": 5, specialization: 0, level: 100, skincolor: 0, hairstyle: 0, haircolor: 0, facetype: 0, features: 0, blindfolds: 0, hornstyle: 0, tattoos: 0, mount: 0, artifactAppearanceMod: 0 } }; var displaySlot = { //Head 1: 1, //Shoulders 3: 2, //Cloak 16: 3, //Chest 5: 4, //Shirt 4: 5, //Tabard 19: 6, //Wrists 9: 7, //Hands 10: 8, //Waist 6: 9, //Legs 7: 10, //Feet 8: 11, //Ranged 15: 12, //1-Hand 13: 12, //2-Hand 17: 12, //Shield 14: 13, //Off-Hand 23: 13 }; $('#main-precontents').after('<h2 class="heading-size-3" style="display:inline-block;">Paste MogIt links and WoWhead comparisons here</h2><a style="font-size:12px;margin-left:10px;" href="http://mogboutique.tumblr.com/post/140277708518/dressing-room-import-script">Update Script</a><input id="comp_src" style="height:25px;border:1px solid gray;color:gray;background:rgba(255,255,255,.05);width:90%;"></input><button id="comp_click">Import</button>'); var summary = null; var bonuses = {}; $('#comp_click').click(function() { var src = $('#comp_src').val(); $.get( src, function( data ) { g_match = data.match(/(g_items.add.+)/g); s_match = data.match(/new Summary(\(.+)/); if( s_match.length > 1 ){ var s = eval(s_match[1]); summary = s.groups[0]; } for( var p in g_match ){ eval( g_match[p] ); } for( var i =0;i<summary.length;i++ ){ bonuses[summary[i][0]]=0; if( summary[i][10] ) bonuses[summary[i][0]]=summary[i][10]; } comparison(); }); }); function comparison() { for (var propt in bonuses ) { if (g_items[propt].jsonequip) { var dslot = displaySlot[g_items[propt].jsonequip.slot]; if (dslot) { if (dslot == 12) if (displaySlot[my_character.equipment[12].charSlot] == 12) if (!my_character.equipment[13].itemId) { for (var p in my_character.equipment[12]) my_character.equipment[13][p] = my_character.equipment[12][p]; } my_character.equipment[dslot].itemId = g_items[propt].jsonequip.id; my_character.equipment[dslot].charSlot = g_items[propt].jsonequip.slot; my_character.equipment[dslot].itemBonus = bonuses[propt]; } } } if (g_items) { var last = localStorage.getItem("lastViewedModel"); var model = eval(last); var settings = model[model.length - 1]; my_character.settings = settings; DressingRoom.updateFromHash(my_character); $('#comparison').off('load'); $('#comparison').remove(); location.reload(); } } /***************WoW Model Viewer Export*****************/ $('head').append('<style type="text/css" id="wmv_style">.dressing-room-controls-block.block-bg{display:none;}</style>'); $('div.dressing-room-controls-block').after('<div id="wmv_pad" style="margin-top:30px;" ><a id="wmv_init" class="fa" href="javascript:void(0);" style="text-align:center;display:block;border:1px solid;padding:8px;">WoW Model Viewer Export</a><div class="text_block" style="margin-top:10px;padding:10px;font-size:12px;">For users of <a href="https://wowmodelviewer.net/wordpress/?page_id=27">WoW Model Viewer</a>.<br>Pressing the button below will generate a code for a "character" file. Create an empty file with .chr extension, then paste the code into it. In WoW Model Viewer, select Character menu -> Load Character -> Select your file. Current set will be imported. Alternatively, you can <b style="color:red;">download a file provided below the box.</b><br>For updates/bugs check <a href="http://mogboutique.tumblr.com/post/140277708518/dressing-room-import-script">this link.</a> <button class="generate_code" style="display:block;margin-top:10px;">Generate .CHR code</button></div><div class="code_block" style="margin-top:10px;padding:10px;font-size:12px;display:none;"></div></div>'); $('div.code_block').append("<a id='doll' class='fa' href='javascript:void(0);' style='font-size:12px;'>Show instructions</a><textarea id='wmv_export' style='width:90%;height:300px;font-size:10px;background:white;'></textarea><button class='generate_code'>Generate again</button><a id='download_file' download='my_character.chr' style='float:right;padding:6px 0px;' href='javascript:void:(0);'>Or download a file</a><div style='clear:both;'></div>"); $('button.generate_code').click(function() { $('div.code_block').show(); $('div.text_block').hide(); observeChanges(); exportWMV(); }); $('#doll').click(function() { $('div.code_block').hide(); $('div.text_block').show(); }); var ishd = [ 'human', 'draenei', 'dwarf', 'orc', 'gnome', 'nightelf', 'bloodelf', 'troll', 'undead' ]; var filename = "MyCharacter"; function exportWMV() { //Head $('div.paperdoll-left > div.iconmedium:first-child > a').attr('slot', 0); //Shoulders $('div.paperdoll-left > div.iconmedium:nth-child(3) > a').attr('slot', 1); //Cloak $('div.paperdoll-left > div.iconmedium:nth-child(4) > a').attr('slot', 11); //Chest $('div.paperdoll-left > div.iconmedium:nth-child(5) > a').attr('slot', 6); //Shirt $('div.paperdoll-left > div.iconmedium:nth-child(6) > a').attr('slot', 4); //Tabard $('div.paperdoll-left > div.iconmedium:nth-child(7) > a').attr('slot', 12); //Wrist $('div.paperdoll-left > div.iconmedium:nth-child(8) > a').attr('slot', 7); //Main Hand $('div.paperdoll-bottom > div.iconmedium:first-child > a').attr('slot', 9); //Off Hand $('div.paperdoll-bottom > div.iconmedium:nth-child(2)> a').attr('slot', 10); //Hands $('div.paperdoll-right > div.iconmedium:first-child > a').attr('slot', 8); //Waist $('div.paperdoll-right > div.iconmedium:nth-child(2)> a').attr('slot', 3); //legs $('div.paperdoll-right > div.iconmedium:nth-child(3)> a').attr('slot', 5); //feet $('div.paperdoll-right > div.iconmedium:nth-child(4)> a').attr('slot', 2); var last = localStorage.getItem("lastViewedModel"); var model = eval(last); var settings = model[model.length - 1]; var race = g_file_races[settings.race]; var gender = g_file_genders[settings.gender]; var hd = ""; if (ishd.indexOf(race) > -1) hd = "_hd"; var text = '<?xml version="1.0" encoding="UTF-8"?>\n' + ' <SavedCharacter version="1.0">\n' + ' <model>\n' + ' <file name="character\\' + race + '\\' + gender + '\\' + race + gender + hd + '.m2"/>\n' + ' <CharDetails>\n' + ' <skinColor value="' + settings.skincolor + '"/>\n' + ' <faceType value="' + settings.facetype + '"/>\n' + ' <hairColor value="' + settings.haircolor + '"/>\n' + ' <hairColor value="' + settings.haircolor + '"/>\n' + ' <hairStyle value="' + settings.hairstyle + '"/>\n' + ' <facialHair value="' + settings.features + '"/>\n' + ' <eyeGlowType value="1"/>\n' + ' <showUnderwear value="0"/>\n' + ' <showEars value="1"/>\n' + ' <showHair value="1"/>\n' + ' <showFacialHair value="1"/>\n' + ' <showFeet value="1"/>\n' + ' </CharDetails>\n' + ' </model>\n' + '<equipment>\n'; var e = {}; $('div#dressing-room-paperdoll a[slot]').each(function() { var href = $(this).attr('href'); if (href.match(/item=(\d+)/)) e[href.match(/item=(\d+)/)[1]] = $(this).attr('slot'); }); for (var p in e) { if (g_items[p].jsonequip) { var displayId = g_items[p].jsonequip.displayid; var id = p; var level = g_items[p].jsonequip.level; if (g_items[p].json) level = g_items[p].json.level; var slot = e[p]; //******************************* if (slot == 6 ) if( g_items[p].name_enus ) filename = g_items[p].name_enus; if (!displayId) displayId = -1; if (!id) id = -1; if (!level) level = -1; if (!slot) slot = -1; text = text + ' <item>\n' + ' <slot value="' + slot + '"/>\n' + ' <id value="' + id + '"/>\n' + ' <displayId value="' + displayId + '"/>\n' + ' <level value="' + level + '"/>\n' + ' </item>\n'; } } //for text = text + ' </equipment>\n' + ' </SavedCharacter>\n'; $('#wmv_export').val(text); var file_uri = 'data:text/xml;charset=utf-8,' + encodeURIComponent(text); $("#download_file").attr('href',file_uri); filename = filename.replace(/[^ \w]+/g,'_'); $("#download_file").attr('download',filename+".chr"); filename = "MyCharacter"; } var observer = null; var config = { attributes: true, childList: true, characterData: true, subtree: true }; function observeChanges(){ var target = $('table.listview-mode-default tbody.clickable')[0]; if(!observer) { observer = new MutationObserver(function(mutations) { exportWMV(); }); observer.observe(target, config); } }