1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// ==UserScript==
// @name         plurk Performance Optimization
// @namespace    https://www.plurk.com/Nathan8489
// @version      0.1
// @description  hidden unnecessary plurk
// @author       NOKO
// @match        https://www.plurk.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    var target = document.querySelector('#timeline_cnt>.block_cnt');
    if(!target){return;};
    var style = document.createElement('style');
    style.innerHTML = `
        @keyframes PerformanceOptimization{from{outline-color: #fff;}to{outline-color: #000;}}
        .plurk {animation-name: PerformanceOptimization;}
    `;
    document.head.append(style);

    var plurks=[];
    var requestId;
    var trigger = false;
    var callback = function(mutationsList, observer){
        if(requestId){cancelAnimationFrame(requestId);};
        requestAnimationFrame(function(){
            var show=[], hide=[];
            var plurk;
            var parentLeft = parseFloat(target.style.left)
            var innerWidth = window.innerWidth;
            for(plurk of plurks){
                var left = Math.abs( parseFloat(plurk.style.left)+parentLeft-(innerWidth/2) );
                if(left<innerWidth)
                {
                    show.push(plurk);
                }
                else if(left>innerWidth)
                {
                    hide.push(plurk);
                }
            }
            for(plurk of show){
                plurk.style.display = '';
            }
            for(plurk of hide){
                plurk.style.display = 'none';
            }
        });
    };
    var inject = function(e){
        if (e.animationName == 'PerformanceOptimization')
        {
            plurks.push(e.target);
        }
    }
    var observer = new MutationObserver(callback);
    observer.observe(target, {attributes : true, attributeFilter : ['style']});

    document.addEventListener('animationstart', inject, false);
})();