Yad2 accessibility improvements

Mark realtors red, and mark private apartments green, etc

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==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)}`);
        })
    });
});