Jump to content

So I created a view counter for floatplane.

Sirmyself

I created a purely Javascript solution to display a view counter during the wan show.

  • Run it in the console if you're confortable with that kind of thing.
  • The chat needs to be displayed within the page for the script to run properly.
  • And the "secondsToRefresh" value will be the number of seconds before the counter shows up. Then the number of seconds it takes before it refreshes (I liked it at 1 second of refresh period, but one could argue it's not necessary, so I set it to 10 by default.)

 

const secondsToRefresh = 10; //refreshes every 10 seconds, change value before running the script to refresh more or less often

function refreshList() {
	var btn = document.querySelectorAll(`.chat-view-container.chat-messages-container:not(.hide) .header-button.btn-user-list, .chat-view-container.chat-users-container:not(.hide) .header-button.btn-user-list.btn-return-to-chat`)[0]
	
	if (btn) {btn.click()};
}

window.setInterval(function() {
    var subTitle = document.getElementById("addedSh*t");
    if (!subTitle) {
        subTitle = document.createElement("div");
        subTitle = document.getElementsByClassName("video-title")[0].insertAdjacentElement("afterEnd", subTitle);
        subTitle.outerHTML = `<div class="video-title" id="addedSh*t">
    <span class="title-text" style="font-size:12px" id="viewCount">View count: test</span>
    </div>`;
    }

	refreshList();
    document.getElementById("viewCount").innerText = "View count: " + document.querySelectorAll(".chat-viewer-name.ng-star-inserted").length;
	refreshList();
    //console.log(document.querySelectorAll(".chat-viewer-name.ng-star-inserted").length);
}, secondsToRefresh * 1000);


image.png.434fc14007082f63b496ae5890629d48.png

Dear diary: Today was not tomorrow and not yesterday, which I think is nice...

//Overengineering example:

#include <iostream>
#include <string>

using namespace std;

int main()
{
  string s = "Hello World";
  for (int i = 0; i < s.length(); ++i)
  {
      cout << s[i];
  }
  return 0;
}

 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×