~/scriptsload-thread-by-likes

bookmarklet

לאוד גאנצע אשכול - פילטער לויט לייקס

Load a thread, filtered by likes

Loads a whole Ivelt thread and shows only the posts with the most likes, so you can skip to the most interesting ones.

  • working
  • works on ivelt.com
  • computer, Android, iPhone
לאוד גאנצע אשכול - פילטער לויט לייקס

Drag this button up to your bookmarks bar. That's the whole install.

Don't see a bookmarks bar? Press Ctrl+Shift+B (on a Mac ⌘+Shift+B).

Can't drag? , then add a new bookmark and paste it as the bookmark's address (URL).

Install on a phone

First tap Copy the bookmarklet above. Then:

Android (Chrome)

  1. Tap ⋮ and then ☆ to bookmark any page.
  2. Tap Edit, change the name to לאוד גאנצע אשכול - פילטער לויט לייקס, and replace the address with the copied text.
  3. To use it, go to the page, tap the address bar, type לאוד גאנצע אשכול - פילטער לויט לייקס, and tap the bookmark in the suggestions.

iPhone (Safari)

  1. Tap the share button and choose Add Bookmark, then save.
  2. Open Bookmarks, tap Edit, tap the new bookmark, and replace the address with the copied text.
  3. To use it, go to the page, open Bookmarks, and tap it.

Made because someone on Ivelt asked for a way to see only the “highly liked” posts in a long thread.

How to use it

  1. Open any page of an Ivelt thread.
  2. Click the bookmark. It loads all the pages and keeps only the posts with enough likes.

Not working, or have an idea for it? Tell me.

Links

Source code

Show it here

(function($) {
    $(document).ready(function() {
        var lastPage = parseInt($('.pagination li:not(.next):last').text(), 10);
        var on_page = parseInt($('.pagination li.active:first').text(), 10);
        var baseUrl = document.URL.replace(/&start=\d*/, '');

function loadPage(page) {
    if (page <= lastPage) {
        $('#loading-page').css('text-transform', 'none').text('Loading page ' + page);
        loadNextPage(page);
    } else {
        $('#loaded-pages').css('text-transform', 'none').text('Loaded pages from ' + on_page + ' to ' + lastPage);
        // Remove the other two messages
        $('#loading-info').remove();
        $('#loading-page').remove();

        // Remove pagination bar
        $('.pagination').remove();
        
        // Prompt the user for the threshold value
        var threshold = prompt("Posts that have more than how many likes do you want to see?");
        
        // Convert the threshold value to an integer
        threshold = parseInt(threshold, 10);

        // Check if the threshold is a valid number
        if (!isNaN(threshold)) {
            // Filter posts based on the threshold value and remove them if they don't meet the criteria
            $('.post').has('.postlove-li .postlove-count').filter(function() {
                var value = parseInt($(this).find('.postlove-count').text(), 10);
                return isNaN(value) || value <= threshold;
            }).remove();
            
            // Remove all divs with IDs post_advs or post_advs2
            $('#post_advs, #post_advs2').remove();
        } else {
            // Display an error message if the input is not a valid number
            alert("Invalid input. Please enter a valid number.");
        }
    }
}

        function loadNextPage(page) {
            $.ajax({
                url: baseUrl + '&start=' + (page * 25),
                success: function(data) {
                    $('.post:last').after($('.post', data));
                    loadPage(page + 1);
                },
                error: function(xhr, status, error) {
                    console.error('Error loading page:', error);
                    // Handle error gracefully (e.g., display an error message)
                }
            });
        }

        lastPage = Math.max(on_page, Math.min(lastPage, parseInt(prompt('You are on page ' + on_page + ' of ' + lastPage + ' pages.\r\nTill which page do you want to print?', lastPage), 10)));

$('#page-body').before($('<span id="loading-info">').append(
    $('<h4>').css({'text-align': 'center', 'font-size': '18px', 'color': '#0787c7'})
    .text('Loading pages from ' + on_page + ' to ' + lastPage).append('<br>').append('<span id="loading-line">'))
);        $('#loading-info').after($('<h4>').css({'text-align': 'center', 'font-size': '18px', 'color': '#0787c7'}).text('').append('<span id="loading-page">'));
        $('#loading-page').after($('<h4>').css({'text-align': 'center', 'font-size': '18px', 'color': '#4BB543'}).text('').append('<span class="loaded-message" id="loaded-pages">'));
        loadPage(on_page);
    });
})(jQuery);

Free to use, share and change (MIT license).