MarktEnhancer

Usability fixes

2021/02/12のページです。最新版はこちら

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

You will need to install an extension such as Tampermonkey to install this script.

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         MarktEnhancer
// @namespace https://greasyfork.org/users/290665
// @version      1.1
// @description  Usability fixes
// @match        https://*.markt.de/*
// @grant    GM_addStyle
// @grant    GM_download
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js
// ==/UserScript==

addStyle();
const myVersion = GM_info.script.version;

var dlname;

$(function() {

    var phone = decPh($('#clsy-c-expose-phone-number').data('phone'));
    console.log("phone: ",$('#clsy-c-expose-phone-number').data('phone')," -> ",phone);

    if (phone.length) {
        phone = phone.replace(/\+ +/,'+');
        var url = phone.replace(/[ -]+/g,'');
        var search = phone.replace(/ +/g,'%20');
        //.html('<a href="tel:'+url+'">'+phone+'</a> [<a href="https://www.google.com/search?q='+search+'" target="_new">google</a>]');
    }
    var PHONE = phone;
    PHONE = PHONE.replace(/\+49/,'0').replace(/ \/ /,'-');


    var NAME = $('#clsy-c-expose-header').first().text();
    if ($('.clsy-c-userbox__profile-name').length) {
        NAME = $('.clsy-c-userbox__profile-name').text() + " - " + NAME;
    }
    NAME = NAME.replace(/[^\w-\(\)äöüß ]/ig,'').replace(/\b(scharfe?|neue?|[dw]ie|[wd]er|[wd]as|und|[dz]u|sie|in|add?resse|m[üu]e?nchen|geile?|aus|mega|service|original|100|(ph|f)otos?|top|private?)\b/ig,'').replace(/ +/g,' ').substring(0,64);

    dlname = NAME + ' - ' + PHONE;
    var dlArea = $('<div id="markt-enhancer"><button id="dlbutton">Download <b>'+dlname+'</b></button><div class="me-logo">MarktEnhancer '+myVersion+'</div><div class="dl-area"></div></div>');

    $('body').on('click', '#dlbutton', function(event) {
        console.log("Clicked download button!");
        start();
        event.stopPropagation();
        event.preventDefault();
    });

    $('#clsy-c-expose').append(dlArea);


});


function addStyle() {
    GM_addStyle(`
.download_error {
    color: white;
    background-color: #880010;
    padding: 1px 4px;
    border-radius: 2px;
    margin: 0px 4px;
}

.download_ok {
    color: white;
    background-color: #10a020;
    padding: 1px 4px;
    border-radius: 2px;
    margin: 0px 4px;
}

#markt-enhancer {
max-height: 150px;
overflow: auto;
background-color: rgb(140, 65, 92);
padding: 4px;
font-size: 10px;
position: absolute;
left: 180px;
top: 0px;
z-index: 10;
right: 180px;
color: white;
}
#markt-enhancer button {
background-color:#f39a00;
font-size:10px;
border:2px outset;
padding:4px;
float:right;
}
#markt-enhancer dl-area {
column-count: 2;
}
`);
}


function start() {
    var downloadlist = [];
    $('[data-fancybox]').each(function() {
        var link = $(this).attr('href');
        if (link.length) {
            downloadlist.push(link.replace(/(\d+)-F(\d+)\./,'$1-A$2.'));
        }
    });
    dlAll(dlname,downloadlist);
}

function dlAll(path,downloadlist) {

    var dialog = $('<div id="markt-enhancerdialog" title="Download to '+path+' ..."></div>').appendTo($('#markt-enhancer'));

    for (let URL of downloadlist) {
        var name = URL.replace(/.*\//,'');
        var file = path.replace(/[^\w-\(\) ]/g,'')+'/'+name;
        URL = URL.replace(/^\/\//,'https://');
        var line = $('<div class="RLDL" data-name="'+name+'">'+name+'</div>\n').appendTo(dialog);

        (function(url,filepath,filename,linediv) {
            console.log(url,filepath,filename,linediv);
            var dl = GM_download({
                url: url,
                name: filepath,
                saveAs: false,
                onerror: function(err){
                    $(linediv).append('<span class="download_error">ERROR: '+err.error+'<br>'+err.details+'</span>');
                },
                onload: function() {
                    $(linediv).append('<span class="download_ok">✓</span>');
                }
            });
        })(URL,file,name,line);

    }
}
function decPh(input) {
    return input.replace(/A/g,'8').replace(/B/g,'4').replace(/C/g,'7').replace(/D/g,'1').replace(/E/g,'9').replace(/F/g,'6').replace(/G/g,'0').replace(/H/g,'5').replace(/I/g,'3').replace(/J/g,'2');
}