VK Infinte Scroll Cleaner

Clear old part of posts after loading new one. Helps with memory problems on low spec PCs.

目前為 2017-01-10 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name           VK Infinte Scroll Cleaner
// @name:ru        VK Infinte Scroll Cleaner
// @namespace      http://vk.com
// @version        0.1.2b
// @description    Clear old part of posts after loading new one. Helps with memory problems on low spec PCs.
// @description:ru Удаляет старые посты при загрузке новых. Помогает с потрелбением ОЗУ на слабых ПК.
// @author         7KiLL
// @match          https://vk.com/*
// ==/UserScript==

(function() {
    'use strict';

    var wall;  //Posts selectors
    var count; //Number of posts
    //Number of posts is higher than actual by 2. Simple thing, but improves UX as well.
    //Favorites - 19/page
    //Feed - 11/page
    if(/fave/i.test(location.href)) {
        console.log('Fav detected');
       count = 21;
        wall = '.wall_posts.all ._post';
    }
    if(/feed/i.test(location.href)) {
        console.log('feed detected');
        count = 13;
        wall = '#feed_rows .feed_row';
    }
    setInterval(function(){
        var current = document.querySelectorAll(wall).length;
        if(current>count)
            clearFeed();
    }, 100);

    function clearFeed() {
        var len = document.querySelectorAll(wall).length;
        while(len > count) {
            document.querySelectorAll(wall)[0].remove();
            len = document.querySelectorAll(wall).length;
        }
        window.scrollTo(0, 350); //Average height of post. Skips first post of previous page that you have seen and probably
                                 //focus you on last one that you haven't seen fully.
    }
})();