Yad2 accessibility improvements

Mark realtors red, and mark private apartments green, etc

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

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

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name     Yad2 accessibility improvements
// @include  https://*.yad2.co.il/*
// @grant    GM_addStyle
// @description Mark realtors red, and mark private apartments green, etc
// @run-at   document-start
// @namespace https://greasyfork.org/users/838639
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js
// @version 0.0.1.20230928104950
// ==/UserScript==

GM_addStyle ( `
    .updated_at .date {
        color: green;
        font-weight: bold;
    }
    .merchant_name {
        background: red;
    }
    .viewed_item {
        opacity: 0.75;
    }
` );

$(document).ready(function() {
    $('.main_content .main_title').each(function() {
        let link = $(this).html();
        let text = encodeURIComponent($(this).text());
        let url = `https://google.com/search?q=${text}`;
        $(this).contents().wrap(`<a href="${url}" target="_blank"></a>`);
    });
    $('.contact_seller_light_box').each(function() {
        let box = $(this);
        let button = $("<input type='button' value='WhatsApp'/>");
        $(this).append(button);
        button.on('click', function(e) {
            let name = $('.contact_seller_light_box .seller .name').text();
            let message = `שלום ${name}, שמי איגור. מתי אפשר לבוא לראות את הדירה?`;
            let phone = '972' + $('.contact_seller_light_box .phone_number').text().substring(1).replace('-', '');
            window.open(`whatsapp://send?phone=${encodeURIComponent(phone)}&text=${encodeURIComponent(message)}`);
        })
    });
});