Greasy Fork

Greasy Fork is available in English.

京东到家商家运营 - 活动页优化

try to take over the world!

当前为 2019-08-07 提交的版本,查看 最新版本

// ==UserScript==
// @name         京东到家商家运营 - 活动页优化
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  try to take over the world!
// @author       You
// @match        http://*.jddj.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';



	// 添加优化配置按钮
    var addBtn1 = '<div style="position: fixed;bottom: 0;right: 0;z-index: 1000"><button id="wei_open" class="btn btn-xs btn-info prevActButton">展开模式</button> <button id="wei_close" class="btn btn-xs btn-info prevActButton">收起模式</button></div>'
	$('.resTabNav').append(addBtn1);
	$('#wei_open').show();
	$('#wei_close').hide();

	// 打开
	$('#wei_open').on('click', function () {
		$('#wei_open').hide();
		$('#wei_close').show();

		// 展开样式
		$($($($('.container-fluid')[1]).children()[0]).children()[1]).css({
			'position': 'fixed',
			'right': '0',
			'top': '0',
			'height': '100%',
			'box-shadow': '0 0 5px #000',
			'background-color': '#fff',
			'z-index': '999',
		});
		$('#resListTab').css({'height': '800px', 'overflow': 'auto'});
		$('.condition-panel').css({'max-height': '800px'});
		// $('.orgRes').css({'max-height': '720px!important'});
		$('.orgBtnGroupNal').children().removeClass('orgRes');
		$('.orgStoreDiv').css({'max-height': 'max-content'});

		$('.orgGroup').css({'border-bottom': '5px solid #428bca'});

		$('.saveBtnDiv').css({'position': 'absolute', 'bottom': '0'});


		$('#resListTab').scroll(function() {
			$('.orgGroup').each(function (i) {
				if ($(this).offset().top < (50 + i * 32)) {
					$(this).find('div:first').css({
						'position': 'absolute',
						'top': i * 32,
						'width': '100%',
						'left': '0',
						'padding': '5px 5px 0 5px',
						'border-bottom': '1px solid #c5d0dc',
						'background-color': '#fff',
					})
				} else {
					$(this).find('div:first').css({
						'position': '',
						'top': '',
						'width': '',
						'left': '',
						'padding': '',
						'border-bottom': '',
						'background-color': '',
					})
				}
			})
		});


		// 表格第一列缩小
		$('.orgStoreDiv').find('thead tr th:first').css({'width': '70px'})
		// $('.orgStoreDiv').find('tbody img').css({'width': '40px'})
		// $('.orgStoreDiv').find('tbody tr td:nth-child(2)').css({
		$(":input[name='skuDesc']").css({
			'height': '24px',
			'font-size': '12px',
			'color': '#03A9F4',
		});
		$(":input[name='skuTopDesc']").css({
			'height': '24px',
			'font-size': '12px',
			'color': '#03A9F4',
		});
		$(":input[name='skuName']").css({
			'height': '24px',
			'font-size': '12px',
			'color': '#03A9F4',
		});


		// 添加遮罩
		var mask = '<div id="awei_mask" style="position: fixed;left: 0;top: 0;width: 100%;height: 100vh;background: rgba(0,0,0,.2);z-index: 998;"></div>';
		$($('.container-fluid')[1]).append(mask);

		// 遮罩点击事件 - 关闭遮罩/恢复配置
		$('#awei_mask, #wei_close').on('click', function () {
			$('#wei_open').show();
			$('#wei_close').hide();

			$($($($('.container-fluid')[1]).children()[0]).children()[1]).css({
				'position': 'initial',
				'right': '0px',
				'top': '0px',
				'height': 'auto',
				'box-shadow': 'none',
				'background-color': 'rgba(0,0,0,0)',
				'z-index': 'initial',
			});
			$('#awei_mask').remove();
			$('#resListTab').css({'height': '', 'overflow': ''});
			$('.condition-panel').css({'max-height': ''});
			// $('.orgRes').css({'max-height': ''});
			$('.orgBtnGroupNal').children().addClass('orgRes');
			$('.orgStoreDiv').css({'max-height': ''});

			$('.orgGroup').css({'border-bottom': ''});

		});

	});

})();