Epey.com Favorilerim

Epey.com daki favori ürünlerinizi kategorize eder.

目前为 2020-12-31 提交的版本。查看 最新版本

// ==UserScript==
// @name         Epey.com Favorilerim
// @namespace    https://github.com/ilyasbilgihan
// @version      0.1
// @description  Epey.com daki favori ürünlerinizi kategorize eder.
// @author       @ilyasbilgihan
// @match        https://www.epey.com/uye/favorilerim/*
// @match        http://www.epey.com/uye/favorilerim/*
// @grant        GM_addStyle
// ==/UserScript==

(function() {
    'use strict';

    var counts = {};

    var items = document.querySelectorAll('#favorilerim li');
    items.forEach((item)=>{
        var category = item.querySelector('a').getAttribute('href').split('/')[3];
        var degisim = item.querySelector('.degisim');
        if(!degisim.classList.contains('dusus')){ // Bu kontrol yapılmazsa tüm favori ürünler kategorilere ayrılır.
            counts[category] = counts[category] || document.createElement('ul');
            counts[category].append(item);
        }

    });

    var cerceve = document.querySelector('.cerceve.cerceve');


    for (const [key, value] of Object.entries(counts)) {
        var h2 = document.createElement('div');
        h2.classList.add('cat-name');
        h2.innerHTML = '<h2>'+ key.split('-').join(' ') +' </h2> <span data-target="'+key+'" class="btn-open">Göster / Gizle</span>';
        
        value.classList.add('cat');
        value.classList.add('closed');
        value.classList.add(key);

        cerceve.append(h2);
        cerceve.append(value)
        value.style.maxHeight = value.offsetHeight + 100 + "px";
    }

    var buttons = document.querySelectorAll('.btn-open');
    buttons.forEach((button)=>{
        button.addEventListener('click', (e)=>{
            var target = e.target.getAttribute('data-target');
            var targetElement = document.querySelector('.cat.'+target);
            targetElement.classList.toggle('closed');

        });
    });

    GM_addStyle(`
        #fbaslik h1{font-size: 25px;}
        #fbaslik h1:after{content:" | (Fiyatı Düşenler)"; font-size: 14px; color: #2f9a30;}
        .btn-open { position: absolute; top: 0; right: 20px; cursor: pointer; user-select: none; }
        #favorilerim { min-height: 0; }
        .cat-name {
            margin: 20px 0 20px 10px;
            text-transform: Capitalize;
            min-width: 100%;
            float: left;
            position: relative;
        }
        .cat-name h2:after { content: " | (Fiyat düşüşü yok)"; font-size: 14px; color: red; }
        .cat{ transition: .4s all;  overflow: hidden; float:left;min-height:0;}.cat li{float:left;width:467px;height:125px;border:1px solid #e8dca8;margin:0 3px 4px;padding:5px;position:relative}.cat li span{margin:5px 0}.cat li .resim{float:left;text-align:center;text-align:center;width:120px;margin-right:15px}.cat li .adi{display:block;width:425px;font-size:13px}.cat li .adi a{font-size:15px;font-weight:700}.cat li .varyant{font-size:13px;font-weight:400}.cat li .fiyat{display:block}.cat li .fiyat span{float:left;width:140px;height:50px}.cat li .fiyat span strong{display:block;font-size:15px}.cat li .fiyat .arrow{width:50px;background:url(https://resim.epey.com/tema/arrow.png?v=2) no-repeat}.cat li .tarih{display:block;font-size:13px}.cat li .degisim{position:absolute;top:0;right:3px;width:24px;text-align:center}.cat li .artis{background:url(https://resim.epey.com/tema/artis.png?v=2) no-repeat top;padding:20px 0 0 0}.cat li .dusus{background:url(https://resim.epey.com/tema/dusus.png?v=2) no-repeat bottom;padding:0 0 20px 0}.cat li .sil{position:absolute;bottom:0;right:3px;width:24px;height:24px;text-align:center;background:url(https://resim.epey.com/tema/delete.png?v=1) no-repeat bottom;cursor:pointer}
        .cat.closed { max-height: 0px!important; transition: max-height 0.25s ease-in; }
    `);



})();