您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Interface enhancements for DSA
当前为
// ==UserScript== // @name DSA Interface // @namespace COMDSPDSA // @version 20 // @description Interface enhancements for DSA // @author Dan Overlander // @include http://sales.dell.com/* // @include *preol.dell.com* // @include *http://localhost:36865* // @include *http://localhost:36158* // @include *localhost.dell.com:5000* // @include *online-sales-ux-* // @exclude */swagger/* // @require https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js // @require https://greasyfork.org/scripts/23115-tampermonkey-support-library/code/Tampermonkey%20Support%20Library.js?version=713223 // @require https://greasyfork.org/scripts/383641-aria-favlets/code/ARIA%20Favlets.js?version=702363 // @require https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore-min.js // @grant GM_setValue // @grant GM_getValue // ==/UserScript== // Since v19.5: Tweaks for Partner app. Added global scan to log multiple (identical) IDs and missing ARIA properties on some elements. Favorites for PartnerUX saved as string-objects. Updated accessibility icon. // Since v19.4: Added ARIA check button. May move it out to a separate script. // Since v19.3: Merged the functionality of the DSA-Menu "DSA Plugin" choice with that of the now-global battery icon. // Since v19.2: Removing errant console.log. Moving setTamperIcon to tamperLibrary // Since v19.1: Enhanced homepage link algorhythm // Since v19: Bug Fixes. Colored favorites in partner favorites. // Since v18: Renamed Import "Emailed Cart" to Import "eQuote" in main navigation. Added Partner UI homepage tweaks. // Sinve v17: Tweaked app-controls to make them appear more centered. // Since v16: Included the customer bar resizing css within the preferences-regulated gate. Tweaked it. // Since v15: added hiding the walkme stuff to the options panel (apparently I did not know it was controlled via profile, first). Reduced timeout; feels more pleasant, but must test in case it kills performance. Adjusted config page title compressed Y value // Since v14: bugfix: Adjusted customer-ribbon button y-position on orderReview and orderDetails. Created localStorage prefs // Since v13: Fixed a smry-ctnr CSS bug // Since v12: Modernized trigger elements. fixed the customer ribbon compression // Since v11: Hid the walkme stuff // Since v10: Re-added group alternating background colors // Since v09: activates compression on scroll // Since v08: Renamed // Since v07: Includes G1, Prod // Since v06: Tweaks to homepage // Since v05: Fixes (again) the create-quote icon // Adds customer-dashboard icon // Since v04: Added more of my own customers to the highlight-in-red list // Since v03: Tweaking homepage column title area // Since v02: updating tm support library. Changing the elements the script waits for on initialization // Since v01: homepage search fields right-aligned in title rows // : doesn't swap col-4 for col-6 except on homepage // : COMMENTED OUT : customer ribbon compressed /* * tm is an object included via @require from DorkForce's Tampermonkey Assist script */ (function() { 'use strict'; var TIMEOUT = 250, global = { scriptName: 'DSA Interface', prefs: undefined, prefsName: 'uiPrefs', mems: global != null ? global.mems : {}, // memsName: 'uiMems', // currently no need to actually save these ?? triggerElements: ['.icon-ui-dell', '.dds__container'], isMouseMoved: false, areClassesAdded: false, partnerClassesAdded: false, areAlertsAdded: false, isResetting: undefined, hpCompressed: false }, page = { initialize: function () { setTimeout(function () { page.setPrefs(); //page.setMems(); // currently no need to actually save these ?? page.addClasses(); tm.setTamperIcon(global); tm.checkNotes(global); page.addHighlights(); page.compression(); page.alternatingColors(); page.adjustPartnerUI(); page.analyzeDOM(); }, TIMEOUT); }, setPrefs: function () { var currentPrefs = GM_getValue(global.prefsName); if (currentPrefs == null || _.isEmpty(JSON.parse(currentPrefs))) { global.prefs = { debugMode: 'false', partnerQuotes: [{ gEnv: 'g2', qNum: '3000000673889' }, { gEnv: 'g4', qNum: '3001013340007' }, { gEnv: 'g4', qNum: '3001013337136' }, { gEnv: 'g4', qNum: '3001013344819' }], partnerOffers: [{ gEnv: 'g2', country: 'fr', language: 'fr', offerNum: '13045689', version: '1', orgId: '328' }, { gEnv: 'g2', country: 'au', language: 'en', offerNum: '50115674', version: '0', orgId: '376' }, { gEnv: 'g2', country: 'de', language: 'de', offerNum: '25058237', version: '1', orgId: '323' }, { gEnv: 'g2', country: 'cn', language: 'zh', offerNum: '50119688', version: '1', orgId: '374' }], hiliteInYourCustomers: '[04], [08], RETAIL', hiliteColor: 'red', compressUi: 'false', hideWalkme: 'false' }; global.prefs.partnerQuotes = JSON.stringify(global.prefs.partnerQuotes).replace(/(\r\n\t|\n|\r\t)/gm,'').replace(/"/gm, '\''); global.prefs.partnerOffers = JSON.stringify(global.prefs.partnerOffers).replace(/(\r\n\t|\n|\r\t)/gm,'').replace(/"/gm, '\''); tm.savePreferences(global.prefsName, global.prefs); } else { global.prefs = JSON.parse(currentPrefs); } }, // setMems: function () { // currently no need to actually save these ?? // var currentMems = GM_getValue(global.memsName); // if (currentMems == null || _.isEmpty(JSON.parse(currentMems))) { // global.mems = { // dupedIds: [] // }; // tm.savePreferences(global.memsName, global.mems); // } else { // global.prefs = JSON.parse(currentMems); // } // }, addClasses: function () { if (!global.areClassesAdded) { global.areClassesAdded = true; tm.addGlobalStyle('.cust-list-blk:hover {background-color: cornsilk}'); tm.addGlobalStyle('.home-sections .dotted {margin-top:3px; margin-bottom:3px;'); tm.addGlobalStyle('.home-sections .actv-block {padding-bottom:0;'); tm.addGlobalStyle('.singleActivity:hover {background-color: cornsilk;}'); tm.addGlobalStyle('.usertag {background-color: greenyellow;}'); // homepage column headers tm.addGlobalStyle('.home-col-hdr h3 { font-size:1.3em; font-weight:bold; padding-top:3px; }'); // homepage search section tm.addGlobalStyle('#home_search_container { margin-bottom: 0px; }'); tm.addGlobalStyle('#home_search_value { height: 30px; }'); tm.addGlobalStyle('#duplicate-po h3 { float: left; width: 200px; }'); tm.addGlobalStyle('#search_type_label { float: left; width: 110px; position: relative; top: 5px !important; }'); tm.addGlobalStyle('#search { float: left; width: 480px; padding: 0px !important; margin: 0px !important; }'); tm.addGlobalStyle('#search .input-search { position: initial !important; width: 100% !important; }'); // customer ribbon if (global.prefs.compressUi === 'true') { tm.addGlobalStyle('.app-nav {margin-top: 0;}'); tm.addGlobalStyle('.app-nav .app-title { padding-top:0; font-size:16px; line-height:1.1; }'); tm.addGlobalStyle('.current-business-unit { position:relative; top:-7px; }'); } // hide Walk Me Through crap if (global.prefs.hideWalkme === 'true') { tm.addGlobalStyle('#walkme-player, .walkme-custom-icon-outer-div { display: none !important; }'); } // ARIA button tm.addGlobalStyle('.ariaButton {position:fixed; z-index:999999999; bottom:0px; right:40px; left:unset; content: url("https://www.dorkforce.com/dsa/preferences-desktop-accessibility-icon.png"); width:16px; height:16px;}'); } }, analyzeDOM: function() { //////////////////////////////////////////////////////////////////////////////////// // 1. Check for DUPLICATE ID VIOLATIONS var idList = global.mems.dupedIds || []; var initCount = idList.length; var logMessage = ''; $('[id]').each(function(){ // scan for exact duplicates var ids = $('[id="'+this.id+'"]'); if(ids.length>1 && ids[0]==this) { if (idList.indexOf(this.id) < 0) { idList.push(this.id); } } }); if (idList.length != initCount) { initCount = idList.length; var logIt = ''; _.each(idList, (thisId) => { logIt += thisId + ', '; }); logIt = logIt.trim().replace(/(^,)|(,$)/g, ''); logMessage = 'Duplicate IDs found: ' + logIt; if (global.prefs.debugMode === 'true') tm.log(logMessage); tm.addNote(global, logMessage); } global.mems.dupedIds = idList; //////////////////////////////////////////////////////////////////////////////////// // 2. Check for Possible Badly-formed ID's var suspiciousIds = []; $('[id]').each(function(){ if (this.id.match(/[0-9]{3,}/g) != null) { suspiciousIds.push(this.id); } }); if (suspiciousIds.length > 0) { logIt = '' _.each(suspiciousIds, (thisId) => { logIt += thisId + ', '; }); logIt = logIt.trim().replace(/(^,)|(,$)/g, ''); logMessage = 'Possibly Bad IDs: ' + logIt if (global.prefs.debugMode === 'true') tm.log(logMessage); tm.addNote(global, logMessage); } //////////////////////////////////////////////////////////////////////////////////// // 3. Check for missing ARIA properties on BUTTONS var elementsLackingAria = []; $('button').each(function(){ if (this.outerHTML.indexOf('aria-label') < 0) { if (this.id != null && this.id != '') { elementsLackingAria.push('#' + this.id); } else { elementsLackingAria.push('.' + this.className); } } }); if (elementsLackingAria.length > 0) { logIt = '' _.each(elementsLackingAria, (thisId) => { logIt += thisId + ', '; }); logIt = logIt.trim().replace(/(^,)|(,$)/g, ''); logMessage = 'Buttons lacking aria-label: ' + logIt if (global.prefs.debugMode === 'true') tm.log(logMessage); tm.addNote(global, logMessage); } //////////////////////////////////////////////////////////////////////////////////// // 4. Check for missing ARIA properties on H- tags elementsLackingAria = []; $(':header').each(function(){ if (this.outerHTML.indexOf('aria-label') < 0) { if (this.id != null && this.id != '') { elementsLackingAria.push('#' + this.id); } else if (this.className != null && this.className != '') { elementsLackingAria.push('.' + this.className); } else { elementsLackingAria.push('"' + this.innerText + '"'); } } }); if (elementsLackingAria.length > 0) { logIt = '' _.each(elementsLackingAria, (thisId) => { logIt += thisId + ', '; }); logIt = logIt.trim().replace(/(^,)|(,$)/g, ''); logMessage = 'Headers lacking aria-label: ' + logIt if (global.prefs.debugMode === 'true') tm.log(logMessage); tm.addNote(global, logMessage); } }, adjustPartnerUI: function () { if (global.prefs.debugMode === 'true') { if($('.tamperlabel').length > 0 && $('.ariaButton').length === 0) { $('.tamperlabel').before('<span class="ariaButton"></span>'); } tm.getContainer({ 'el': '.ariaButton' }).then(function($container){ $('.ariaButton').css('cursor', 'pointer').unbind('click').on('click', function () { ariaCheck.start(document); // TODO: finish as it doesn't seem to walk the entire dom }); }); } var verboseEnv = function(env) { switch(env) { case('g4'): return 'ge4-sit'; case('g3'): return 'ge3-sit'; case('g2'): return 'ge2-sit'; default: return 'ge1-sit'; } } if ($('.channel-header').length > 0 && !global.partnerClassesAdded) { global.partnerClassesAdded = true; tm.addGlobalStyle('.popupDetailWindow { position:fixed !important; }'); } // hide the default popup Close because for some weird reason it's not working $('.popupDetailContent.fingery').hide(); // localize vars var faves = global.prefs.partnerQuotes != null ? JSON.parse(global.prefs.partnerQuotes.replace(/'/gm, '"')) : []; var offers = global.prefs.partnerOffers != null ? JSON.parse(global.prefs.partnerOffers.replace(/'/gm, '"')) : []; // modify logo var getUrl = window.location; var baseUrl = getUrl.protocol + "//" + getUrl.host + "/" + getUrl.pathname.split('/')[1]; if (baseUrl.indexOf('online-sales') < 0) { baseUrl = 'https://localhost.dell.com:5000/'; } $('.dds__msthd-dell-icon').prop('href', baseUrl).css('color', 'yellow'); // add favorites if ($('#myQuotes').length === 0) { $('#DSAHomePage').append('<H4 id="myQuotes" aria-label="My Favorite Quotes">My Favorite Quotes</H4>'); _.each(faves, function(fave) { $('#DSAHomePage').append('<div class="aFavoriteQuote">' + ' <a href="http://' + fave.gEnv + 'vmoscux01.olqa.preol.dell.com/solutions/Configurator/api/QuoteCheckout/v1/amer/CheckUserHasQuoteCheckoutAccess/' + fave.qNum + '/1/oscpartner1%40fourkites.com" target="blank">Verify</a>' + ' | ' + ' <a href="https://online-sales-ux-' + verboseEnv(fave.gEnv) + '.ausvdc02.pcf.dell.com/quotes/' + fave.qNum + '/1" target="blank">Partner ' + fave.gEnv + '</a>' + ' | ' + ' <a href="https://online-sales-ux-dev.ausvdc02.pcf.dell.com/quotes/' + fave.qNum + '" target="blank">Partner DEV</a>' + ' | ' + ' <a href="http://' + fave.gEnv + 'vmcomux01.olqa.preol.dell.com/#/quote/details/QuoteNumber/' + fave.qNum + '" target="blank">DSA ' + fave.gEnv + '</a>' + ' | ' + ' <a href="/us/en/quotes/' + fave.qNum + '/1">' + fave.qNum + '.1</a>' + '</div>'); }); $('#DSAHomePage').append('<div style="margin-top:10px;"> </div>'); _.each(offers, function(offer) { $('#DSAHomePage').append('<div class="aFavoriteQuote">' + ' <a href="https://online-sales-ux-' + verboseEnv(offer.gEnv) + '.ausvdc02.pcf.dell.com/salesapp/' + offer.country + '/' + offer.language + '/offer/' + offer.offerNum + '/' + offer.version + '/' + offer.orgId + '" target="blank">Partner ' + offer.gEnv + '</a>' + ' | ' + ' <a href="https://online-sales-ux-dev.ausvdc02.pcf.dell.com/salesapp/' + offer.country + '/' + offer.language + '/offer/' + offer.offerNum + '/' + offer.version + '/' + offer.orgId + '" target="blank">Partner DEV</a>' + ' | ' + ' <a href="/salesapp/' + offer.country + '/' + offer.language + '/offer/' + offer.offerNum + '/' + offer.version + '/' + offer.orgId + '">' + offer.offerNum + ' (' + offer.country + ')</a>' + '</div>'); }); } }, addHighlights: function () { var hiArray = global.prefs.hiliteInYourCustomers != null ? global.prefs.hiliteInYourCustomers.replace(/ */g, '').split(','): []; _.each(hiArray, function(hilite) { $('.cust-list-blk a:contains("' + hilite + '")').css('color', global.prefs.hiliteColor); $('.aFavoriteQuote a:contains("' + hilite + '")').css('color', global.prefs.hiliteColor); }); }, compression: function () { if (!global.hpCompressed && global.prefs.compressUi === 'true') { //global.hpCompressed = true; // config page floating title $('.fixed-position-container').css({'top': '106px'}); // Column: Your Customers $('.cust-list-blk').css({'height': '22px', 'font-size': '.8em', 'overflow': 'hidden'}); $('.icon-small-favorite-100').css({'height': '9px', 'width': '9px', 'background-position': '-287px -46px'}); $('.icon-small-favorite-0').css({'height': '9px', 'width': '9px', 'background-position': '-286px -137px'}); $('.remove-record').css({'top': '-3px', 'position': 'relative', 'height': '20px'}); $('.cust-list-blk a:contains(Create Quote)').css({'position': 'relative', 'float': 'right', 'top': '-13px'}).html('<span class="remove-record leQuote" style="background-position:-46px -144px;"> </span>'); $('.cust-list-blk a:contains(View Dashboard)').css({'position': 'relative', 'float': 'right', 'top': '-13px'}).html('<span class="remove-record leDashboard" style="background-position:-47px -288px;"> </span>'); $('.input-search').prev().hide(); $('.input-search').css({'position': 'absolute', 'top': '0', 'left': '56%', 'width': '40%'}); $('#yourCustomersSection a').eq(0).prop('innerText', 'All'); // recent activity $('#homepageController_recentActivity_h').prop('innerText', 'Recent Activity'); $('#homepageController_recentActivity_h').parent().find('a').eq(0).prop('innerText', 'All'); $('.actv-type span:first-child').css('display', 'none'); $('.actv-type span:nth-child(2)').css('float', 'right'); $('#recentActivity_sortBy').parent().css({'position': 'absolute', 'top': '0', 'left': '57%', 'width': '40%'}); // hide last col if($('.remove-record').length > 0) { if ($('#main .col-md-4:nth-child(5)').length > 0) { $('#main .col-md-4:nth-child(5)').remove(); $('#main .col-md-4').toggleClass("col-md-4").toggleClass("col-md-6"); } } // hide title $('#home_recentActivity').parent().parent().hide(); // compress title bar $('.top-nav').css({'padding': '3px 0 0 0'}); $('#dellBrandLogo_goHomePage').css({'font-size': '35px', 'height': '35px'}); $('.main-nav').css({'min-height': '40px', 'margin-bottom': '10px', 'height': '40px'}); $('.view-nav-withoutribbon').css({'margin-top': '30px'}); $('.brand-title').css({'line-height': '35px'}); $('.content-shell .view-nav').css({'top': '40px'}); $('.brand').next().next().css({'position': 'relative', 'top': '-8px'}); if($('.remove-record').length === 0) { if($('.view-nav-withoutribbon').length > 0) { $('.content-area').css({'margin-top': '10px'}); } else { $('.content-area').css({'margin-top': '80px'}); // customer ribbon = 60px } } // customer ribbon $('.top-nav .container').css({'height': '37px'}); $('.content-shell .view-nav').css({'height': '40px', 'min-height': '40px'}); if ($('#orderReview_createOrder').length === 0 && $('#orderDetails_moreActions').length === 0) { $('.app-controls').parent().css({'top': '-5px'}); } else { $('.app-controls').parent().css({'top': '5px'}); } if ($('h2:contains("Service Tag")').length > 0) { $('.app-controls').css({'padding-top': '5px'}); if ($('h2:contains("Service Tag Groups")').length > 0) { //whyyyyy $('.app-controls').css({'padding-top': '10px'}); } } } }, alternatingColors: function () { $('.line-group:odd').css('background-color', 'rgba(0, 0, 0, 0.1)'); } }; /* * Global functions */ function initScript () { _.each(global.triggerElements, function (trigger) { tm.getContainer({ 'el': trigger, 'max': 100, 'spd': 1000 }).then(function($container){ page.initialize(); }); }); } initScript(); $(document).mousemove(function(e) { if (!global.isMouseMoved) { global.isMouseMoved = true; setTimeout(function() { global.isMouseMoved = false; }, TIMEOUT * 2); initScript(); } }); window.onresize = function(event) { initScript(); }; // TODO: verify that this isn't doubling efforts $(document).scroll(function() { page.compression(); page.alternatingColors(); }); })();