Ergebnis 1 bis 12 von 12

Thema: NGB LetItSnow [Grease/Tamper]

  1. #1

    Cool NGB LetItSnow [Grease/Tamper]

    Let it snow..



    Für Greasemonkey und Tampermonkey ein bisschen Weihnachtsstimmung.

    Edit: Der Schnee lässt sich mit "^" an (Standard: An) und abschalten.
    Hier ein Weg die Schneekanone immer zu zünden oder abzuschalten: https://ngb.to/threads/107883-NGB-Le...64#post1098064

    Code (JavaScript):
    1. // ==UserScript==
    2. // @name     NGB LetItSnow
    3. // @version  1
    4. // @grant    none
    5. // @include  https://ngb.to/*
    6. // @include  https://www.ngb.to/*
    7. // ==/UserScript==
    8.  
    9. let canvasElement = document.createElement('canvas')
    10. canvasElement.width = '2000'
    11. canvasElement.height = '1600'
    12. document.body.append(canvasElement)
    13.  
    14. canvasElement.style['position'] = 'fixed'
    15. canvasElement.style['left'] = '0px'
    16. canvasElement.style['top'] = '0px'
    17. canvasElement.style['z-index'] = '100'
    18. canvasElement.style['background'] = 'transparent'
    19. canvasElement.style['maxwidth'] = '100%'
    20. canvasElement.style['maxheight'] = '100%'
    21. canvasElement.style['user-select'] = 'none'
    22. canvasElement.style['pointer-events'] = 'none'
    23.  
    24. let ctx = canvasElement.getContext('2d')
    25. let pi2 = 2 * Math.PI
    26. let particles = []
    27. let particleCount = 250
    28. let wind = 0
    29. let doSnow = true
    30.  
    31. function setup() {
    32.     ctx.clearRect(0, 0, canvasElement.width, canvasElement.height)
    33.     for (let i = 0; i < particleCount; i++) {
    34.         particles.push(new particle((Math.random() * canvasElement.width) + 5, (Math.random() * canvasElement.height - 5), Math.random() * 4 + 1, 1, 0.125, 1, 1.125, 0.15))
    35.     }
    36.  
    37.     window.requestAnimationFrame(drawSnow)
    38. }
    39.  
    40.  
    41. class particle {
    42.     constructor(x, y, size, maxSpeedX, minSpeedX, maxSpeedY, minSpeedY) {
    43.         this.wind = 0
    44.         this.x = x
    45.         this.y = y
    46.         this.size = size
    47.         this.speedX = (Math.random() * maxSpeedX + minSpeedX)
    48.         this.speedY = (Math.random() * maxSpeedY + minSpeedY)
    49.     }
    50.  
    51.     moveBySpeed() {
    52.         this.x += this.speedX;
    53.         this.y += this.speedY;
    54.         this.x += wind
    55.         //this.size += this.y / (canvasElement.height * 75)
    56.     }
    57. }
    58.  
    59. function drawSnow() {
    60.     ctx.clearRect(0, 0, canvasElement.width, canvasElement.height)
    61.     if (!doSnow) return
    62.     wind = (Math.random() * 1) + (Math.random() * -1)
    63.  
    64.     let deleted = 0
    65.     for (let i = 0; i < particles.length; ++i) {
    66.         let particle = particles[i]
    67.         particle.moveBySpeed()
    68.  
    69.         if (particle.x <= 0 || particle.x > canvasElement.width) {
    70.             particles.splice(i, 1)
    71.             --i
    72.             ++deleted
    73.         } else if (particle.y <= 0 || particle.y > canvasElement.height) {
    74.             particles.splice(i, 1)
    75.             --i
    76.             ++deleted
    77.         }
    78.     }
    79.  
    80.     for (let i = 0; i < deleted; ++i) particles.push(new particle((Math.random() * canvasElement.width) + 1, 1, Math.random() * 4 + 1, 1, 0.125, 1, 1.125, 0.15))
    81.  
    82.     /*
    83.     ctx.fillStyle = '#333'
    84.     ctx.beginPath()
    85.  
    86.     for (let particle of particles) {
    87.       ctx.moveTo(particle.x, particle.y)
    88.       ctx.arc(particle.x, particle.y, particle.size, 0, pi2)
    89.     }
    90.     */
    91.  
    92.     ctx.fill()
    93.  
    94.     ctx.fillStyle = '#fff'
    95.     ctx.beginPath()
    96.     for (let particle of particles) {
    97.         ctx.moveTo(particle.x, particle.y)
    98.         ctx.arc(particle.x - (particle.size * 0.25), particle.y - (particle.size * 0.25), particle.size * 0.75, 0, pi2)
    99.     }
    100.  
    101.     ctx.fill()
    102.  
    103.     window.requestAnimationFrame(drawSnow)
    104. }
    105.  
    106. let cookieData = document.cookie.split('; ')
    107. for (let cookie of cookieData) {
    108.   if (cookie.startsWith('doSnow')) {
    109.     doSnow = cookie.split('=')[1] === 'false' ? false : true
    110.     document.cookie = 'doSnow=; max-age=-1'
    111.   }
    112. }
    113.  
    114. document.cookie = 'doSnow=' + doSnow.toString() + '; domain=ngb.to; path=/'
    115.  
    116.  
    117. setup()
    118.  
    119.  
    120. document.addEventListener('keyup', function (evt) {
    121.     if (evt.key === 'Dead') {
    122.         doSnow = !doSnow
    123.         document.cookie = 'doSnow=; max-age=-1';
    124.         document.cookie = 'doSnow=' + doSnow.toString() + '; domain=ngb.to; path=/'
    125.  
    126.         if (doSnow) window.requestAnimationFrame(drawSnow)
    127.         else ctx.clearRect(0, 0, window.innerWidth, window.innerHeight)
    128.     }
    129. })
    130.  
    Merry X-Mas!
    Für diesen Beitrag bedanken sich Baer, Lokalrunde, saddy, LadyRavenous
    Geändert von theSplit (15.12.20 um 16:05 Uhr) Grund: An und aus Setting über Cookie

  2. #2
    Schneehase/Humor-Diktator

    Administrator

    Avatar von Lokalrunde
    Registriert seit
    Jul 2013
    Ort
    im Tiefschnee
    Beiträge
    64.603
    ngb:news Artikel
    535

    Re: NGB LetItSnow [Grease/Tamper]

    Sehr schön. Nachdem der schneiende Header bei mir in Ermangelung einer Alternative zur Stylist-Erweiterung nicht mehr funktioniert, ist das eine gute Alternative. Gleich mal probieren

    Edit: Ist das normal, das nach jedem Reload bzw. nach jedem Aufruf eines Subforums oder Threads alles erst mal wieder aus ist? Muss dann jedes Mal auf ^ gedrückt werden.
    ║ ► ♫ ZehnVorne - Die ngb-Bar ♫ ◄ ║ ► Lokalrundes Fun-Blog: wieder online ◄ ║
    The cold never bothered me anyway

    “Every autumn now my thoughts return to snow. Snow is something I identify myself with. Like my father, I am a snow person.” (Charlie English)


  3. #3
    1998

    Moderator

    (Threadstarter)

    Avatar von theSplit
    Registriert seit
    Aug 2014
    Beiträge
    26.831
    ngb:news Artikel
    4

    Re: NGB LetItSnow [Grease/Tamper]

    Wenn du es "immer" schneiend haben willst, einfach das hier auf "Ja" setzen:

    Zeile 29:

    Code (JavaScript):
    1. let doSnow = false //Standardmäßig aus
    mit dem hier

    Code (JavaScript):
    1. let doSnow = true //Standardmäßig an
    abspeichern und den Forentab neu laden!

    Edit: Hab es jetzt per Standard aktiviert, weil sich sonst gewundert wird..
    Für diesen Beitrag bedankt sich Lokalrunde
    Geändert von theSplit (14.12.20 um 04:36 Uhr) Grund: Zeile 29

  4. #4
    Schneehase/Humor-Diktator

    Administrator

    Avatar von Lokalrunde
    Registriert seit
    Jul 2013
    Ort
    im Tiefschnee
    Beiträge
    64.603
    ngb:news Artikel
    535

    Re: NGB LetItSnow [Grease/Tamper]

    Ist jetzt auf der anderen Seite ebenfalls wieder ein Problem. Wenn ich das Schneien nämlich jetzt mittels ^ abschalte, ist es bei einem Reload bzw. Aufruf eine Subforums/Threads wieder da

    Wenn Du da eine Möglichkeit finden könntest, die diese Einstellung quasi übernimmt, wäre das natürlich genial. Hab davon aber keine Ahnung, also weiß auch nicht, ob und, falls ja, wie einfach so was umsetzbar ist.
    ║ ► ♫ ZehnVorne - Die ngb-Bar ♫ ◄ ║ ► Lokalrundes Fun-Blog: wieder online ◄ ║
    The cold never bothered me anyway

    “Every autumn now my thoughts return to snow. Snow is something I identify myself with. Like my father, I am a snow person.” (Charlie English)


  5. #5
    1998

    Moderator

    (Threadstarter)

    Avatar von theSplit
    Registriert seit
    Aug 2014
    Beiträge
    26.831
    ngb:news Artikel
    4

    Re: NGB LetItSnow [Grease/Tamper]

    Hab dir deinen Wunsch umgesetzt und den Startpost editiert.

    Jetzt lässt sich mittels "^" der Schnee, auch bei Seitenwechsel/beim Surfen auf dem NGB, an und ausschalten und merkt sich diese Einstellung.
    Für diesen Beitrag bedankt sich Lokalrunde
    Geändert von theSplit (14.12.20 um 18:20 Uhr)

  6. #6
    1998

    Moderator

    (Threadstarter)

    Avatar von theSplit
    Registriert seit
    Aug 2014
    Beiträge
    26.831
    ngb:news Artikel
    4

    Cool Re: NGB LetItSnow [Grease/Tamper]

    Jetzt noch eine neue, winterlichere Version bei der der Schnee liegen bleibt.

    Screenshot:


    Video: https://www.picflash.org/picture.php...15&action=show

    Und hier das Skript:

    Code (JavaScript):
    1. // ==UserScript==
    2. // @name     NGB LetItSnow
    3. // @version  1
    4. // @grant    none
    5. // @include  https://ngb.to/*
    6. // @include  https://www.ngb.to/*
    7. // ==/UserScript==
    8.  
    9. let pi2 = 2 * Math.PI
    10. let particles = []
    11. let particleCount = 250
    12. let wind = 0
    13. let baseDecay = 3200
    14. let maxParticles = 1000
    15. let doSnow = true
    16.  
    17. let canvasElement = document.createElement('canvas')
    18. canvasElement.width = '2000'
    19. canvasElement.height = '1600'
    20. document.body.append(canvasElement)
    21.  
    22. canvasElement.style['position'] = 'fixed'
    23. canvasElement.style['left'] = '0px'
    24. canvasElement.style['top'] = '0px'
    25. canvasElement.style['z-index'] = '100'
    26. canvasElement.style['background'] = 'transparent'
    27. canvasElement.style['maxwidth'] = '100%'
    28. canvasElement.style['maxheight'] = '100%'
    29. canvasElement.style['user-select'] = 'none'
    30. canvasElement.style['pointer-events'] = 'none'
    31.  
    32. let ctx = canvasElement.getContext('2d')
    33.  
    34. function setup() {
    35.     ctx.clearRect(0, 0, canvasElement.width, canvasElement.height)
    36.     for (let i = 0; i < particleCount; i++) {
    37.         particles.push(new particle((Math.random() * canvasElement.width) + 5, (Math.random() * canvasElement.height - 5), Math.random() * 4 + 1, 1, 0.125, 1, 1.125, 0.15))
    38.     }
    39.  
    40.     window.requestAnimationFrame(drawSnow)
    41. }
    42.  
    43.  
    44. class particle {
    45.     constructor(x, y, size, maxSpeedX, minSpeedX, maxSpeedY, minSpeedY) {
    46.         this.x = x
    47.         this.y = y
    48.         this.size = size
    49.         this.speedX = (Math.random() * maxSpeedX) + (Math.random() * -maxSpeedX) + (Math.random() * minSpeedX) + (Math.random() * -minSpeedX)
    50.         this.speedY = (Math.random() * maxSpeedY) + minSpeedY
    51.         this.decay = baseDecay + Math.round(Math.random() * 1000 - Math.random() * 1000)
    52.         this.hasDecay = false
    53.     }
    54.  
    55.     moveBySpeed() {
    56.         this.x += this.speedX;
    57.         this.y += this.speedY;
    58.         this.x += wind
    59.         //this.size += this.y / (canvasElement.height * 75)
    60.     }
    61. }
    62.  
    63. function drawSnow() {
    64.     if (!doSnow) return
    65.     ctx.clearRect(0, 0, window.innerWidth, window.innerHeight)
    66.     wind = (Math.random() * 1) + (Math.random() * -1)
    67.  
    68.     let deleted = 0
    69.     let sizeParticles = particles.length
    70.     let addParticles = sizeParticles < maxParticles
    71.     for (let i = 0; i < particles.length; ++i) {
    72.         let particle = particles[i]
    73.         if (!particle.hasDecay) {
    74.           particle.moveBySpeed()
    75.      
    76.           if (particle.x <= 0 || particle.x > window.innerWidth) {
    77.               particles.splice(i, 1)
    78.               --i
    79.               ++deleted
    80.           } else if (particle.y < 0 || particle.y >= window.innerHeight - (particle.size * 0.5)) {
    81.                 particle.hasDecay = true
    82.                 particle.y = window.innerHeight
    83.               /*
    84.               particles.splice(i, 1)
    85.               --i
    86.              
    87.               ++deleted
    88.               */
    89.           }
    90.         } else {
    91.           if (addParticles && particle.decay % 100 === 0 && Math.random() * 1 > 0.95) ++deleted
    92.                    
    93.           if (particle.decay <= 0) {
    94.                     particles.splice(i, 1)
    95.                 --i
    96.               ++deleted
    97.           } else if (particle.y != window.innerHeight) {
    98.             particle.y = window.innerHeight
    99.             }
    100.          
    101.           --particle.decay
    102.           particle.size += 0.0075
    103.         }
    104.     }
    105.        
    106.     for (let i = 0; i < deleted; ++i) particles.push(new particle((Math.random() * canvasElement.width) + 1, 1, Math.random() * 4 + 1, 1, 0.125, 1, 1.125, 0.15))
    107.     let diffParticles = particleCount - particles.length
    108.     if (diffParticles > 0) for (let i = 0; i < diffParticles; ++i) particles.push(new particle((Math.random() * canvasElement.width) + 1, 1, Math.random() * 4 + 1, 1, 0.125, 1, 1.125, 0.15))
    109.    
    110.    
    111.     ctx.fillStyle = '#fff'
    112.     ctx.beginPath()
    113.     for (let particle of particles) {
    114.         ctx.moveTo(particle.x, particle.y)
    115.         ctx.arc(particle.x - (particle.size * 0.25), particle.y - (particle.size * 0.25), particle.size * 0.75, 0, pi2)
    116.     }
    117.  
    118.     ctx.fill()
    119.  
    120.     window.requestAnimationFrame(drawSnow)
    121. }
    122.  
    123. let cookieData = document.cookie.split('; ')
    124. for (let cookie of cookieData) {
    125.   if (cookie.startsWith('doSnow')) {
    126.     doSnow = cookie.split('=')[1] === 'false' ? false : true
    127.     document.cookie = 'doSnow=; max-age=-1'
    128.   }
    129. }
    130.  
    131. document.cookie = 'doSnow=' + doSnow.toString() + '; domain=ngb.to; path=/'
    132.  
    133.  
    134. setup()
    135.  
    136.  
    137. document.addEventListener('keyup', function (evt) {
    138.     if (evt.key === 'Dead') {
    139.         doSnow = !doSnow
    140.         document.cookie = 'doSnow=; max-age=-1';
    141.         document.cookie = 'doSnow=' + doSnow.toString() + '; domain=ngb.to; path=/'
    142.  
    143.         if (doSnow) window.requestAnimationFrame(drawSnow)
    144.         else ctx.clearRect(0, 0, window.innerWidth, window.innerHeight)
    145.     }
    146. })
    147.  
    Für diesen Beitrag bedankt sich Lokalrunde
    Geändert von theSplit (15.12.20 um 16:05 Uhr)

  7. #7
    Schneehase/Humor-Diktator

    Administrator

    Avatar von Lokalrunde
    Registriert seit
    Jul 2013
    Ort
    im Tiefschnee
    Beiträge
    64.603
    ngb:news Artikel
    535

    Re: NGB LetItSnow [Grease/Tamper]

    @theSplit: Sehr schön. Aber bei der neuen Version wird die Einstellung nicht gespeichert, kann das sein?

    Edit: Ah! Ich nehme alles zurück und behaupte das Gegenteil
    Wie es aussieht werden die Einstellungen individuell pro Subforum gespeichert. Nett
    ║ ► ♫ ZehnVorne - Die ngb-Bar ♫ ◄ ║ ► Lokalrundes Fun-Blog: wieder online ◄ ║
    The cold never bothered me anyway

    “Every autumn now my thoughts return to snow. Snow is something I identify myself with. Like my father, I am a snow person.” (Charlie English)


  8. #8
    1998

    Moderator

    (Threadstarter)

    Avatar von theSplit
    Registriert seit
    Aug 2014
    Beiträge
    26.831
    ngb:news Artikel
    4

    Re: NGB LetItSnow [Grease/Tamper]

    Zitat Zitat von Lokalrunde Beitrag anzeigen
    Wie es aussieht werden die Einstellungen individuell pro Subforum gespeichert. Nett
    Nein, das täuscht. Wenn du mehrere Tabs offen hast und in einem die ^ drückst, wird es für den Tab an oder ausgeschaltet. Wechselst du dann in den anderen Tab und navigierst, wird der letzte Stand übernommen.

  9. #9
    Schneehase/Humor-Diktator

    Administrator

    Avatar von Lokalrunde
    Registriert seit
    Jul 2013
    Ort
    im Tiefschnee
    Beiträge
    64.603
    ngb:news Artikel
    535

    Re: NGB LetItSnow [Grease/Tamper]

    @theSplit: Ich habe in der Regel einen Thread fürs Board offen. In Threads oder Subforen, in denen ich es mittels ^ deaktiviert habe, bleibt es auch deaktiviert, in den anderen nicht.
    ║ ► ♫ ZehnVorne - Die ngb-Bar ♫ ◄ ║ ► Lokalrundes Fun-Blog: wieder online ◄ ║
    The cold never bothered me anyway

    “Every autumn now my thoughts return to snow. Snow is something I identify myself with. Like my father, I am a snow person.” (Charlie English)


  10. #10
    1998

    Moderator

    (Threadstarter)

    Avatar von theSplit
    Registriert seit
    Aug 2014
    Beiträge
    26.831
    ngb:news Artikel
    4

    Re: NGB LetItSnow [Grease/Tamper]

    Irgendwie war das Einstellungsmerken etwas Fehleranfällig, gerade wenn man mehrere Tabs offen gehabt hat.

    Hier ist noch ein etwa aktualisierte Version, auch mit "anmutend schmelzendem Scnee". Ich denke diese Version solltest du ausprobieren.

    Ich überlege auch ob man nicht den Schnee zwischenspeichert und bei einem Tab wiederherstellt.. dann wäre das ein gängiges Bild auch bei Seitenwechsel. Wäre das gewünscht oder soll das so bleiben wie ist?

    Code (JavaScript):
    1. // ==UserScript==
    2. // @name     NGB LetItSnow
    3. // @version  1.1
    4. // @grant    none
    5. // @include  https://ngb.to/*
    6. // @include  https://www.ngb.to/*
    7. // ==/UserScript==
    8.  
    9. let pi2 = 2 * Math.PI
    10. let particles = []
    11. let particleCount = 300
    12. let wind = 0
    13. let baseDecay = 3200
    14. let maxParticles = 1000
    15. let doSnow = true
    16.  
    17. let canvasElement = document.createElement('canvas')
    18. canvasElement.width = '2000'
    19. canvasElement.height = '1600'
    20. document.body.append(canvasElement)
    21.  
    22. canvasElement.style['position'] = 'fixed'
    23. canvasElement.style['left'] = '0px'
    24. canvasElement.style['top'] = '0px'
    25. canvasElement.style['z-index'] = '100'
    26. canvasElement.style['background'] = 'transparent'
    27. canvasElement.style['maxwidth'] = '100%'
    28. canvasElement.style['maxheight'] = '100%'
    29. canvasElement.style['user-select'] = 'none'
    30. canvasElement.style['pointer-events'] = 'none'
    31.  
    32. let ctx = canvasElement.getContext('2d')
    33.  
    34. function setup() {
    35.     ctx.clearRect(0, 0, canvasElement.width, canvasElement.height)
    36.     for (let i = 0; i < particleCount; i++) {
    37.         particles.push(new particle(Math.random() * canvasElement.width + 5, Math.random() * canvasElement.height - 5, Math.random() * 4 + 1, 1, 0.125, 1, 1.125, 0.15))
    38.     }
    39.  
    40.     window.requestAnimationFrame(drawSnow)
    41. }
    42.  
    43.  
    44. class particle {
    45.     constructor(x, y, size, maxSpeedX, minSpeedX, maxSpeedY, minSpeedY) {
    46.         this.x = x
    47.         this.y = y
    48.         this.size = size
    49.         this.speedX = Math.random() * maxSpeedX + Math.random() * -maxSpeedX + Math.random() * minSpeedX + Math.random() * -minSpeedX
    50.         this.speedY = Math.random() * maxSpeedY + minSpeedY
    51.         this.decay = baseDecay + Math.round(Math.random() * 1000 - Math.random() * 1000)
    52.         this.hasDecay = false
    53.     }
    54.  
    55.     moveBySpeed() {
    56.         this.x += this.speedX;
    57.         this.y += this.speedY;
    58.         this.x += wind
    59.         //this.size += this.y / (canvasElement.height * 75)
    60.     }
    61. }
    62.  
    63. function drawSnow() {
    64.     if (!doSnow) return
    65.     ctx.clearRect(0, 0, window.innerWidth, window.innerHeight)
    66.     wind = (Math.random() * 1) + (Math.random() * -1)
    67.  
    68.     let deleted = 0
    69.     let sizeParticles = particles.length
    70.     let addParticles = sizeParticles < maxParticles
    71.     for (let i = 0; i < particles.length; ++i) {
    72.         let particle = particles[i]
    73.         if (!particle.hasDecay) {
    74.           particle.moveBySpeed()
    75.      
    76.           if (particle.x < 0 || particle.x > canvasElement.width) {
    77.               particles.splice(i, 1)
    78.               --i
    79.               ++deleted
    80.           } else if (particle.y < 0 || particle.y >= window.innerHeight) {
    81.                 particle.hasDecay = true
    82.                 particle.y = window.innerHeight
    83.           }
    84.         } else {
    85.           if (addParticles && particle.decay % 100 === 0 && Math.random() * 1 > 0.95) ++deleted
    86.                    
    87.             if (particle.decay <= 0) {
    88.                     particles.splice(i, 1)
    89.                 --i
    90.               ++deleted
    91.           } else {
    92.             --particle.decay
    93.             particle.size += 0.0075
    94.           }
    95.          
    96.           if (particle.y != window.innerHeight) particle.y = window.innerHeight
    97.         }
    98.     }
    99.        
    100.     for (let i = 0; i < deleted; ++i) particles.push(new particle(Math.random() * canvasElement.width + 1, 1, Math.random() * 4 + 1, 1, 0.125, 1, 1.125, 0.15))
    101.     let diffParticles = particleCount - particles.length
    102.     if (diffParticles > 0) for (let i = 0; i < diffParticles; ++i) particles.push(new particle(Math.random() * canvasElement.width + 1, 1, Math.random() * 4 + 1, 1, 0.125, 1, 1.125, 0.15))
    103.    
    104.     ctx.fillStyle = '#fff'
    105.    
    106.     ctx.beginPath()
    107.     for (let particle of particles) {
    108.         if (particle.hasDecay) continue
    109.         ctx.moveTo(particle.x, particle.y)
    110.         ctx.arc(particle.x, particle.y, particle.size, 0, pi2)
    111.     }
    112.     ctx.fill()     
    113.  
    114.     for (let particle of particles) {
    115.         if (!particle.hasDecay) continue
    116.           ctx.fillStyle = 'rgba(255,255,255, ' + (particle.decay * 0.01) + ')'
    117.         ctx.beginPath()
    118.         ctx.arc(particle.x, particle.y - (particle.size * 0.5), particle.size, 0, pi2)
    119.         ctx.fill()
    120.     }
    121.  
    122.  
    123.  
    124.    
    125.  
    126.     window.requestAnimationFrame(drawSnow)
    127. }
    128.  
    129. let cookieData = document.cookie.split('; ')
    130. for (let cookie of cookieData) {
    131.   if (cookie.startsWith('doSnow')) {
    132.     doSnow = cookie.split('=')[1] === 'false' ? false : true
    133.     document.cookie = 'doSnow=; max-age=-1'
    134.   }
    135. }
    136.  
    137. document.cookie = 'doSnow=' + doSnow.toString() + '; domain=ngb.to; path=/'
    138.  
    139.  
    140. setup()
    141.  
    142.  
    143. document.addEventListener('keyup', function (evt) {
    144.     if (evt.key === 'Dead') {
    145.         doSnow = !doSnow
    146.         document.cookie = 'doSnow=; max-age=-1';
    147.         document.cookie = 'doSnow=' + doSnow.toString() + '; domain=ngb.to; path=/'
    148.  
    149.         if (doSnow) window.requestAnimationFrame(drawSnow)
    150.         else ctx.clearRect(0, 0, window.innerWidth, window.innerHeight)
    151.     }
    152. })
    153.  
    Geändert von theSplit (16.12.20 um 21:46 Uhr)

  11. #11
    Schneehase/Humor-Diktator

    Administrator

    Avatar von Lokalrunde
    Registriert seit
    Jul 2013
    Ort
    im Tiefschnee
    Beiträge
    64.603
    ngb:news Artikel
    535

    Re: NGB LetItSnow [Grease/Tamper]

    Ich bin mit der Version, die ich aktuell habe (nicht die aktuellste, die Du gerade gepostet hast), ja zufrieden
    ║ ► ♫ ZehnVorne - Die ngb-Bar ♫ ◄ ║ ► Lokalrundes Fun-Blog: wieder online ◄ ║
    The cold never bothered me anyway

    “Every autumn now my thoughts return to snow. Snow is something I identify myself with. Like my father, I am a snow person.” (Charlie English)


  12. #12
    1998

    Moderator

    (Threadstarter)

    Avatar von theSplit
    Registriert seit
    Aug 2014
    Beiträge
    26.831
    ngb:news Artikel
    4

    Re: NGB LetItSnow [Grease/Tamper]

    Hier nochmal eine Version die sich den letzten Stand merkt.

    Ihr könnt das einfach ausschalten wenn ihr useSave = false setzt.

    Code (JavaScript):
    1. // ==UserScript==
    2. // @name     NGB LetItSnow
    3. // @version  1.1
    4. // @grant    GM.setValue
    5. // @grant    GM.getValue
    6. // @include  https://ngb.to/*
    7. // @include  https://www.ngb.to/*
    8. // ==/UserScript==
    9.  
    10. let useSave = true
    11. let doSnow = true
    12.  
    13. let saveInProgress = false
    14. let pi2 = 2 * Math.PI
    15. let particles = []
    16. let particleCount = 300
    17. let wind = 0
    18. let baseDecay = 3200
    19. let maxParticles = 750
    20.  
    21. let canvasElement = document.createElement('canvas')
    22. canvasElement.width = '2200'
    23. canvasElement.height = '1600'
    24. document.body.append(canvasElement)
    25.  
    26. canvasElement.style['position'] = 'fixed'
    27. canvasElement.style['left'] = '0px'
    28. canvasElement.style['top'] = '0px'
    29. canvasElement.style['z-index'] = '100'
    30. canvasElement.style['background'] = 'transparent'
    31. canvasElement.style['maxwidth'] = '100%'
    32. canvasElement.style['maxheight'] = '100%'
    33. canvasElement.style['user-select'] = 'none'
    34. canvasElement.style['pointer-events'] = 'none'
    35.  
    36. let ctx = canvasElement.getContext('2d')
    37.  
    38.  
    39. function setup() {
    40.   ctx.clearRect(0, 0, canvasElement.width, canvasElement.height)
    41.   if (useSave) {
    42.     GM.getValue('doSnowParticles', '').then(function (data) {
    43.       if (data !== '') {
    44.         let rows = data.split('|')
    45.  
    46.         for (let entries of rows) {
    47.           let entry = entries.split('_', 7)
    48.           particles.push(new resumeParticle(parseFloat(entry[0]), parseFloat(entry[1]), parseFloat(entry[2]), parseFloat(entry[3]), parseFloat(entry[4]), parseInt(entry[5]), entry[6] === "true" ? true : false))
    49.         }
    50.  
    51.         console.log('doSnow: restored particles..')
    52.       } else if (particles.length === 0) {
    53.         for (let i = 0; i < particleCount; i++) {
    54.           particles.push(new particle(Math.random() * canvasElement.width + 5, Math.random() * canvasElement.height - 5, Math.random() * 3 + 1, 1, 0.125, 1, 1.125, 0.15))
    55.         }
    56.       }
    57.      
    58.       window.requestAnimationFrame(drawSnow)
    59.     })
    60.   } else if (particles.length === 0) {
    61.     for (let i = 0; i < particleCount; i++) {
    62.       particles.push(new particle(Math.random() * canvasElement.width + 5, Math.random() * canvasElement.height - 5, Math.random() * 3 + 1, 1, 0.125, 1, 1.125, 0.15))
    63.     }
    64.  
    65.     window.requestAnimationFrame(drawSnow)
    66.   }
    67. }
    68.  
    69.  
    70. class resumeParticle {
    71.   constructor(x, y, size, speedX, speedY, decay, hasDecay) {
    72.     this.x = x
    73.     this.y = y
    74.     this.size = size
    75.     this.speedX = speedX
    76.     this.speedY = speedY
    77.     this.decay = decay
    78.     this.hasDecay = hasDecay
    79.   }
    80.  
    81.   moveBySpeed() {
    82.     this.x += this.speedX;
    83.     this.y += this.speedY;
    84.     this.x += wind
    85.     //this.size += this.y / (canvasElement.height * 75)
    86.   }
    87. }
    88.  
    89. class particle {
    90.   constructor(x, y, size, maxSpeedX, minSpeedX, maxSpeedY, minSpeedY) {
    91.     this.x = x
    92.     this.y = y
    93.     this.size = size
    94.     this.speedX = Math.random() * maxSpeedX + Math.random() * -maxSpeedX + Math.random() * minSpeedX + Math.random() * -minSpeedX
    95.     this.speedY = Math.random() * maxSpeedY + minSpeedY
    96.     this.decay = baseDecay + Math.round(Math.random() * 1000 - Math.random() * 1000)
    97.     this.hasDecay = false
    98.   }
    99.  
    100.   moveBySpeed() {
    101.     this.x += this.speedX;
    102.     this.y += this.speedY;
    103.     this.x += wind
    104.     //this.size += this.y / (canvasElement.height * 75)
    105.   }
    106. }
    107.  
    108. function drawSnow() {
    109.   if (!doSnow || saveInProgress) return
    110.   ctx.clearRect(0, 0, window.innerWidth, window.innerHeight)
    111.   wind = (Math.random() * 1) + (Math.random() * -1)
    112.  
    113.   let deleted = 0
    114.   let sizeParticles = particles.length
    115.   let addParticles = sizeParticles < maxParticles
    116.   for (let i = 0; i < particles.length; ++i) {
    117.     let particle = particles[i]
    118.     if (!particle.hasDecay) {
    119.       particle.moveBySpeed()
    120.  
    121.       if (particle.x < 0 || particle.x > canvasElement.width) {
    122.         particles.splice(i, 1)
    123.         --i
    124.         ++deleted
    125.       } else if (particle.y < 0 || particle.y >= window.innerHeight + (particle.size * 0.5)) {
    126.         particle.hasDecay = true
    127.         particle.y = window.innerHeight
    128.       }
    129.     } else {
    130.       if (addParticles && particle.decay % 100 === 0 && Math.random() * 1 > 0.95) ++deleted
    131.       if (particle.y != window.innerHeight + (particle.size * 0.5)) particle.y = window.innerHeight + (particle.size * 0.5)
    132.  
    133.       if (particle.decay <= 0) {
    134.         particles.splice(i, 1)
    135.         --i
    136.         ++deleted
    137.       } else {
    138.         --particle.decay
    139.         particle.size += 0.005
    140.       }
    141.  
    142.      
    143.     }
    144.   }
    145.  
    146.   for (let i = 0; i < deleted; ++i) particles.push(new particle(Math.random() * canvasElement.width + 1, 1, Math.random() * 3 + 1, 1, 0.125, 1, 1.125, 0.15))
    147.   let diffParticles = particleCount - particles.length
    148.   if (diffParticles > 0) for (let i = 0; i < diffParticles; ++i) particles.push(new particle(Math.random() * canvasElement.width + 1, 1, Math.random() * 3 + 1, 1, 0.125, 1, 1.125, 0.15))
    149.  
    150.   ctx.fillStyle = '#fff'
    151.  
    152.   ctx.beginPath()
    153.   for (let particle of particles) {
    154.     if (particle.hasDecay) continue
    155.     ctx.moveTo(particle.x, particle.y)
    156.     ctx.arc(particle.x, particle.y, particle.size, 0, pi2)
    157.   }
    158.   ctx.fill()
    159.  
    160.   for (let particle of particles) {
    161.     if (!particle.hasDecay) continue
    162.     ctx.fillStyle = 'rgba(255,255,255, ' + (particle.decay * 0.01) + ')'
    163.     ctx.beginPath()
    164.     ctx.arc(particle.x, particle.y - (particle.size * 0.5), particle.size, 0, pi2)
    165.     ctx.fill()
    166.   }
    167.  
    168.  
    169.  
    170.  
    171.  
    172.   window.requestAnimationFrame(drawSnow)
    173. }
    174.  
    175. document.addEventListener('keyup', function (evt) {
    176.   if (evt.key === 'Dead') {
    177.     doSnow = !doSnow
    178.     document.cookie = 'doSnow=; max-age=-1';
    179.     document.cookie = 'doSnow=' + doSnow.toString() + '; domain=ngb.to; path=/'
    180.  
    181.     if (doSnow) window.requestAnimationFrame(drawSnow)
    182.     elsectx.clearRect(0, 0, canvasElement.width, canvasElement.height)
    183.   }
    184. })
    185.  
    186.  
    187.  
    188. window.addEventListener('beforeunload', function (evt) {
    189.   if (!useSave) {
    190.     GM.setValue('doSnowParticles', '')
    191.     return true
    192.   }
    193.  
    194.   saveInProgress = true
    195.  
    196.   let particleList = []
    197.   for (let particle of particles) {
    198.     particleList.push([particle.x, particle.y, particle.size, particle.speedX, particle.speedY, particle.decay, particle.hasDecay].join('_'))
    199.   }
    200.  
    201.   GM.setValue('doSnowParticles', particleList.join('|')).then(function () { console.log('doSnow: saved particles..') })
    202. })
    203.  
    204. let cookieData = document.cookie.split('; ')
    205. for (let cookie of cookieData) {
    206.   if (cookie.startsWith('doSnow')) {
    207.     doSnow = cookie.split('=')[1] === 'false' ? false : true
    208.     document.cookie = 'doSnow=; max-age=-1'
    209.   }
    210. }
    211.  
    212. document.cookie = 'doSnow=' + doSnow.toString() + '; domain=ngb.to; path=/'
    213. setup()
    Für diesen Beitrag bedankt sich pspzockerscene
    Geändert von theSplit (31.12.20 um 00:16 Uhr) Grund: Tampermonkey läuft. SaveInProgres ergänzt

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •