DoubleList Enhancer

Add Image Thumbnail Previews, throttled per link @1200ms

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         DoubleList Enhancer
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Add Image Thumbnail Previews, throttled per link @1200ms
// @author       Technoid
// @match        https://doublelist.com/city/*
// @icon         https://www.google.com/s2/favicons?domain=doublelist.com
// @grant        none
// ==/UserScript==

/* eslint-env jquery */
(function() {
    'use strict';

    setTimeout(function() {
        let matchnum = 0

        $("a.item").each(function( index ) {
            let a = $( this )
            //console.log( index + ": " + a.text() );
            a.parent().css("flex-wrap", "wrap")
            let url = a.attr("href")

            //console.log("a.item " + index)
            //console.log(url)
            if (url.match(/posts/) && a.find(".orn").length > 0) {
                setTimeout(function() {

                    $.ajax({
                        url: url,
                        cache: true,
                        success: function(response) {
                            //console.log("Ajax Success")
                            let thumbs = $(response).find(".gallery-thumbs .swiper-slide");
                            //let result = $(response).find("#mainpic");
                            //console.log(response); // works as expected (returns all html)

                            if (thumbs.length === 0) {
                              //console.log("No Pic Found")
                              return
                            }

                            let imgdiv = $("<div style='flex-basis: 100%;'></div>")
                            a.append(imgdiv)

                            thumbs.each(function(index2) {
                              let img = $(this)
                              let ohtml = img.prop("outerHTML")

                              if (!ohtml.match(/background-image/)) {
                                  //console.log("No Image Element found.")
                                  //console.log(ohtml)
                                  return;
                              }

                              console.log("Pic Found - appending html : " + ohtml); // returns [object Object]
                              let thumb = $(ohtml)
                              thumb.css("background-size", "cover");
                              thumb.css("background-position", "center")
                              thumb.css("height", "60px")
                              thumb.css("width", "60px")
                              thumb.css("display", "inline-block")
                              thumb.css("margin", "10px")
                              imgdiv.append(thumb)
                            })

                        },
                        error: function(error) {
                          console.log("Ajax Error")
                          console.log(error)
                        }
                    });
                }, 1200 * matchnum++);
            } else {
                //console.log("Not matched posts")
                return
            }

            //if (index > 3) return false;


        });

    }, 1500)
})();