// ==UserScript== // @name InstaSynchP Wallcounter // @namespace InstaSynchP // @description Summarizes the lengths of each users video walls // @version 1 // @author Zod- // @source https://github.com/Zod-/InstaSynchP-Wallcounter // @license MIT // @include *://instasync.com/r/* // @include *://*.instasync.com/r/* // @grant none // @run-at document-start // @require https://greasyfork.org/scripts/5647-instasynchp-library/code/InstaSynchP%20Library.js?version=37716 // @downloadURL none // ==/UserScript== function Wallcounter(version) { "use strict"; this.version = version; this.name = 'InstaSynchP Wallcounter'; this.counter = {}; this.commands = { "'wallcounter": { 'hasArguments': true, 'reference': this, 'description': 'Summarizes the lengths of each users video walls or specific users', 'callback': this.execute } }; } Wallcounter.prototype.resetVariables = function () { "use strict"; this.counter = {}; }; Wallcounter.prototype.executeOnce = function () { "use strict"; var th = this; cssLoader.add({ 'name': 'wallcounter', 'url': 'https://cdn.rawgit.com/Zod-/InstaSynchP-Wallcounter/f234bce65b1fe913f13672cb8507dfa3dcf767d1/wallcounter.css', 'autoload': true }); function count(video, duration, inc) { var name = video.addedby.toLowerCase(); if (th.counter.hasOwnProperty(name)) { //update wallcounter th.counter[name].duration += duration; th.counter[name].count += inc; } else { //create wallcounter th.counter[name] = { duration: duration, count: 1, origName: video.addedby }; } //update own wallcounter if (name === thisUser().username.toLowerCase()) { $('#playlist_wallcounter').text( 'Wallcounter[{1} - {0}]'.format(th.counter[name].count, window.utils.secondsToTime(th.counter[name].duration)) ); } } events.on(th, "AddVideo", function (video) { count(video, video.duration, +1); }, true); events.on(th, "RemoveVideo", function (ignore, video) { count(video, -video.duration, -1); }, true); }; Wallcounter.prototype.preConnect = function () { "use strict"; //add own wallcounter below the playlist $('.playlist-stats').append( $('