Wieso funktioniert meine "Browser Extension" nicht auf dieser Seite?

Mir ist unter Linux aufgefallen das ich gar nicht den Auto-Scroll von Windows habe in zb. Google Chrome wenn man auf das Mauspad klickt, nutze ich gerne und dachte mir als Challenge ohne Chat Gpt dass ich mal schnell probieren könnte ein eigenes zu programmieren.

Ich weiß da gibt es fertige Software und Extension's, die laufen ohne Probleme und Ressourcen sparender wahrscheinlich.

Hab das erst in einer Html Datei (Extension in "") gemacht zum testen dann in anderen Websites den JS Code in eine Konsole eingefügt und es funktioniert eigentlich ganz gut.

Das Problem ist das ich nicht verstehe wieso er nicht hier funktioniert https://www.tennon.io/ , mir fällt beim inspizieren nichts auf und es scheint mit Next JS umgesetzt zu sein.

<!DOCTYPE html>
<html lang="de">


<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Auto Scroll Extension</title>
    <style>
        html {
            min-width: 100%;
        }
    </style>
</head>


<body>
    <script>
        /* Render Dummy Content, cursor change wont work with min-height */
        for (let i = 0; i < 1000; i++) {
            document.body.innerHTML += "Lorem Ipsum ";
        }
        const scrollSpeed_Up = -1;
        const scrollSpeed_Down = 1;
        const middlehalf = window.innerHeight / 2;
        let AutoScroll_Interval; /* Global acess */
        let isScrolling = false;
        let isScrollingUp = false; /* Default Scrolling Down, Prevent Errors */


        const ToggleScrolling = Enable => {
            if (Enable) {
                console.log("Auto Scroll Active");
                document.body.style.cursor = "all-scroll";
                AutoScroll_Interval = setInterval(AutoScroll, 1);
                isScrolling = true; /* Prevent Multiple Interval's */
            } else if (!Enable && isScrolling) {
                /* Stop Interval , Reset Cursor and Variables */
                console.log("Auto Scroll Stopped");
                document.body.style.cursor = "auto";
                clearInterval(AutoScroll_Interval);
                isScrolling = false;
            }
        }


        const AutoScroll = () => {
            /* Get Current Vertical Scroll Position : console.log(window.scrollY); */
            isScrollingUp ? window.scrollBy(0, scrollSpeed_Up) : window.scrollBy(0, scrollSpeed_Down);
        }


        window.addEventListener("mousemove", e => {
            e.clientY > middlehalf ? isScrollingUp = false : isScrollingUp = true;
        });


        /* Check if Scroll Button is Pressed */
        window.addEventListener("mousedown", e => {
            e.button === 1 && !isScrolling ? ToggleScrolling(true) : ToggleScrolling(false);
        });


        /* ############## IGNORE ##############
        Check if Client has reached Bottom
        const scrollableHeight = document.documentElement.scrollHeight - window.innerHeight;
        if (window.scrollY >= scrollableHeight) { 
            // Reached Bottom Code ... 
        } else {
            // Code ...
        }
        */
    </script>
</body>


</html>
Browser, Linux, HTML, IT, Webseite, JavaScript, Ubuntu, HTML5, Informatik, Programmiersprache, Webentwicklung, Frontend, React, node.js, React Native
C# Programm das gerecht Verteilen kann?

Hallo Leute, ich hoffe euch geht's gut.

Ich bin noch ziemlich neu hier und auch in der Welt von C# nicht gerade der Profi, aber ich liebe es, in meiner Freizeit zu programmieren.

Vor ein paar Wochen habe ich mit C# angefangen und arbeite jetzt an einem Projekt für eine App. Ich tüftle an einem Programm, das verschiedene Dinge (zum Beispiel 3 Tomaten, 4 Bananen und 6 Äpfel) gerecht auf eine festgelegte Anzahl von Tüten verteilt (sagen wir 3 Tüten).

Die Gesamtanzahl jeder Obstsorte und die Gesamtanzahl der Dinge insgesamt dürfen sich höchstens um eins unterscheiden, damit es für jede Tüte so fair wie möglich bleibt.

Mein Ansatz ist, eine Liste von Integer-Arrays zu erstellen, die ich

bags
nennen würde.

Jeder Teil dieser Liste würde dann ein Integer-Array beinhalten, in dem die Gegenstände für jede Tüte gespeichert werden.

Versteht ihr, worauf ich hinauswill? Ich könnte echt eure Hilfe gebrauchen und wäre dankbar für eure Gedanken dazu, wie ich am besten vorgehen sollte. Sollte ich die Anzahl der Dinge teilen oder wie würdet ihr das angehen? Bin gespannt auf eure Vorschläge! Danke schon mal im Voraus.

Mein C# Code Ansatz:

// Online C# Editor for free
// Write, Edit and Run your C# code using C# Online Compiler

using System;

public class HelloWorld
{
  public static void Main() 
  {
    double[] objects = new double[]{4,4,2};
    Pack(objects, 3);
  }
   
  public static void Pack(double[] things, int numBags)
  {
    double[] results = new double[]{0,0,0};
    double[] sumUp = new double[]{0,0,0};
     
    for(int i = 0; i < things.Length; i++) 
    {
      double current = things[i] / numBags;
      double nextnumber = (double)Math.Floor(current);
       
      results[i] = current;
       
      double part = current - nextnumber;
      sumUp[i] = part;
       
      Console.WriteLine(results[i] + "/" + Math.Floor(current) + "/" + part);
    }
     
    for(int b = 0; b < sumUp.Length; b++) 
    {
      sumUp[b] = sumUp[b] * numBags;
      Console.WriteLine(sumUp[b]);
    }
  }
}
Programm, programmieren, C Sharp, Programmiersprache, Algorithmus

Meistgelesene Beiträge zum Thema Programmiersprache