Auto reload Vivaldi Forum only when there is a new post or thread {AHK script}



  • For those that have installed AHK, this is a script to auto reload Vivaldi Forum only when there is a new post or thread:

    1c9b0e79-60a1-47c7-97d3-b7182e085415-image.png

    ; AUTO RELOAD VIVALDI FORUM 
    
    #Persistent
    SendMode Input
    
    target := "Home | Vivaldi Forum - Vivaldi", color := "0xD8D8D8"
    CoordMode, Pixel, Screen
    
    Loop
     
    {
     
    
     WinGetActiveTitle, active
     If active contains %target%
    
    {
         PixelGetColor, thisColor, 248, 311
          Sleep, 500
          If (thisColor = color)
          Send ^r
          Else
          Sleep, 1000
          }
     
    Sleep, 3000
    continue
    }
    
    

    You have to change the values of X and Y : 248 and 311, and the color 0xD8D8D8 according to your theme. The position and the color of one of the pixels of the text in "There are 3 new posts. Click here to reload"; or could be the color of the highlight if you don't use a theme:

    a9c67d5d-5beb-4e53-9353-e10480b9cd11-image.png

    Enjoy.



  • You’ve now pushed me to finally write this idea as old as the notice. Here’s the userJS to achieve the same (w/o userJS headers)

    (function(){
      let observers = [];
    
      function callback(mutationList, observer) {
        for (let mut of mutationList) {
          if (mut.type === "attributes" && mut.attributeName === "class") {
            if (mut.oldValue.split(" ").includes("hide")
                && !mut.target.className.split(" ").includes("hide")) {
              ajaxify.refresh();
            }
          }
        }
      }
    
      function watch() {
        for (let obs of observers) {
          obs.disconnect();
          let idx = observers.indexOf(obs);
          if (idx > -1)
            observers.splice(idx, 1);
        }
        let node = document.querySelector("#new-topics-alert");
        if (!node)
          return;
        let cfg = { attributes: true, attributeFilter: [ "class" ], attributeOldValue: true };
        let obs = new MutationObserver(callback);
        observers.push(obs);
        obs.observe(node, cfg);
      }
    
      window.addEventListener("load", () => {
        watch();
        // Have to use jQuery coz otherwise it doesn't work
        if (window.$)
          $(window).on('action:ajaxify.end', () => watch());
      });
    })();
    


  • @potmeklecbohdan You welcome.



  • @potmeklecbohdan Your UserJS works like a charm.

    It works in any page of Vivaldi Forum even though there is no "new-topics-alert" display?

    You have to open a new thread because my thread say {AHK script}, so many people could use it !!



  • @barbudo2005 said in Auto reload Vivaldi Forum only when there is a new post or thread {AHK script}:

    It works in any page of Vivaldi Forum even though there is no "new-topics-alert" display?

    It doesn’t. When you see a new post appear while you’re reading a thread, it’s a normal feature of the forum. #new-topics-alert is only in /unread (or maybe a few other pages).



  • @potmeklecbohdan

    If you have the Vivaldi Forum open and links open from it, the children auto reload if there is a new post.



  • @barbudo2005 Doesn’t happen for me, sorry.



  • @potmeklecbohdan

    Could you check over your userJS, because I think don't make a "complete" reload.

    I have a userJS to rename the tab and I use EzLinkPreview; and both don't work after an autoreload. I have to click the Reload button.

    Thank you in advance.



  • @barbudo2005 Replace that ajaxify.refresh with location.reload



  • @potmeklecbohdan Thank you very much.


Log in to reply
 

Looks like your connection to Vivaldi Forum was lost, please wait while we try to reconnect.