Ergebnis 1 bis 20 von 20

Thema: [Script] NGB Subload - Themenüberblick von Foren

  1. #1

    [Script] NGB Subload - Themenüberblick von Foren

    Hallo,

    ich habe ein Greasemonkey-Skript (sollte allerdings auch mit Tempermonkey funktionieren) - welches einen Überblick über ein Forum gibt, noch bevor ihr dieses öffnen müsst.
    Dabei werden dann unter dem Forumnamen die letzten X (Standardmäßig bis zu 8) Themen mit Informationen angezeigt, die allerdings niemals älter als 90 Tage sind. Seid ihr in einem Forum mit Unterforen, werden dann auch anschließend diese gelistet.

    Info: Nach Rücksprache ist das Skript hier okay, aber es verursacht natürlich etwas mehr Load, weil die Foren einmalig geladen werden müssen, wenn sich nichts aktualisiert, kommen sie aus dem Cache (Firefox).

    Das ganze funktioniert über Ajax Requests die in Chrome wie auch Firefox unterstützt werden.

    Hier einmal ein paar Screenshots des Skripts im Einsatz:

    - -

    Das Skript hat noch keine Einstellungsoptionen, also es lässt sich noch nicht wirklich steuern. Wir zeigen immer bis zu 8 letzte Themen an.


    Updates:
    v1.0 : Diese Version
    v1.1 : https://ngb.to/threads/29485-Script-...197#post793197
    v1.2: https://ngb.to/threads/29485-Script-...751#post793751

    v1.2.2:
    v1.2.3:
    v.1.2.4: https://ngb.to/threads/29485-Script-...896#post793896

    v.1.2.5 (Bugfix! + latest): https://ngb.to/threads/29485-Script-...383#post794383

    Und hier das Userscript (alt, v1.0):

    Code (JavaScript):
    1. // ==UserScript==
    2. // @name NGB Subloader
    3. // @namespace ngb_subload
    4. // @description NGB Subloader
    5. // @include https://ngb.to/
    6. // @include https://ngb.to/forum*
    7. // @version 1
    8. // @grant none
    9. // ==/UserScript==
    10.  
    11. function loaderChangeStatus(loader) {
    12.   loader = loader.target;
    13.   if (loader.readyState == 4 && loader.status == 200) {
    14.     data = loader.responseText.replace(/\n|\t|\b/g, '');
    15.    
    16.     var threadTitles = data.match(/<a href="[\s\w\b\=\"\\\-\_].*" class="lastpostdate/g);
    17.     //console.log(threadTitles);
    18.    
    19.     var threadAuthors = data.match(/<a[\s\w\b].* popupctrl"[\s\w\bäöüÄÖÜ=\"].*<\/a>/g);
    20.     //console.log(threadAuthors);
    21.    
    22.     var threadTimes = data.match(/<dd>[\s\w\bäöüÄÖÜ=\"\-\:\.].*<\/span>/g);
    23.     var offset = 0;
    24.     var htmlData = '<div style="clear: both; display: inline-block; width: 100%; padding: 10px 6px;">';
    25.     for (var i = 0; i < threadTimes.length; i++) {
    26.       if (threadTimes[i].match(/\"time\"/) === null) {
    27.         threadTimes.splice(i, 1);
    28.         i--;
    29.       }
    30.     }
    31.    
    32.     //console.log(threadTimes);
    33.  
    34.     if (threadTitles.length !== 0) {
    35.       var threadUrl = '';
    36.       var threadAuthor = '';
    37.       var threadAuthorId = 0;
    38.       var threadTime = '';
    39.       var now = new Date();
    40.      
    41.       for (var x = 0; x < 8; x++) { // Anzahl der Artikel die wir maximal anzeigen lassen wollen, hier 8.
    42.         if (offset + x >= threadTitles.length) {
    43.           break;
    44.         }
    45.        
    46.         threadUrl = threadTitles[x + offset].match(/href="threads[\s\wäöüÄÖÜ\-\\\/\_].*"/) [0];
    47.         threadUrl = threadUrl.substring(6, threadUrl.length - 8);
    48.         threadAuthor = threadAuthors[x + offset].match(/<strong\>[\s\wäöüÄÖÜ\-\\\\/_].*<\/strong>/) [0];
    49.         threadAuthor = threadAuthor.substr(8,threadAuthor.length-17);
    50.         threadAuthorId = threadAuthors[x + offset].match(/members\/[0-9].*-/g)[0];
    51.         threadAuthorId.substr(7, threadAuthorId.length);
    52.         threadTime = threadTimes[x + offset].replace(/<dd>|<span class="time">|<\/span>/g, '');
    53.        
    54.         if (threadTime.indexOf("Heute,") === -1 && threadTime.indexOf("Gestern,") === -1) {
    55.           var timeDate = threadTime.match(/[0-9].?/g);
    56.           var dateObj = new Date();
    57.           dateObj.setDate(parseInt(timeDate[0]));
    58.           dateObj.setMonth(parseInt(timeDate[1]));
    59.           dateObj.setFullYear(parseInt("20"+timeDate[2]), 10);
    60.           dateObj.setHours(parseInt(timeDate[3], 10));
    61.           dateObj.setMinutes(parseInt(timeDate[4], 10));
    62.           dateObj.setSeconds(0);
    63.           dateObj.setMilliseconds(0);
    64.          
    65.           if (dateObj.getTime() < now - (3600000*24*90)) {
    66.             offset++;
    67.             x--;
    68.             continue;
    69.           }
    70.         }
    71.        
    72.         htmlData += '<a href="https://ngb.to/' + threadUrl + '">' + threadUrl.substring(threadUrl.indexOf('-', 7), threadUrl.indexOf('?', 7)).replace(/quot/g, '').replace(/\-/g, ' ') + '</a>';
    73.         htmlData += ' [<a href="https://ngb.to/members/'+threadAuthorId+threadAuthor+'">' + threadAuthor + '</a>, ' + threadTime + ']<br/><br/>';
    74.        
    75.         /*
    76.         console.log("----------------------------------------------------------------");
    77.         console.log(threadUrl);
    78.         console.log(threadAuthor);
    79.         console.log(threadTime);
    80.         */
    81.       }
    82.       loader.parent.innerHTML += htmlData + '</div>';
    83.     }
    84.   }
    85.  
    86.   return;
    87. }
    88.        
    89. function ajaxLoader(url, index) {
    90.   var loader = new XMLHttpRequest();
    91.   loader.addEventListener('readystatechange', loaderChangeStatus);
    92.   loader.parent = boardLinks[index].parentNode.parentNode;
    93.   loader.open('GET', 'https://ngb.to/' + url.replace("http:\/\/", "https:\/\/"));
    94.   loader.send();
    95.   return;
    96. }
    97.        
    98. var boardLinks = document.querySelectorAll('h2.forumtitle');
    99. for (var i = 0; i < boardLinks.length; ++i) {
    100.   var hrefLink = boardLinks[i].innerHTML.match(/href="[\s\w\böäüÖÄÜ\-\_\/\\].*"/g) [0];
    101.   var url = hrefLink.substring(6, hrefLink.length - 1);
    102.   ajaxLoader(url, i, true);
    103. }
    104.  
    Folgende Ideen stehen noch im Raum für das Skript:
    - Foren zum laden aktivieren/deaktiveren (Cookie)
    - Button um alle dynamischen Inhalte auf Knopfdruck ein bzw. auszubleden (vielleicht verankert im Usermenü (auch in Cookie)
    - Button um die Anzeige für ein Forum zu ein- bzw. auszuklappen (auch in Cookie)
    Für diesen Beitrag bedanken sich BurnerR, Nerephes
    Geändert von theSplit (13.06.17 um 14:54 Uhr)
    Gruß theSplit
    @ I might be sober. The good things... the bad things... all I ever know is here! @
    +++ thunderNote +++ Thom's Inventarverwaltung +++ Pi-Thread +++ IT-Talents Code Competitions +++ NGB-Statistik Opt-Out/Anonymisierung +++ Stonerhead +++ Add-on Flag Cookies +++ Google Image Directlinks +++ dwrox.net

  2. #2
    1998

    Veteran

    (Threadstarter)

    Avatar von theSplit
    Registriert seit
    Aug 2014
    Beiträge
    4.853
    ngb:news Artikel
    2

    Re: [Script] NGB Subload - Themenüberblick von Foren

    v1.1:
    - die Ansicht wurde nochmal überarbeitet
    - jetzt werden wirklich nur noch die Threads angezeigt, die 30 Tage oder jünger sind - alles andere fliegt raus, vorher wurden auch ältere Themen als X Tage angezeigt da der Monat bei 0 in Javascript anfängt
    - die Titel der Themen werden nun korrekt ausgelesen

    Screenshot:


    Code (JavaScript):
    1.  
    2. // ==UserScript==
    3. // @name NGB Subloader
    4. // @namespace ngb_subload
    5. // @description NGB Subloader
    6. // @include https://ngb.to/
    7. // @include https://ngb.to/forum*
    8. // @version 1.1
    9. // @grant none
    10. // ==/UserScript==
    11.  
    12. function loaderChangeStatus(loader) {
    13.   loader = loader.target;
    14.   if (loader.readyState == 4 && loader.status == 200) {
    15.     data = loader.responseText.replace(/\n|\t|\b/g, '');
    16.    
    17.     var threadLinks = data.match(/class="titl.*<\/a>/g);
    18.     //console.log(threadLinks);
    19.    
    20.     var threadAuthors = data.match(/<a[\s\w\b].* popupctr.*<\/a>/g);
    21.     //console.log(threadAuthors);
    22.    
    23.     var threadTimes = data.match(/<dd>.*<\/span>/g);
    24.     for (var i = 0; i < threadTimes.length; i++) {
    25.       if (threadTimes[i].match(/"time"/) === null) {
    26.         threadTimes.splice(i, 1);
    27.         i--;
    28.       }
    29.     }
    30.    
    31.    //console.log(threadTimes);
    32.    
    33.     var htmlData = '<div style="clear: both; display: inline-block; width: 100%; padding: 10px 0px;">';
    34.    
    35.  
    36.     if (threadLinks.length !== 0) {
    37.       try {
    38.         var threadTitle = "";
    39.         var threadUrl = '';
    40.         var threadAuthor = '';
    41.         var threadAuthorId = 0;
    42.         var threadTime = '';
    43.         var now = new Date();
    44.         var hasContent = false;
    45.        
    46.         var offset = 0;
    47.         var offsetUser = Math.abs(threadAuthors.length - threadLinks.length);
    48.        
    49.         for (var x = 0; x < 8; x++) {
    50.           if (offset + x + offsetUser == threadAuthors.length || offset + x == threadLinks.length || offset + x == threadTimes.length) {
    51.             break;
    52.           }
    53.  
    54.           threadTitle = threadLinks[x + offset].match(/">.*<\/a>/g)[0];
    55.           threadTitle = threadTitle.substring(2, threadTitle.length-4);
    56.           //console.log(threadTitle);
    57.           threadUrl = threadLinks[x + offset].match(/href="threads.*"/g)[0];
    58.           threadUrl = threadUrl.substr(6, threadUrl.length - 8);
    59.           //console.log(threadUrl);
    60.           threadAuthor = threadAuthors[x + offset + offsetUser].match(/<strong\>[\s\w\däöüÄÖÜ\-\\\\/_\(\)\[\]].*<\/strong>/g)[0];
    61.           threadAuthor = threadAuthor.substring(8,threadAuthor.length-9);
    62.           //console.log(threadAuthor);
    63.           threadAuthorId = threadAuthors[x + offset].match(/members\/[0-9]*\-/g)[0];
    64.           threadAuthorId.substr(7, threadAuthorId.length);
    65.           //console.log(threadAuthorId);
    66.           threadTime = threadTimes[x + offset].replace(/<dd>|<span class="time">|<\/span>/g, '');
    67.           //console.log(threadTime);
    68.  
    69.           if (threadTime.indexOf("Heute,") === -1 && threadTime.indexOf("Gestern,") === -1) {
    70.             var timeDate = threadTime.match(/[0-9].?/g);
    71.             var dateObj = new Date();
    72.             dateObj.setDate(parseInt(timeDate[0]));
    73.             dateObj.setMonth(parseInt(timeDate[1])-1);
    74.             dateObj.setFullYear(parseInt("20"+timeDate[2]));
    75.             dateObj.setHours(parseInt(timeDate[3]));
    76.             dateObj.setMinutes(parseInt(timeDate[4]));
    77.             dateObj.setSeconds(0);
    78.             dateObj.setMilliseconds(0);
    79.             if (dateObj.getTime() < now - ((3600 * 1000) * 24 * 30)) { // 30 - Anzahl der Tage die Themen alt sein duerfen
    80.               offset++;
    81.               x--;
    82.               continue;
    83.             }
    84.           }
    85.  
    86.           htmlData += '<a style="clear: left; float: left;"href="https://ngb.to/' + threadUrl + '">' + threadTitle + '</a>';
    87.           htmlData += '<p style="display: block; text-align: right; margin-left: 10%;">[ <a href="https://ngb.to/members/'+threadAuthorId+threadAuthor+'">' + threadAuthor + '</a>, ' + threadTime + ' Uhr ]</p>';
    88.           hasContent = true;
    89.  
    90.           /*
    91.           console.log("----------------------------------------------------------------");
    92.           console.log(threadUrl);
    93.           console.log(threadAuthor);
    94.           console.log(threadTime);
    95.           */
    96.         }
    97.        
    98.         if (hasContent) {
    99.           loader.parent.innerHTML += htmlData + '</div>';  
    100.         }
    101.       } catch (error) {
    102.         console.log("[ERROR] Error in script: "+ error + ", loader: " + loader.responseURL);
    103.       }
    104.      
    105.     }
    106.   } else if (loader.readyState == 4) {
    107.     console.log("[ERROR] Loader status: " + loader.responseURL + " : (" + loader.status + ") "+ loader.statusText);
    108.   }
    109.  
    110.   return;
    111. }
    112.        
    113. function ajaxLoader(url, index) {
    114.   var loader = new XMLHttpRequest();
    115.   loader.addEventListener('readystatechange', loaderChangeStatus);
    116.   loader.parent = boardLinks[index].parentNode.parentNode;
    117.   loader.open('GET', 'https://ngb.to/' + url.replace("http:\/\/", "https:\/\/"));
    118.   loader.send();
    119.   return;
    120. }
    121.        
    122. var boardLinks = document.querySelectorAll('h2.forumtitle');
    123. for (var i = 0; i < boardLinks.length; ++i) {
    124.   var hrefLink = boardLinks[i].innerHTML.match(/href="[\s\w\böäüÖÄÜ\-\_\/\\].*"/g) [0];
    125.   var url = hrefLink.substring(6, hrefLink.length - 1);
    126.   ajaxLoader(url, i, true);
    127. }
    128.  
    Geändert von theSplit (07.06.17 um 23:46 Uhr) Grund: Fix incorrect username display
    Gruß theSplit
    @ I might be sober. The good things... the bad things... all I ever know is here! @
    +++ thunderNote +++ Thom's Inventarverwaltung +++ Pi-Thread +++ IT-Talents Code Competitions +++ NGB-Statistik Opt-Out/Anonymisierung +++ Stonerhead +++ Add-on Flag Cookies +++ Google Image Directlinks +++ dwrox.net

  3. #3
    Schneehasen-Reptiloid 2.5

    Administrator

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

    Re: [Script] NGB Subload - Themenüberblick von Foren

    Prinzipiell finde ich es nicht schlecht, aber zumindest unter Tampermonkey in Chrome scheint es nicht ganz fehlerfrei zu funktionieren. So hat sich beispielsweise bei den internen Foren (die Du nicht sehen kannst, was das bugfixen natürlich komplizierter macht, das ist mir klar) ein Fehler eingeschlichen, wonach der letzte Beitrag angeblich von Kugelfisch stammen soll, was ja bekanntlich nicht der Fall sein kann. Außerdem werden in bestimmten Foren (beispielsweise Teilen der Börse) gar keine Threads angezeigt.
    ║ ► ♫ 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)


  4. #4
    1998

    Veteran

    (Threadstarter)

    Avatar von theSplit
    Registriert seit
    Aug 2014
    Beiträge
    4.853
    ngb:news Artikel
    2

    Re: [Script] NGB Subload - Themenüberblick von Foren

    Danke für dein Feedback!

    Ich habe eben nochmal ein paar augenscheinliche Fehler behoben und auch "Error" handling eingebaut, bzw. das Fehler überhaupt dargestellt werden.

    Wenn du die Entwicklerkonsole aufmachst, sollte dir nun auch ein Fehler angezeigt werden, wenn er in der Hauptroutine stattfindet. Das würde mir schon einmal helfen den Fehler zu suchen, für interne Foren kann ich allerdings weniger etwas machen, hoffen wir das meine letzten Fehlerbehebungen das beheben.
    Gruß theSplit
    @ I might be sober. The good things... the bad things... all I ever know is here! @
    +++ thunderNote +++ Thom's Inventarverwaltung +++ Pi-Thread +++ IT-Talents Code Competitions +++ NGB-Statistik Opt-Out/Anonymisierung +++ Stonerhead +++ Add-on Flag Cookies +++ Google Image Directlinks +++ dwrox.net

  5. #5
    Schneehasen-Reptiloid 2.5

    Administrator

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

    Re: [Script] NGB Subload - Themenüberblick von Foren

    Wenn Du mir jetzt noch sagst, welche Fehler Du da genau benötigst, kann ich Dir weiterhelfen
    Ich bin in der Beziehung eher unwissend, weißt Du ja


    Edit: Hier mal ein Beispiel für einen Fehler:



    Bei Hardware wird nix angezeigt, obwohl es aktuelle Threads gibt.
    ║ ► ♫ 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)


  6. #6
    1998

    Veteran

    (Threadstarter)

    Avatar von theSplit
    Registriert seit
    Aug 2014
    Beiträge
    4.853
    ngb:news Artikel
    2

    Re: [Script] NGB Subload - Themenüberblick von Foren

    Ich habe mal die Fehlerquellen etwas mehr hervorgehoben, heißt, wenn etwas einen Fehler schmeißt, steht da "[ERROR] Fehlermeldung", mehr oder minder auch mit URL und Grund.

    Das Skript aktualisiere ich gleich, dann sollte es passen.

    Das du im Hardware den Thread von "takota" nicht sehen kannst, hat aber auch damit zu tun, das das Thema im Unterforum "Hardware-Kaufberatung" liegt, die Hardware Anzeige sollte nun passen. Da gab es noch ein Problem mit.

    In "Kaufberatung", schmeißt der Ajax Request einen 301 - Permanent umgezogen für das "Hardware" Forum, dass muss wohl an der Verlinkung liegen wie die Inhalte "doppelt" vorhanden sind.

    Ich aktualisiere eben mal das Skript im Thread des "v1.1" Edit: Done!

    Edit2:

    Habe gerade noch eine Bearbeitung gemacht, das Benutzernamen nicht korrekt angezeigt worden sind, durch Unterforen, das sollte jetzt auch behoben sein. So wurde ein falscher Benutzername im Hardware zum Beispiel angezeigt.
    Geändert von theSplit (07.06.17 um 21:34 Uhr)
    Gruß theSplit
    @ I might be sober. The good things... the bad things... all I ever know is here! @
    +++ thunderNote +++ Thom's Inventarverwaltung +++ Pi-Thread +++ IT-Talents Code Competitions +++ NGB-Statistik Opt-Out/Anonymisierung +++ Stonerhead +++ Add-on Flag Cookies +++ Google Image Directlinks +++ dwrox.net

  7. #7
    Schneehasen-Reptiloid 2.5

    Administrator

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

    Re: [Script] NGB Subload - Themenüberblick von Foren

    Funktioniert zwar nun schon etwas besser, es bleiben aber nach wie vor Foren ohne Threads in der Übersicht.

    [ERROR] Error in script: TypeError: Cannot read property 'replace' of undefined, loader: https://ngb.to/forums/11-Hardware
    [ERROR] Error in script: TypeError: Cannot read property 'replace' of undefined, loader: https://ngb.to/forums/25-Grafik
    [ERROR] Error in script: TypeError: Cannot read property 'replace' of undefined, loader: https://ngb.to/forums/90-Schn%C3%A4ppchen
    [ERROR] Error in script: TypeError: Cannot read property 'replace' of undefined, loader: https://ngb.to/forums/18-Zwischenmenschliches
    [ERROR] Error in script: TypeError: Cannot read property 'replace' of undefined, loader: https://ngb.to/forums/64-Werbung
    Das sollten alle sein, hoffe, das hilft weiter.
    Für diesen Beitrag bedankt sich theSplit
    ║ ► ♫ 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

    Veteran

    (Threadstarter)

    Avatar von theSplit
    Registriert seit
    Aug 2014
    Beiträge
    4.853
    ngb:news Artikel
    2

    Re: [Script] NGB Subload - Themenüberblick von Foren

    Versuch mal bitte Zeile 49 wie folgt abzuändern:

    Code (JavaScript):
    1. if (offset + x + offsetUser == threadAuthors.length || offset + x == threadLinks.length || offset + x == threadTimes.length) {
    Neu in der Zeile ist das:
    || offset + x == threadTimes.length


    Das überprüft ob die Zeiten (threadTimes) außerhalb bereits abgearbeitet sind bzw. nicht mehr bearbeitet werden können falls ja, bricht die Ausführung ab und stellt dann nur dass da, was wir bisher haben.

    Ich weiß nicht ob du da mehr siehst als ich als Normaluser, aber nur da werden Daten mit einem "replace" (ein String) verändert.

    PS: Kannst du das auch mal in Firefox testen, falls möglich/nötig?

    Eigentlich sollten die Zeiten aber definiert sein, außer dein Markup (HTML) sieht anders aus.
    Geändert von theSplit (07.06.17 um 22:37 Uhr)
    Gruß theSplit
    @ I might be sober. The good things... the bad things... all I ever know is here! @
    +++ thunderNote +++ Thom's Inventarverwaltung +++ Pi-Thread +++ IT-Talents Code Competitions +++ NGB-Statistik Opt-Out/Anonymisierung +++ Stonerhead +++ Add-on Flag Cookies +++ Google Image Directlinks +++ dwrox.net

  9. #9
    Schneehasen-Reptiloid 2.5

    Administrator

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

    Re: [Script] NGB Subload - Themenüberblick von Foren

    Grafik (und übrigens auch "Konsolen und Emulatoren", obwohl es dafür keine Fehlermeldung gab) bleibt nach wie vor leer, mittlerweile aber ohne Fehlermeldung in der Konsole.

    Für Firefox bin ich der falsche Ansprechpartner, den nutze ich nur noch sporadisch und habe auch nur Werbeblocker & NoScript installiert.
    ║ ► ♫ 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
    Schneehasen-Reptiloid 2.5

    Administrator

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

    Re: [Script] NGB Subload - Themenüberblick von Foren

    Die angezeigten Namen stimmen übrigens nicht, wie ich gerade sehe:



    Das passt nicht. Frodoo taucht auf, ohne wirklich aktiv gewesen zu sein und der Rest ist dadurch "verrutscht".
    Für diesen Beitrag bedankt sich theSplit
    ║ ► ♫ 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)


  11. #11
    1998

    Veteran

    (Threadstarter)

    Avatar von theSplit
    Registriert seit
    Aug 2014
    Beiträge
    4.853
    ngb:news Artikel
    2

    Re: [Script] NGB Subload - Themenüberblick von Foren

    Ja, das war wirklich ein Problem, ich glaube das habe ich nun im Griff, kopiere dir am besten das gesamte Skript noch einmal aus dem v1.1 "Post", habe es aktualisiert vor kurzer Zeit.
    Bei mir stimmt es zum Beispiel aktuell.

    Siehe Screenshot:

    Gruß theSplit
    @ I might be sober. The good things... the bad things... all I ever know is here! @
    +++ thunderNote +++ Thom's Inventarverwaltung +++ Pi-Thread +++ IT-Talents Code Competitions +++ NGB-Statistik Opt-Out/Anonymisierung +++ Stonerhead +++ Add-on Flag Cookies +++ Google Image Directlinks +++ dwrox.net

  12. #12
    1998

    Veteran

    (Threadstarter)

    Avatar von theSplit
    Registriert seit
    Aug 2014
    Beiträge
    4.853
    ngb:news Artikel
    2

    Re: [Script] NGB Subload - Themenüberblick von Foren

    Zitat Zitat von Lokalrunde Beitrag anzeigen
    Grafik (und übrigens auch "Konsolen und Emulatoren", obwohl es dafür keine Fehlermeldung gab) bleibt nach wie vor leer, mittlerweile aber ohne Fehlermeldung in der Konsole.

    Für Firefox bin ich der falsche Ansprechpartner, den nutze ich nur noch sporadisch und habe auch nur Werbeblocker & NoScript installiert.

    Grafik und Konsolen bleiben leer, weil immer nur das "erste" Forum vorgeladen wird, alle darunter liegenden bleiben ausgeschlossen.

    Das heißt: In Grafik hat niemand gepostet, aber in den Wettbewerben, dann wird aber für Grafik nichts direkt angezeigt, erst wenn man in das Forum wechselt werden die "Unterforen" vorgeladen.

    Du siehst also nur die Beiträge aus den "Oberforen", und alles was darunter ist, siehtst du eventuell erst dann, wenn du in das Oberforum hinein wechselst.
    Für diesen Beitrag bedankt sich drfuture
    Gruß theSplit
    @ I might be sober. The good things... the bad things... all I ever know is here! @
    +++ thunderNote +++ Thom's Inventarverwaltung +++ Pi-Thread +++ IT-Talents Code Competitions +++ NGB-Statistik Opt-Out/Anonymisierung +++ Stonerhead +++ Add-on Flag Cookies +++ Google Image Directlinks +++ dwrox.net

  13. #13
    Schneehasen-Reptiloid 2.5

    Administrator

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

    Re: [Script] NGB Subload - Themenüberblick von Foren

    Ah, ok. Da ich bei den Konsolen normalerweise nie gucke, dachte ich am letzten Beitrag den 04.06.17 gesehen zu haben, war aber schon 2016. Dann passt es ja
    Den Rest teste ich jetzt nicht mehr, das probiere ich später. Ist mir jetzt schon zu spät, um das nochmal ausgiebig zu testen
    ║ ► ♫ 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)


  14. #14
    Geht ein
    Registriert seit
    Feb 2016
    Ort
    im Funkloch
    Beiträge
    313
    ngb:news Artikel
    3

    Re: [Script] NGB Subload - Themenüberblick von Foren

    Zitat Zitat von theSplit Beitrag anzeigen
    Seit ihr in einem Forum mit Unterforen
    >>Das Felsgestein gähnt in der freudigen Erwartung eures nächsten fabelhaften Spielzugs, Keeper<<

  15. #15
    1998

    Veteran

    (Threadstarter)

    Avatar von theSplit
    Registriert seit
    Aug 2014
    Beiträge
    4.853
    ngb:news Artikel
    2

    Re: [Script] NGB Subload - Themenüberblick von Foren

    .... du Grammernazi, der Unterschied ist mir aber bekannt.
    Wohl zu schnell getippt

    Habs korrigiert

    Seid ihr alle damit einverstanden? - Ich hoffe doch
    Gruß theSplit
    @ I might be sober. The good things... the bad things... all I ever know is here! @
    +++ thunderNote +++ Thom's Inventarverwaltung +++ Pi-Thread +++ IT-Talents Code Competitions +++ NGB-Statistik Opt-Out/Anonymisierung +++ Stonerhead +++ Add-on Flag Cookies +++ Google Image Directlinks +++ dwrox.net

  16. #16
    Geht ein
    Registriert seit
    Feb 2016
    Ort
    im Funkloch
    Beiträge
    313
    ngb:news Artikel
    3

    Re: [Script] NGB Subload - Themenüberblick von Foren

    Zitat Zitat von theSplit Beitrag anzeigen
    Seid ihr alle damit einverstanden? - Ich hoffe doch
    Noch nicht!
    >>Das Felsgestein gähnt in der freudigen Erwartung eures nächsten fabelhaften Spielzugs, Keeper<<

  17. #17
    1998

    Veteran

    (Threadstarter)

    Avatar von theSplit
    Registriert seit
    Aug 2014
    Beiträge
    4.853
    ngb:news Artikel
    2

    Re: [Script] NGB Subload - Themenüberblick von Foren

    Update: v1.2

    - es gibt einen Ein und Ausschalter für NGB Subload "NBG Sl [an] / NGB Sl [aus] (im Usermenü, Update2: für unangemeldete im Boardmenü) (Update: jetzt auch über einen Cookie gesteuert)
    - Subload kann jetzt über Cookies steuern, welche Foren geladen werden sollen und welche nicht - per Default werden keine Foren geladen mehr vorgeladen
    - die Foren können interaktiv entladen und geladen werden, mit Buttons können die Foren bestimmt werden die automatisch geladen werden sollen und dann beim nächsten Besuch wieder geladen werden
    - wird ein Forum mit Unterforum besucht, erstellt Subload Cookies für diese, diese können dann mit einem Click auf "Add to Subload" geladen werden
    - ein Klick auf einen Themenlink öffnet automatisch einen neuen Tab, anstelle des aktuellen so kann von dort aus navigiert werden wo man sich gerade befindet und das Thema im neuen Tab gelesen werden
    - Links zu den Themen sind nun auch die letzten Posts, nicht mehr der erste Post im Thema
    - Auslesen der Threadprefix funktioniert (letzter Screenshot)

    Erst ein paar Screenshots:


    Mit Threadprefixen:


    Und hier der neue Code (ich update gleich den Startpost mit dem Link zu den Versionen:

    Code (JavaScript):
    1.  
    2. // ==UserScript==
    3. // @name NGB Subloader
    4. // @namespace ngb_subload
    5. // @description NGB Subloader
    6. // @include https://ngb.to/
    7. // @include https://ngb.to/#*
    8. // @include https://ngb.to/forum*
    9. // @version 1.2
    10. // @grant none
    11. // ==/UserScript==
    12.  
    13. var loaded = 0;
    14. var hasLoaded = false;
    15. var boardLinks;
    16.  
    17. function toggleVisibility(event) {
    18.   var ngbSubloadDivs = document.getElementsByClassName("ngbSubloadDiv");
    19.   var ngbSubloadToggles = document.getElementsByClassName("subLoadtoggleForum");
    20.  
    21.   var show = "inline-block";
    22.   if (event.target.dataset.status == "on") {
    23.     show = "none";
    24.     event.target.dataset.status = "off";
    25.     event.target.innerHTML = "NGB-Sl [an]";
    26.     document.cookie = "subload_switch=off";
    27.   } else {
    28.     event.target.dataset.status = "on";
    29.     event.target.innerHTML = "NGB-Sl [aus]";
    30.     document.cookie = "subload_switch=on";
    31.   }
    32.  
    33.   for (var i = 0; i < ngbSubloadDivs.length; ++i) {
    34.     ngbSubloadDivs[i].style.display = show;
    35.     ngbSubloadToggles[i].style.display = show;
    36.   }
    37.  
    38.   if (!hasLoaded) {
    39.     for (var i = 0; i < boardLinks.length; ++i) {
    40.       var hrefLink = boardLinks[i].innerHTML.match(/href=".*"/g) [0];
    41.       var url = hrefLink.substring(6, hrefLink.length - 1);
    42.       ajaxLoader(url, i);
    43.     }
    44.   }
    45.  
    46.   return false;
    47. }
    48.  
    49. function toggleSubLoad(event) {
    50.   var forumId = event.target.dataset.name;
    51.   if (document.cookie.indexOf("subload_"+ forumId +"=true") != -1) {
    52.     document.cookie = "subload_"+forumId+"=false";
    53.   } else {
    54.     document.cookie = "subload_"+forumId+"=true";
    55.   }
    56.  
    57.   var oldData = document.querySelector("div.ngbSubloadDiv."+forumId);
    58.   oldData.parentNode.removeChild(oldData);
    59.   loaded--;
    60.  
    61.   boardLinks = document.querySelectorAll('h2.forumtitle');
    62.   var index = parseInt(event.target.dataset.index);
    63.   var hrefLink = boardLinks[index].innerHTML.match(/href=".*"/g) [0];
    64.   var url = hrefLink.substring(6, hrefLink.length - 1);
    65.   ajaxLoader(url, index);
    66. }
    67.  
    68. function checkLoad() {
    69.   if (loaded >= boardLinks.length-2) {
    70.     var userMenu = document.querySelector("ul.isuser");
    71.     if (userMenu !== null) {
    72.       if (document.getElementById("ngb_subload_switch") === null) {
    73.         userMenu.innerHTML += '<li><a id="ngb_subload_switch" data-status="on" style="margin-left: 10px; margin-right: 15px; cursor: pointer; text-decoration: none;" title="NGB Subload umschalten">NGB-Sl [aus]</a></li>';
    74.         document.getElementById("ngb_subload_switch").addEventListener("click", toggleVisibility, true);  
    75.       }
    76.     } else {
    77.       var subMenu = document.querySelector("ul.floatcontainer > ul.floatcontainer");
    78.       if (document.getElementById("ngb_subload_switch") === null) {
    79.         subMenu.innerHTML += '<li><a id="ngb_subload_switch" class="popupmenu" data-status="on" style="margin-left: 30px; margin-right: 15px; cursor: pointer; text-decoration: none;" title="NGB Subload umschalten">NGB-Sl [an]</a></li>';
    80.         document.getElementById("ngb_subload_switch").addEventListener("click", toggleVisibility, true);  
    81.       }
    82.     }
    83.  
    84.     var toggleButtons = document.getElementsByClassName("subLoadtoggleForum");
    85.     for (var i = 0; i < toggleButtons.length; ++i) {
    86.       toggleButtons[i].addEventListener("click", toggleSubLoad, true);
    87.     }
    88.    
    89.     hasLoaded = true;
    90.   }
    91. }
    92.  
    93. function loaderChangeStatus(loader) {
    94.   loader = loader.target;
    95.   if (loader.readyState == 4 && loader.status == 200) {
    96.     data = loader.responseText.replace(/\n|\t|\b/g, '');
    97.     try {
    98.       var threadLinks = data.match(/class="titl.*<\/a>/g);
    99.       var threadLastPosts = data.match(/<a .*lastpostdate.*<\/a>/g);
    100.       var threadPrefixes = data.replace(/\n|\t|\b|\r/g, '').match(/id="thread_prefix.*\<\/span>/g);
    101.       var threadAuthors = data.match(/<a[\s\w\b].* popupctr.*<\/a>/g);
    102.       var threadTimes = data.match(/<dd>.*<\/span>/g);  
    103.     } catch (error) {
    104.       console.log("[ERROR] Error in script: "+ error + ", loader: " + loader.responseURL);
    105.       loaded++;
    106.       return;
    107.     }
    108.    
    109.     for (var i = 0; i < threadTimes.length; i++) {
    110.       if (threadTimes[i].match(/"time"/) === null) {
    111.         threadTimes.splice(i, 1);
    112.         i--;
    113.       }
    114.     }
    115.    
    116.     var forumId = loader.parent.parentNode.parentNode.parentNode.parentNode.id
    117.     if (window.location.pathname.indexOf("/forums/") != -1) {
    118.       forumId = loader.parent.parentNode.parentNode.parentNode.parentNode.parentNode.id;
    119.     }
    120.    
    121.     var htmlData = '<div class="ngbSubloadDiv ' + forumId +'" style="clear: both; display: inline-block; width: 100%; margin: 10px 0px 10px 20px;">';
    122.  
    123.     if (document.cookie.indexOf("subload_"+ forumId +"=true") == -1) {
    124.       loader.parent.innerHTML += htmlData + '<button class="subLoadtoggleForum" data-name="'+forumId+'" data-index="'+ loader.index +'" style="clear:both; float: right; margin-top: 15px;">Add to subload</button></div>';
    125.       loaded++;
    126.      
    127.       checkLoad();
    128.       return;
    129.     }
    130.  
    131.     if (threadLinks.length !== 0) {
    132.       try {
    133.         var threadTitle = "";
    134.         var threadUrl = '';
    135.         var threadAuthor = '';
    136.         var threadAuthorId = 0;
    137.         var threadTime = '';
    138.         var threadId = "";
    139.         var lastThreadPrefix = 0;
    140.        
    141.         var now = new Date();        
    142.         var offset = 0;
    143.         var offsetUser = Math.abs(threadAuthors.length - threadLinks.length);
    144.        
    145.         for (var x = 0; x < 8; x++) {
    146.           if (offset + x + offsetUser == threadAuthors.length || offset + x == threadLinks.length || offset + x == threadTimes.length) {
    147.             break;
    148.           }
    149.  
    150.           threadTitle = threadLinks[x + offset].match(/">.*<\/a>/g)[0];
    151.           threadTitle = threadTitle.substring(2, threadTitle.length-4);
    152.           threadUrl = threadLastPosts[x + offset].match(/href="threads[\s\wäöüÄÖÜ\\\/\#\?\+\-\_\=\(\)\[\]]*/g)[0];
    153.           threadUrl = threadUrl.substr(6, threadUrl.length - 1);
    154.           threadAuthor = threadAuthors[x + offset + offsetUser].match(/<strong\>[\s\w\däöüÄÖÜ\-\\\\/_\(\)\[\]].*<\/strong>/g)[0];
    155.           threadAuthor = threadAuthor.substring(8,threadAuthor.length-9);
    156.           threadAuthorId = threadAuthors[x + offset].match(/members\/[0-9]*\-/g)[0];
    157.           threadAuthorId.substring(7, threadAuthorId.length);
    158.           threadTime = threadTimes[x + offset].replace(/<dd>|<span class="time">|<\/span>/g, '');
    159.           threadId = threadLinks[x + offset].match(/href="threads\/[0-9]*/g)[0];
    160.           threadId = threadId.substring(14, threadId.length);
    161.        
    162.           if (threadTime.indexOf("Heute,") === -1 && threadTime.indexOf("Gestern,") === -1) {
    163.             var timeDate = threadTime.match(/[0-9].?/g);
    164.             var dateObj = new Date();
    165.             dateObj.setDate(parseInt(timeDate[0]));
    166.             dateObj.setMonth(parseInt(timeDate[1])-1);
    167.             dateObj.setFullYear(parseInt("20"+timeDate[2]));
    168.             dateObj.setHours(parseInt(timeDate[3]));
    169.             dateObj.setMinutes(parseInt(timeDate[4]));
    170.             dateObj.setSeconds(0);
    171.             dateObj.setMilliseconds(0);
    172.             if (dateObj.getTime() < now - ((3600 * 1000) * 24 * 30)) { // 30 - Anzahl der Tage die Themen alt sein duerfen
    173.               offset++;
    174.               x--;
    175.               continue;
    176.             }
    177.           }
    178.          
    179.           var prefix = "";
    180.           if (threadPrefixes !== null) {
    181.             for (var i = lastThreadPrefix; i < threadPrefixes.length; ++i) {
    182.               if (threadPrefixes[i].indexOf(threadId) != -1) {
    183.                 lastThreadPrefix = i;
    184.                 prefix = threadPrefixes[i].match(/>[\s\w\b\-\_\(\)\[\]äöüÄÖÜ\:\,\;\#\+\*\&\/]*<\/span>/g)[0].trimRight();
    185.                 prefix = prefix.substring(1, prefix.length-7);
    186.               }
    187.             }  
    188.           }
    189.          
    190.           if (prefix != "") {
    191.             htmlData += '<span style="clear: both; float:left;"><i>' + prefix + '</i>&nbsp;<a href="https://ngb.to/' + threadUrl + '" target="_blank">' + threadTitle + '</a></span>';  
    192.           } else {
    193.             htmlData += '<a style="clear: left; float: left;" href="https://ngb.to/' + threadUrl + '" target="_blank">' + threadTitle + '</a>';
    194.           }
    195.          
    196.           htmlData += '<p style="display: block; text-align: right; margin-left: 10%;">[ <a href="https://ngb.to/members/'+threadAuthorId+threadAuthor+'">' + threadAuthor + '</a>, ' + threadTime + ' Uhr ]</p>';
    197.         }
    198.        
    199.         loader.parent.innerHTML += htmlData + '<button class="subLoadtoggleForum" data-name="'+forumId+'" data-index="'+loader.index+'" style="clear:both; float: right; margin-top: 15px;">Remove of subload</button></div>';
    200.         loaded++;
    201.         checkLoad();
    202.        
    203.       } catch (error) {
    204.         console.log("[ERROR] Error in script: "+ error + ", loader: " + loader.responseURL);
    205.       }
    206.     }
    207.  
    208.   } else if (loader.readyState == 4) {
    209.     console.log("[ERROR] Loader status: " + loader.responseURL + " : (" + loader.status + ") "+ loader.statusText);
    210.     loaded++;
    211.     checkLoad();
    212.   }
    213.  
    214.   return;
    215. }
    216.  
    217. function ajaxLoader(url, index) {
    218.   var loader = new XMLHttpRequest();
    219.   loader.addEventListener('readystatechange', loaderChangeStatus);
    220.   loader.parent = boardLinks[index].parentNode.parentNode;
    221.   loader.index = index;
    222.  
    223.   var forumId = loader.parent.parentNode.parentNode.parentNode.parentNode.id;
    224.   if (window.location.pathname.indexOf("/forums/") != -1) {
    225.     forumId = loader.parent.parentNode.parentNode.parentNode.parentNode.parentNode.id;
    226.   }
    227.  
    228.   if (document.cookie.indexOf("subload_"+ forumId +"=true") == -1) {
    229.     var htmlData = '<div class="ngbSubloadDiv ' + forumId +'" style="clear: both; display: inline-block; width: 100%; margin: 10px 0px 10px 20px;">';
    230.     loader.parent.innerHTML += htmlData + '<button class="subLoadtoggleForum" data-name="'+forumId+'" data-index="'+loader.index+'" style="clear:both; float: right; margin-top: 15px;">Add to subload</button></div>';
    231.     loaded++;
    232.     checkLoad();
    233.     return;
    234.   }
    235.  
    236.   loader.open('GET', 'https://ngb.to/' + url.replace("http:\/\/", "https:\/\/"), true);
    237.   loader.send();
    238.   return;
    239. }
    240.        
    241. //-----------------------------------------------------------------------------------------------
    242.  
    243. boardLinks = document.querySelectorAll('h2.forumtitle');
    244. for (var i = 0; i < boardLinks.length; ++i) {
    245.   var forumId = boardLinks[i].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.id;
    246.  
    247.   if (window.location.pathname.indexOf("/forums/") != -1) {
    248.     forumId = boardLinks[i].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.id;
    249.   }
    250.  
    251.   if (document.cookie.indexOf("subload_"+ forumId +"=true") == -1 && document.cookie.indexOf("subload_"+ forumId +"=false") == -1) {
    252.     document.cookie = "subload_"+ forumId +"=false";
    253.   }
    254. }
    255.  
    256. // Check for existing subload cookie
    257. if (document.cookie.indexOf("subload_switch=on") == -1 && document.cookie.indexOf("subload_switch=off") == -1) {
    258.   document.cookie = "subload_switch=on";
    259. }
    260.  
    261. if (document.cookie.indexOf("subload_switch=on") != -1) {
    262.   for (var i = 0; i < boardLinks.length; ++i) {
    263.     var hrefLink = boardLinks[i].innerHTML.match(/href=".*"/g) [0];
    264.     var url = hrefLink.substring(6, hrefLink.length - 1);
    265.     ajaxLoader(url, i);
    266.   }
    267. } else {
    268.   setTimeout(function() {
    269.     var userMenu = document.querySelector("ul.isuser");
    270.     if (userMenu !== null) {
    271.       if (document.getElementById("ngb_subload_switch") === null) {
    272.         userMenu.innerHTML += '<li><a id="ngb_subload_switch" data-status="off" style="margin-left: 10px; margin-right: 15px; cursor: pointer; text-decoration: none;" title="NGB Subload umschalten">NGB-Sl [an]</a></li>';
    273.         document.getElementById("ngb_subload_switch").addEventListener("click", toggleVisibility, true);  
    274.       }
    275.     } else {
    276.       var subMenu = document.querySelector("ul.floatcontainer > ul.floatcontainer");
    277.       if (document.getElementById("ngb_subload_switch") === null) {
    278.         subMenu.innerHTML += '<li><a id="ngb_subload_switch" class="popupmenu" data-status="off" style="margin-left: 30px; margin-right: 15px; cursor: pointer; text-decoration: none;" title="NGB Subload umschalten">NGB-Sl [an]</a></li>';
    279.         document.getElementById("ngb_subload_switch").addEventListener("click", toggleVisibility, true);  
    280.       }
    281.     }
    282.   }, 450);
    283. }
    Geändert von theSplit (11.06.17 um 10:56 Uhr) Grund: Update2: Für unangemeldete im Forummenü (Picdump Zeile)
    Gruß theSplit
    @ I might be sober. The good things... the bad things... all I ever know is here! @
    +++ thunderNote +++ Thom's Inventarverwaltung +++ Pi-Thread +++ IT-Talents Code Competitions +++ NGB-Statistik Opt-Out/Anonymisierung +++ Stonerhead +++ Add-on Flag Cookies +++ Google Image Directlinks +++ dwrox.net

  18. #18
    1998

    Veteran

    (Threadstarter)

    Avatar von theSplit
    Registriert seit
    Aug 2014
    Beiträge
    4.853
    ngb:news Artikel
    2

    Re: [Script] NGB Subload - Themenüberblick von Foren

    Update v1.2.2 (bitte nutzt v1.2.3, weiter unten)

    Changelog:
    - einen Button "NGB-Sl Buttons [an/aus] im Usermenü (für uneingeloggt im "Untermenü im Forum") hinzugefügt
    - neuer Button blendet den Button zum "Add to subload" / "Remove of subload" aus (über Cookies)
    - Fehlermeldungen zeigen nun auch auf die Zeile im Skript, in der der Fehler passiert ist
    - Code cleanups

    Code:
    1. // ==UserScript==
    2. // @name NGB Subloader
    3. // @namespace ngb_subload
    4. // @description NGB Subloader
    5. // @include https://ngb.to/
    6. // @include https://ngb.to/#*
    7. // @include https://ngb.to/forum*
    8. // @version 1.2.2
    9. // @grant none
    10. // ==/UserScript==
    11.  
    12. var loaded = 0;
    13. var hasLoaded = false;
    14. var boardLinks;
    15.  
    16. function toggleVisibility(event) {
    17.   var ngbSubloadDivs = document.getElementsByClassName("ngbSubloadDiv");
    18.  
    19.   var show = "inline-block";
    20.   if (event.target.dataset.status == "on") {
    21.     show = "none";
    22.     event.target.dataset.status = "off";
    23.     event.target.innerHTML = "NGB-Sl [an]";
    24.     document.cookie = "subload_switch=off";
    25.   } else {
    26.     event.target.dataset.status = "on";
    27.     event.target.innerHTML = "NGB-Sl [aus]";
    28.     document.cookie = "subload_switch=on";
    29.   }
    30.  
    31.   for (var i = 0; i < ngbSubloadDivs.length; ++i) {
    32.     ngbSubloadDivs[i].style.display = show;
    33.   }
    34.  
    35.   if (!hasLoaded) {
    36.     for (var i = 0; i < boardLinks.length; ++i) {
    37.       var hrefLink = boardLinks[i].innerHTML.match(/href=".*"/g) [0];
    38.       var url = hrefLink.substring(6, hrefLink.length - 1);
    39.       ajaxLoader(url, i);
    40.     }
    41.   }
    42.  
    43.   return false;
    44. }
    45.  
    46. function toggleButtons(event) {
    47.   var ngbSubloadToggles = document.getElementsByClassName("subLoadtoggleForum");
    48.  
    49.   var show = "inline-block";
    50.   if (event.target.dataset.status == "on") {
    51.     show = "none";
    52.     event.target.dataset.status = "off";
    53.     event.target.innerHTML = "NGB-Sl Buttons [an]";
    54.     document.cookie = "subload_switch_buttons=off";
    55.   } else {
    56.     event.target.dataset.status = "on";
    57.     event.target.innerHTML = "NGB-Sl Buttons [aus]";
    58.     document.cookie = "subload_switch_buttons=on";
    59.   }
    60.  
    61.   for (var i = 0; i < ngbSubloadToggles.length; ++i) {
    62.     ngbSubloadToggles[i].style.display = show;
    63.   }  
    64.  
    65.   return false;
    66. }
    67.  
    68.  
    69. function toggleSubLoad(event) {
    70.   var forumId = event.target.dataset.name;
    71.   if (document.cookie.indexOf("subload_"+ forumId +"=true") != -1) {
    72.     document.cookie = "subload_"+forumId+"=false";
    73.   } else {
    74.     document.cookie = "subload_"+forumId+"=true";
    75.   }
    76.  
    77.   var oldData = document.querySelector("div.ngbSubloadDiv."+forumId);
    78.   oldData.parentNode.removeChild(oldData);
    79.   loaded--;
    80.  
    81.   boardLinks = document.querySelectorAll('h2.forumtitle');
    82.   var index = parseInt(event.target.dataset.index);
    83.   var hrefLink = boardLinks[index].innerHTML.match(/href=".*"/g) [0];
    84.   var url = hrefLink.substring(6, hrefLink.length - 1);
    85.   ajaxLoader(url, index);
    86. }
    87.  
    88. function checkLoad() {
    89.   if (loaded >= boardLinks.length-2) {
    90.     var userMenu = document.querySelector("ul.isuser");
    91.     if (userMenu !== null) {
    92.       if (document.getElementById("ngb_subload_switch") === null) {
    93.         userMenu.innerHTML += '<li><a id="ngb_subload_switch_buttons" data-status="on" style="margin-right: 15px; cursor: pointer; text-decoration: none;" title="NGB Subload Buttons">NGB-Sl Buttons[aus]</a></li>';
    94.         userMenu.innerHTML += '<li><a id="ngb_subload_switch" data-status="on" style="margin-left: 10px; cursor: pointer; text-decoration: none;" title="NGB Subload umschalten">NGB-Sl [aus]</a></li>';
    95.         document.getElementById("ngb_subload_switch_buttons").addEventListener("click", toggleButtons, true);
    96.         document.getElementById("ngb_subload_switch").addEventListener("click", toggleVisibility, true);        
    97.       }
    98.     } else {
    99.       var subMenu = document.querySelector("ul.floatcontainer > ul.floatcontainer");
    100.       if (document.getElementById("ngb_subload_switch") === null) {
    101.         subMenu.innerHTML += '<li><a id="ngb_subload_switch" class="popupmenu" data-status="on" style="margin-left: 30px; cursor: pointer; text-decoration: none;" title="NGB Subload umschalten">NGB-Sl [aus]</a></li>';
    102.         subMenu.innerHTML += '<li><a id="ngb_subload_switch_buttons" class="popmenu" data-status="on" style="margin-right: 15px; cursor: pointer; text-decoration: none;" title="NGB Subload Buttons umschalten">NGB-Sl Buttons [aus]</a></li>';
    103.         document.getElementById("ngb_subload_switch_buttons").addEventListener("click", toggleButtons, true);
    104.         document.getElementById("ngb_subload_switch").addEventListener("click", toggleVisibility, true);
    105.       }
    106.     }
    107.    
    108.     var displayStr = "inline-block";
    109.     if (document.cookie.indexOf("subload_switch_buttons=off") != -1) {
    110.       displayStr = "none";
    111.     }
    112.  
    113.     var toggleButtonsArray = document.getElementsByClassName("subLoadtoggleForum");
    114.     for (var i = 0; i < toggleButtonsArray.length; ++i) {
    115.       toggleButtonsArray[i].addEventListener("click", toggleSubLoad, true);
    116.       toggleButtonsArray[i].style.display = displayStr;
    117.     }
    118.    
    119.     hasLoaded = true;
    120.   }
    121. }
    122.  
    123. function loaderChangeStatus(loader) {
    124.   loader = loader.target;
    125.   if (loader.readyState == 4 && loader.status == 200) {
    126.     data = loader.responseText.replace(/\n|\t|\b/g, '');
    127.     try {
    128.       var threadLinks = data.match(/class="titl.*<\/a>/g);
    129.       var threadLastPosts = data.match(/<a .*lastpostdate.*<\/a>/g);
    130.       var threadPrefixes = data.replace(/\n|\t|\b|\r/g, '').match(/id="thread_prefix.*\<\/span>/g);
    131.       var threadAuthors = data.match(/<a[\s\w\b].* popupctr.*<\/a>/g);
    132.       var threadTimes = data.match(/<dd>.*<\/span>/g);  
    133.     } catch (error) {
    134.       console.log("[ERROR] Error in script: "+ error + ", lineNumber, "+error.lineNumber+", loader: " + loader.responseURL);
    135.       loaded++;
    136.       return;
    137.     }
    138.    
    139.     for (var i = 0; i < threadTimes.length; i++) {
    140.       if (threadTimes[i].match(/"time"/) === null) {
    141.         threadTimes.splice(i, 1);
    142.         i--;
    143.       }
    144.     }
    145.    
    146.     var forumId = loader.parent.parentNode.parentNode.parentNode.parentNode.id
    147.     if (window.location.pathname.indexOf("/forums/") != -1) {
    148.       forumId = loader.parent.parentNode.parentNode.parentNode.parentNode.parentNode.id;
    149.     }
    150.    
    151.     var htmlData = '<div class="ngbSubloadDiv ' + forumId +'" style="clear: both; display: inline-block; width: 100%; margin: 10px 0px 10px 20px;">';
    152.  
    153.     if (document.cookie.indexOf("subload_"+ forumId +"=true") == -1) {
    154.       loader.parent.innerHTML += htmlData + '<button class="subLoadtoggleForum" data-name="'+forumId+'" data-index="'+ loader.index +'" style="clear:both; float: right; margin-top: 15px;">Add to subload</button></div>';
    155.       loaded++;
    156.      
    157.       checkLoad();
    158.       return;
    159.     }
    160.  
    161.     if (threadLinks.length !== 0) {
    162.       try {
    163.         var threadTitle = "";
    164.         var threadUrl = '';
    165.         var threadAuthor = '';
    166.         var threadAuthorId = 0;
    167.         var threadTime = '';
    168.         var threadId = "";
    169.         var lastThreadPrefix = 0;
    170.        
    171.         var now = new Date();        
    172.         var offset = 0;
    173.         var offsetUser = Math.abs(threadAuthors.length - threadLinks.length);
    174.        
    175.         for (var x = 0; x < 8; x++) {
    176.           if (offset + x + offsetUser == threadAuthors.length || offset + x == threadLinks.length || offset + x == threadTimes.length) {
    177.             break;
    178.           }
    179.  
    180.           threadTitle = threadLinks[x + offset].match(/">.*<\/a>/g)[0];
    181.           threadTitle = threadTitle.substring(2, threadTitle.length-4);
    182.           threadUrl = threadLastPosts[x + offset].match(/href="threads[\s\wäöüÄÖÜ\\\/\#\?\+\-\_\=\(\)\[\]]*/g)[0];
    183.           threadUrl = threadUrl.substr(6, threadUrl.length - 1);
    184.           threadAuthor = threadAuthors[x + offset + offsetUser].match(/<strong\>[\s\w\däöüÄÖÜ\-\\\\/_\(\)\[\]].*<\/strong>/g)[0];
    185.           threadAuthor = threadAuthor.substring(8,threadAuthor.length-9);
    186.           threadAuthorId = threadAuthors[x + offset].match(/members\/[0-9]*\-/g)[0];
    187.           threadAuthorId.substring(7, threadAuthorId.length);
    188.           threadTime = threadTimes[x + offset].replace(/<dd>|<span class="time">|<\/span>/g, '');
    189.           threadId = threadLinks[x + offset].match(/href="threads\/[0-9]*/g)[0];
    190.           threadId = threadId.substring(14, threadId.length);
    191.        
    192.           if (threadTime.indexOf("Heute,") === -1 && threadTime.indexOf("Gestern,") === -1) {
    193.             var timeDate = threadTime.match(/[0-9].?/g);
    194.             var dateObj = new Date();
    195.             dateObj.setDate(parseInt(timeDate[0]));
    196.             dateObj.setMonth(parseInt(timeDate[1])-1);
    197.             dateObj.setFullYear(parseInt("20"+timeDate[2]));
    198.             dateObj.setHours(parseInt(timeDate[3]));
    199.             dateObj.setMinutes(parseInt(timeDate[4]));
    200.             dateObj.setSeconds(0);
    201.             dateObj.setMilliseconds(0);
    202.             if (dateObj.getTime() < now - ((3600 * 1000) * 24 * 30)) { // 30 - Anzahl der Tage die Themen alt sein duerfen
    203.               offset++;
    204.               x--;
    205.               continue;
    206.             }
    207.           }
    208.          
    209.           var prefix = "";
    210.           if (threadPrefixes !== null) {
    211.             for (var i = lastThreadPrefix; i < threadPrefixes.length; ++i) {
    212.               if (threadPrefixes[i].indexOf(threadId) != -1) {
    213.                 lastThreadPrefix = i;
    214.                 prefix = threadPrefixes[i].match(/>[\s\w\b\-\_\(\)\[\]äöüÄÖÜ\:\,\;\#\+\*\&\/]*<\/span>/g)[0].trimRight();
    215.                 prefix = prefix.substring(1, prefix.length-7);
    216.               }
    217.             }  
    218.           }
    219.          
    220.           if (prefix != "") {
    221.             htmlData += '<span style="clear: both; float:left;"><i>' + prefix + '</i>&nbsp;<a href="https://ngb.to/' + threadUrl + '" target="_blank">' + threadTitle + '</a></span>';  
    222.           } else {
    223.             htmlData += '<a style="clear: left; float: left;" href="https://ngb.to/' + threadUrl + '" target="_blank">' + threadTitle + '</a>';
    224.           }
    225.          
    226.           htmlData += '<p style="display: block; text-align: right; margin-left: 10%;">[ <a href="https://ngb.to/members/'+threadAuthorId+threadAuthor+'">' + threadAuthor + '</a>, ' + threadTime + ' Uhr ]</p>';
    227.         }
    228.        
    229.         loader.parent.innerHTML += htmlData + '<button class="subLoadtoggleForum" data-name="'+forumId+'" data-index="'+loader.index+'" style="clear:both; float: right; margin-top: 15px;">Remove of subload</button></div>';
    230.         loaded++;
    231.         checkLoad();
    232.        
    233.       } catch (error) {
    234.         console.log("[ERROR] Error in script: "+ error + ", lineNumber, "+error.lineNumber+", loader: " + loader.responseURL);
    235.       }
    236.     }
    237.  
    238.   } else if (loader.readyState == 4) {
    239.     console.log("[ERROR] Loader status: " + loader.responseURL + " : (" + loader.status + ") "+ loader.statusText);
    240.     loaded++;
    241.     checkLoad();
    242.   }
    243.  
    244.   return;
    245. }
    246.  
    247. function ajaxLoader(url, index) {
    248.   var loader = new XMLHttpRequest();
    249.   loader.addEventListener('readystatechange', loaderChangeStatus);
    250.   loader.parent = boardLinks[index].parentNode.parentNode;
    251.   loader.index = index;
    252.  
    253.   var forumId = loader.parent.parentNode.parentNode.parentNode.parentNode.id;
    254.   if (window.location.pathname.indexOf("/forums/") != -1) {
    255.     forumId = loader.parent.parentNode.parentNode.parentNode.parentNode.parentNode.id;
    256.   }
    257.  
    258.   if (document.cookie.indexOf("subload_"+ forumId +"=true") == -1) {
    259.     var htmlData = '<div class="ngbSubloadDiv ' + forumId +'" style="clear: both; display: inline-block; width: 100%; margin: 10px 0px 10px 20px;">';
    260.     loader.parent.innerHTML += htmlData + '<button class="subLoadtoggleForum" data-name="'+forumId+'" data-index="'+loader.index+'" style="clear:both; float: right; margin-top: 15px;">Add to subload</button></div>';
    261.     loaded++;
    262.     checkLoad();
    263.     return;
    264.   }
    265.  
    266.   loader.open('GET', 'https://ngb.to/' + url.replace("http:\/\/", "https:\/\/"), true);
    267.   loader.send();
    268.   return;
    269. }
    270.        
    271. //-----------------------------------------------------------------------------------------------
    272.  
    273. boardLinks = document.querySelectorAll('h2.forumtitle');
    274. for (var i = 0; i < boardLinks.length; ++i) {
    275.   var forumId = boardLinks[i].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.id;
    276.  
    277.   if (window.location.pathname.indexOf("/forums/") != -1) {
    278.     forumId = boardLinks[i].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.id;
    279.   }
    280.  
    281.   if (document.cookie.indexOf("subload_"+ forumId +"=true") == -1 && document.cookie.indexOf("subload_"+ forumId +"=false") == -1) {
    282.     document.cookie = "subload_"+ forumId +"=false";
    283.   }
    284. }
    285.  
    286. // Check for existing subload main cookies
    287. if (document.cookie.indexOf("subload_switch=on") == -1 && document.cookie.indexOf("subload_switch=off") == -1) {
    288.   document.cookie = "subload_switch=on";
    289. }
    290. if (document.cookie.indexOf("subload_switch_buttons=on") == -1 && document.cookie.indexOf("subload_switch_buttons=off") == -1) {
    291.   document.cookie = "subload_switch_buttons=on";
    292. }
    293.  
    294. if (document.cookie.indexOf("subload_switch=on") != -1) {
    295.   for (var i = 0; i < boardLinks.length; ++i) {
    296.     var hrefLink = boardLinks[i].innerHTML.match(/href=".*"/g) [0];
    297.     var url = hrefLink.substring(6, hrefLink.length - 1);
    298.     ajaxLoader(url, i);
    299.   }
    300. } else {
    301.   setTimeout(function() {
    302.     var userMenu = document.querySelector("ul.isuser");
    303.     if (userMenu !== null) {
    304.       if (document.getElementById("ngb_subload_switch") === null) {
    305.         userMenu.innerHTML += '<li><a id="ngb_subload_switch_buttons" data-status="off" style="margin-right: 15px; cursor: pointer; text-decoration: none;" title="NGB Subload Buttons umschalten">NGB-Sl Buttons [an]</a></li>';
    306.         userMenu.innerHTML += '<li><a id="ngb_subload_switch" data-status="off" style="margin-left: 10px; cursor: pointer; text-decoration: none;" title="NGB Subload umschalten">NGB-Sl [an]</a></li>';
    307.         document.getElementById("ngb_subload_switch").addEventListener("click", toggleVisibility, true);  
    308.         document.getElementById("ngb_subload_switch_buttons").addEventListener("click", toggleButtons, true);
    309.       }
    310.     } else {
    311.       var subMenu = document.querySelector("ul.floatcontainer > ul.floatcontainer");
    312.       if (document.getElementById("ngb_subload_switch") === null) {
    313.         subMenu.innerHTML += '<li><a id="ngb_subload_switch" class="popupmenu" data-status="off" style="margin-left: 30px; cursor: pointer; text-decoration: none;" title="NGB Subload umschalten">NGB-Sl [an]</a></li>';
    314.         subMenu.innerHTML += '<li><a id="ngb_subload_switch_buttons" class="popupmenu" data-status="off" style="margin-right: 15px; cursor: pointer; text-decoration: none;" title="NGB Subload Buttons umschalten">NGB-Sl Buttons [an]</a></li>';
    315.         document.getElementById("ngb_subload_switch").addEventListener("click", toggleVisibility, true);
    316.         document.getElementById("ngb_subload_switch_buttons").addEventListener("click", toggleButtons, true);
    317.       }
    318.     }
    319.   }, 450);
    320. }
    321.  
    Update 1.2.3 (1.2.4 weiter unten!)
    - Important Change: Die Schalter für Subload sind nun nicht mehr im Usermenü, sondern auf einer Höhe mit der Breadcrumb Liste, weil ansonsten die "Popups" für die Menüs nicht mehr funktioniert haben, nachdem die Subload Einträge hinzugefügt worden sind.
    - Change: Die Schalter sind nun keine Textlinks mehr, sondern Buttons
    - Bugfix "Der Button ein/ausschalter" hatte nicht den korrekten Status beim Neuladen übernommen


    Code:
    1.  
    2. // ==UserScript==
    3. // @name NGB Subloader
    4. // @namespace ngb_subload
    5. // @description NGB Subloader
    6. // @include https://ngb.to/
    7. // @include https://ngb.to/#*
    8. // @include https://ngb.to/forum*
    9. // @version 1.2.3
    10. // @grant none
    11. // ==/UserScript==
    12.  
    13. var loaded = 0;
    14. var hasLoaded = false;
    15. var boardLinks;
    16.  
    17. function toggleVisibility(event) {
    18.   var ngbSubloadDivs = document.getElementsByClassName("ngbSubloadDiv");
    19.  
    20.   var show = "inline-block";
    21.   if (event.target.dataset.status == "on") {
    22.     show = "none";
    23.     event.target.dataset.status = "off";
    24.     event.target.innerHTML = "NGB-Sl [an]";
    25.     document.cookie = "subload_switch=off";
    26.   } else {
    27.     event.target.dataset.status = "on";
    28.     event.target.innerHTML = "NGB-Sl [aus]";
    29.     document.cookie = "subload_switch=on";
    30.   }
    31.  
    32.   for (var i = 0; i < ngbSubloadDivs.length; ++i) {
    33.     ngbSubloadDivs[i].style.display = show;
    34.   }
    35.  
    36.   if (!hasLoaded) {
    37.     for (var i = 0; i < boardLinks.length; ++i) {
    38.       var hrefLink = boardLinks[i].innerHTML.match(/href=".*"/g) [0];
    39.       var url = hrefLink.substring(6, hrefLink.length - 1);
    40.       ajaxLoader(url, i);
    41.     }
    42.   }
    43.  
    44.   return false;
    45. }
    46.  
    47. function toggleButtons(event) {
    48.   var ngbSubloadToggles = document.getElementsByClassName("subLoadtoggleForum");
    49.  
    50.   var show = "inline-block";
    51.   if (event.target.dataset.status == "on") {
    52.     show = "none";
    53.     event.target.dataset.status = "off";
    54.     event.target.innerHTML = "NGB-Sl Buttons [an]";
    55.     document.cookie = "subload_switch_buttons=off";
    56.   } else {
    57.     event.target.dataset.status = "on";
    58.     event.target.innerHTML = "NGB-Sl Buttons [aus]";
    59.     document.cookie = "subload_switch_buttons=on";
    60.   }
    61.  
    62.   for (var i = 0; i < ngbSubloadToggles.length; ++i) {
    63.     ngbSubloadToggles[i].style.display = show;
    64.   }  
    65.  
    66.   return false;
    67. }
    68.  
    69.  
    70. function toggleSubLoad(event) {
    71.   var forumId = event.target.dataset.name;
    72.   if (document.cookie.indexOf("subload_"+ forumId +"=true") != -1) {
    73.     document.cookie = "subload_"+forumId+"=false";
    74.   } else {
    75.     document.cookie = "subload_"+forumId+"=true";
    76.   }
    77.  
    78.   var oldData = document.querySelector("div.ngbSubloadDiv."+forumId);
    79.   oldData.parentNode.removeChild(oldData);
    80.   loaded--;
    81.  
    82.   boardLinks = document.querySelectorAll('h2.forumtitle');
    83.   var index = parseInt(event.target.dataset.index);
    84.   var hrefLink = boardLinks[index].innerHTML.match(/href=".*"/g) [0];
    85.   var url = hrefLink.substring(6, hrefLink.length - 1);
    86.   ajaxLoader(url, index);
    87. }
    88.  
    89. function checkLoad() {
    90.   if (loaded >= boardLinks.length-2) {
    91.    
    92.     var subLoadStatus = "off";
    93.     var subLoadText = "an";
    94.     if (document.cookie.indexOf("subload_switch=on") != -1) {
    95.       subLoadStatus = "on";
    96.       subLoadText = "aus";
    97.     }
    98.    
    99.     var buttonStatus = "off";
    100.     var buttonText = "an";
    101.     if (document.cookie.indexOf("subload_switch_buttons=on") != -1) {
    102.       buttonStatus = "on";
    103.       buttonText = "aus";
    104.     }
    105.    
    106.     var subMenu = document.querySelector("div.breadcrumb > ul");
    107.     if (document.getElementById("ngb_subload_switch") === null) {
    108.       subMenu.innerHTML += '<li><div style="float: right;"> \
    109.         <button id="ngb_subload_switch" data-status="'+ subLoadStatus +'" style="margin-right: 10px; cursor: pointer; text-decoration: none;" title="NGB Subload umschalten">NGB-Sl ['+ subLoadText +']</button> \
    110.         <button id="ngb_subload_switch_buttons" data-status="'+ buttonStatus +'" style="cursor: pointer; text-decoration: none;" title="NGB Subload Buttons umschalten">NGB-Sl Buttons ['+ buttonText +']</button></div></li>';
    111.       document.getElementById("ngb_subload_switch").addEventListener("click", toggleVisibility, true);
    112.       document.getElementById("ngb_subload_switch_buttons").addEventListener("click", toggleButtons, true);
    113.     }
    114.  
    115.  
    116.     var displayStr = "inline-block";
    117.     if (document.cookie.indexOf("subload_switch_buttons=off") != -1) {
    118.       displayStr = "none";
    119.     }
    120.  
    121.     var toggleButtonsArray = document.getElementsByClassName("subLoadtoggleForum");
    122.     for (var i = 0; i < toggleButtonsArray.length; ++i) {
    123.       toggleButtonsArray[i].addEventListener("click", toggleSubLoad, true);
    124.       toggleButtonsArray[i].style.display = displayStr;
    125.     }
    126.    
    127.     hasLoaded = true;
    128.   }
    129. }
    130.  
    131. function loaderChangeStatus(loader) {
    132.   loader = loader.target;
    133.   if (loader.readyState == 4 && loader.status == 200) {
    134.     data = loader.responseText.replace(/\n|\t|\b/g, '');
    135.     try {
    136.       var threadLinks = data.match(/class="titl.*<\/a>/g);
    137.       var threadLastPosts = data.match(/<a .*lastpostdate.*<\/a>/g);
    138.       var threadPrefixes = data.replace(/\n|\t|\b|\r/g, '').match(/id="thread_prefix.*\<\/span>/g);
    139.       var threadAuthors = data.match(/<a[\s\w\b].* popupctr.*<\/a>/g);
    140.       var threadTimes = data.match(/<dd>.*<\/span>/g);  
    141.     } catch (error) {
    142.       console.log("[ERROR] Error in script: "+ error + ", lineNumber, "+error.lineNumber+", loader: " + loader.responseURL);
    143.       loaded++;
    144.       return;
    145.     }
    146.    
    147.     for (var i = 0; i < threadTimes.length; i++) {
    148.       if (threadTimes[i].match(/"time"/) === null) {
    149.         threadTimes.splice(i, 1);
    150.         i--;
    151.       }
    152.     }
    153.    
    154.     var forumId = loader.parent.parentNode.parentNode.parentNode.parentNode.id
    155.     if (window.location.pathname.indexOf("/forums/") != -1) {
    156.       forumId = loader.parent.parentNode.parentNode.parentNode.parentNode.parentNode.id;
    157.     }
    158.    
    159.     var htmlData = '<div class="ngbSubloadDiv ' + forumId +'" style="clear: both; display: inline-block; width: 100%; margin: 10px 0px 10px 20px;">';
    160.  
    161.     if (document.cookie.indexOf("subload_"+ forumId +"=true") == -1) {
    162.       loader.parent.innerHTML += htmlData + '<button class="subLoadtoggleForum" data-name="'+forumId+'" data-index="'+ loader.index +'" style="clear:both; float: right; margin-top: 15px;">Add to subload</button></div>';
    163.       loaded++;
    164.      
    165.       checkLoad();
    166.       return;
    167.     }
    168.  
    169.     if (threadLinks.length !== 0) {
    170.       try {
    171.         var threadTitle = "";
    172.         var threadUrl = '';
    173.         var threadAuthor = '';
    174.         var threadAuthorId = 0;
    175.         var threadTime = '';
    176.         var threadId = "";
    177.         var lastThreadPrefix = 0;
    178.        
    179.         var now = new Date();        
    180.         var offset = 0;
    181.         var offsetUser = Math.abs(threadAuthors.length - threadLinks.length);
    182.        
    183.         for (var x = 0; x < 8; x++) {
    184.           if (offset + x + offsetUser == threadAuthors.length || offset + x == threadLinks.length || offset + x == threadTimes.length) {
    185.             break;
    186.           }
    187.  
    188.           threadTitle = threadLinks[x + offset].match(/">.*<\/a>/g)[0];
    189.           threadTitle = threadTitle.substring(2, threadTitle.length-4);
    190.           threadUrl = threadLastPosts[x + offset].match(/href="threads[\s\wäöüÄÖÜ\\\/\#\?\+\-\_\=\(\)\[\]]*/g)[0];
    191.           threadUrl = threadUrl.substr(6, threadUrl.length - 1);
    192.           threadAuthor = threadAuthors[x + offset + offsetUser].match(/<strong\>[\s\w\däöüÄÖÜ\-\\\\/_\(\)\[\]].*<\/strong>/g)[0];
    193.           threadAuthor = threadAuthor.substring(8,threadAuthor.length-9);
    194.           threadAuthorId = threadAuthors[x + offset].match(/members\/[0-9]*\-/g)[0];
    195.           threadAuthorId.substring(7, threadAuthorId.length);
    196.           threadTime = threadTimes[x + offset].replace(/<dd>|<span class="time">|<\/span>/g, '');
    197.           threadId = threadLinks[x + offset].match(/href="threads\/[0-9]*/g)[0];
    198.           threadId = threadId.substring(14, threadId.length);
    199.        
    200.           if (threadTime.indexOf("Heute,") === -1 && threadTime.indexOf("Gestern,") === -1) {
    201.             var timeDate = threadTime.match(/[0-9].?/g);
    202.             var dateObj = new Date();
    203.             dateObj.setDate(parseInt(timeDate[0]));
    204.             dateObj.setMonth(parseInt(timeDate[1])-1);
    205.             dateObj.setFullYear(parseInt("20"+timeDate[2]));
    206.             dateObj.setHours(parseInt(timeDate[3]));
    207.             dateObj.setMinutes(parseInt(timeDate[4]));
    208.             dateObj.setSeconds(0);
    209.             dateObj.setMilliseconds(0);
    210.             if (dateObj.getTime() < now - ((3600 * 1000) * 24 * 30)) { // 30 - Anzahl der Tage die Themen alt sein duerfen
    211.               offset++;
    212.               x--;
    213.               continue;
    214.             }
    215.           }
    216.          
    217.           var prefix = "";
    218.           if (threadPrefixes !== null) {
    219.             for (var i = lastThreadPrefix; i < threadPrefixes.length; ++i) {
    220.               if (threadPrefixes[i].indexOf(threadId) != -1) {
    221.                 lastThreadPrefix = i;
    222.                 prefix = threadPrefixes[i].match(/>[\s\w\b\-\_\(\)\[\]äöüÄÖÜ\:\,\;\#\+\*\&\/]*<\/span>/g)[0].trimRight();
    223.                 prefix = prefix.substring(1, prefix.length-7);
    224.               }
    225.             }  
    226.           }
    227.          
    228.           if (prefix != "") {
    229.             htmlData += '<span style="clear: both; float:left;"><i>' + prefix + '</i>&nbsp;<a href="https://ngb.to/' + threadUrl + '" target="_blank">' + threadTitle + '</a></span>';  
    230.           } else {
    231.             htmlData += '<a style="clear: left; float: left;" href="https://ngb.to/' + threadUrl + '" target="_blank">' + threadTitle + '</a>';
    232.           }
    233.          
    234.           htmlData += '<p style="display: block; text-align: right; margin-left: 10%;">[ <a href="https://ngb.to/members/'+threadAuthorId+threadAuthor+'">' + threadAuthor + '</a>, ' + threadTime + ' Uhr ]</p>';
    235.         }
    236.        
    237.         loader.parent.innerHTML += htmlData + '<button class="subLoadtoggleForum" data-name="'+forumId+'" data-index="'+loader.index+'" style="clear:both; float: right; margin-top: 15px;">Remove of subload</button></div>';
    238.         loaded++;
    239.         checkLoad();
    240.        
    241.       } catch (error) {
    242.         console.log("[ERROR] Error in script: "+ error + ", lineNumber, "+error.lineNumber+", loader: " + loader.responseURL);
    243.       }
    244.     }
    245.  
    246.   } else if (loader.readyState == 4) {
    247.     console.log("[ERROR] Loader status: " + loader.responseURL + " : (" + loader.status + ") "+ loader.statusText);
    248.     loaded++;
    249.     checkLoad();
    250.   }
    251.  
    252.   return;
    253. }
    254.  
    255. function ajaxLoader(url, index) {
    256.   var loader = new XMLHttpRequest();
    257.   loader.addEventListener('readystatechange', loaderChangeStatus);
    258.   loader.parent = boardLinks[index].parentNode.parentNode;
    259.   loader.index = index;
    260.  
    261.   var forumId = loader.parent.parentNode.parentNode.parentNode.parentNode.id;
    262.   if (window.location.pathname.indexOf("/forums/") != -1) {
    263.     forumId = loader.parent.parentNode.parentNode.parentNode.parentNode.parentNode.id;
    264.   }
    265.  
    266.   if (document.cookie.indexOf("subload_"+ forumId +"=true") == -1) {
    267.     var htmlData = '<div class="ngbSubloadDiv ' + forumId +'" style="clear: both; display: inline-block; width: 100%; margin: 10px 0px 10px 20px;">';
    268.     loader.parent.innerHTML += htmlData + '<button class="subLoadtoggleForum" data-name="'+forumId+'" data-index="'+loader.index+'" style="clear:both; float: right; margin-top: 15px;">Add to subload</button></div>';
    269.     loaded++;
    270.     checkLoad();
    271.     return;
    272.   }
    273.  
    274.   loader.open('GET', 'https://ngb.to/' + url.replace("http:\/\/", "https:\/\/"), true);
    275.   loader.send();
    276.   return;
    277. }
    278.        
    279. //-----------------------------------------------------------------------------------------------
    280.  
    281. boardLinks = document.querySelectorAll('h2.forumtitle');
    282. for (var i = 0; i < boardLinks.length; ++i) {
    283.   var forumId = boardLinks[i].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.id;
    284.  
    285.   if (window.location.pathname.indexOf("/forums/") != -1) {
    286.     forumId = boardLinks[i].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.id;
    287.   }
    288.  
    289.   if (document.cookie.indexOf("subload_"+ forumId +"=true") == -1 && document.cookie.indexOf("subload_"+ forumId +"=false") == -1) {
    290.     document.cookie = "subload_"+ forumId +"=false";
    291.   }
    292. }
    293.  
    294. // Check for existing subload main cookies
    295. if (document.cookie.indexOf("subload_switch=on") == -1 && document.cookie.indexOf("subload_switch=off") == -1) {
    296.   document.cookie = "subload_switch=on";
    297. }
    298. if (document.cookie.indexOf("subload_switch_buttons=on") == -1 && document.cookie.indexOf("subload_switch_buttons=off") == -1) {
    299.   document.cookie = "subload_switch_buttons=on";
    300. }
    301.  
    302. if (document.cookie.indexOf("subload_switch=on") != -1) {
    303.   for (var i = 0; i < boardLinks.length; ++i) {
    304.     var hrefLink = boardLinks[i].innerHTML.match(/href=".*"/g) [0];
    305.     var url = hrefLink.substring(6, hrefLink.length - 1);
    306.     ajaxLoader(url, i);
    307.   }
    308. } else {
    309.   setTimeout(function() {
    310.         var subLoadStatus = "off";
    311.     var subLoadText = "an";
    312.     if (document.cookie.indexOf("subload_switch=on") != -1) {
    313.       subLoadStatus = "on";
    314.       subLoadText = "aus";
    315.     }
    316.    
    317.     var buttonStatus = "off";
    318.     var buttonText = "an";
    319.     if (document.cookie.indexOf("subload_switch_buttons=on") != -1) {
    320.       buttonStatus = "on";
    321.       buttonText = "aus";
    322.     }
    323.    
    324.     var subMenu = document.querySelector("div.breadcrumb > ul");
    325.     if (document.getElementById("ngb_subload_switch") === null) {
    326.       subMenu.innerHTML += '<li><div style="float: right;"> \
    327.         <button id="ngb_subload_switch" data-status="'+ subLoadStatus +'" style="margin-right: 10px; cursor: pointer; text-decoration: none;" title="NGB Subload umschalten">NGB-Sl ['+ subLoadText +']</button> \
    328.         <button id="ngb_subload_switch_buttons" data-status="'+ buttonStatus +'" style="cursor: pointer; text-decoration: none;" title="NGB Subload Buttons umschalten">NGB-Sl Buttons ['+ buttonText +']</button></div></li>';
    329.       document.getElementById("ngb_subload_switch").addEventListener("click", toggleVisibility, true);
    330.       document.getElementById("ngb_subload_switch_buttons").addEventListener("click", toggleButtons, true);
    331.     }
    332.   }, 450);
    333. }
    334.  

    Update 1.2.4

    - Change: Einstellung über Variable: "useGMinsteadOfCookies" (Standard: true)
    .... welche aussagt das wir SQLite über GM_setValue/GM_getValue nutzen, und nicht Cookies, welche gelöscht werden können. Wer Cookies verwenden will, muß Zeile 17 den Wert auf "false" (ohne "") setzen.


    Code:
    1. // ==UserScript==
    2. // @name NGB Subloader
    3. // @namespace ngb_subload
    4. // @description NGB Subloader
    5. // @include https://ngb.to/
    6. // @include https://ngb.to/#*
    7. // @include https://ngb.to/forum*
    8. // @version 1.2.4
    9. // @author theSplit
    10. // @grant GM_setValue
    11. // @grant GM_getValue
    12. // ==/UserScript==
    13.  
    14.  
    15.  
    16. // Change either to: true OR false ---- in order to use OR not to use GM_setValue and GM_getValue with SQLite as storage out side the cookies, default: true
    17. var useGMinsteadOfCookies = true;
    18.  
    19. // Dont change this
    20. var loaded = 0;
    21. var hasLoaded = false;
    22. var boardLinks;
    23.  
    24.  
    25. function toggleVisibility(event) {
    26.   var ngbSubloadDivs = document.getElementsByClassName("ngbSubloadDiv");
    27.  
    28.   var show = "inline-block";
    29.   if (event.target.dataset.status == "on") {
    30.     show = "none";
    31.     event.target.dataset.status = "off";
    32.     event.target.innerHTML = "NGB-Sl [an]";
    33.     if (useGMinsteadOfCookies) {
    34.       GM_setValue("subload_switch", "off");
    35.     } else {
    36.       document.cookie = "subload_switch=off";
    37.     }
    38.  
    39.   } else {
    40.     event.target.dataset.status = "on";
    41.     event.target.innerHTML = "NGB-Sl [aus]";
    42.     if (useGMinsteadOfCookies) {
    43.       GM_setValue("subload_switch", "on");
    44.     } else {
    45.       document.cookie = "subload_switch=on";
    46.     }
    47.   }
    48.  
    49.   for (var i = 0; i < ngbSubloadDivs.length; ++i) {
    50.     ngbSubloadDivs[i].style.display = show;
    51.   }
    52.  
    53.   if (!hasLoaded) {
    54.     for (var i = 0; i < boardLinks.length; ++i) {
    55.       var hrefLink = boardLinks[i].innerHTML.match(/href=".*"/g) [0];
    56.       var url = hrefLink.substring(6, hrefLink.length - 1);
    57.       ajaxLoader(url, i);
    58.     }
    59.   }
    60.  
    61.   return false;
    62. }
    63.  
    64. function toggleButtons(event) {
    65.   var ngbSubloadToggles = document.getElementsByClassName("subLoadtoggleForum");
    66.  
    67.   var show = "inline-block";
    68.   if (event.target.dataset.status == "on") {
    69.     show = "none";
    70.     event.target.dataset.status = "off";
    71.     event.target.innerHTML = "NGB-Sl Buttons [an]";
    72.  
    73.     if (useGMinsteadOfCookies) {
    74.       GM_setValue("subload_switch_buttons", "off");
    75.     } else {
    76.       document.cookie = "subload_switch_buttons=off";
    77.     }
    78.   } else {
    79.     event.target.dataset.status = "on";
    80.     event.target.innerHTML = "NGB-Sl Buttons [aus]";
    81.  
    82.     if (useGMinsteadOfCookies) {
    83.       GM_setValue("subload_switch_buttons", "on");
    84.     } else {
    85.       document.cookie = "subload_switch_buttons=on";
    86.     }
    87.   }
    88.  
    89.   for (var i = 0; i < ngbSubloadToggles.length; ++i) {
    90.     ngbSubloadToggles[i].style.display = show;
    91.   }  
    92.  
    93.   return false;
    94. }
    95.  
    96.  
    97. function toggleSubLoad(event) {
    98.   var forumId = event.target.dataset.name;
    99.   if (useGMinsteadOfCookies) {
    100.     if (GM_getValue("subload_"+ forumId) == "true") {
    101.       GM_setValue("subload_"+ forumId, "false");
    102.     } else {
    103.       GM_setValue("subload_"+ forumId, "true");
    104.     }
    105.   } else {
    106.     if (document.cookie.indexOf("subload_"+ forumId +"=true") != -1) {
    107.       document.cookie = "subload_"+forumId+"=false";
    108.     } else {
    109.       document.cookie = "subload_"+forumId+"=true";
    110.     }
    111.   }
    112.  
    113.   var oldData = document.querySelector("div.ngbSubloadDiv."+forumId);
    114.   oldData.parentNode.removeChild(oldData);
    115.   loaded--;
    116.  
    117.   boardLinks = document.querySelectorAll('h2.forumtitle');
    118.   var index = parseInt(event.target.dataset.index);
    119.   var hrefLink = boardLinks[index].innerHTML.match(/href=".*"/g) [0];
    120.   var url = hrefLink.substring(6, hrefLink.length - 1);
    121.   ajaxLoader(url, index);
    122. }
    123.  
    124. function checkLoad() {
    125.   if (loaded >= boardLinks.length-2) {
    126.  
    127.     var subLoadStatus = "off";
    128.     var subLoadText = "an";
    129.  
    130.     var buttonStatus = "off";
    131.     var buttonText = "an";
    132.  
    133.     if ((!useGMinsteadOfCookies && document.cookie.indexOf("subload_switch=on") != -1) || (useGMinsteadOfCookies && GM_getValue("subload_switch") == "on")) {
    134.       subLoadStatus = "on";
    135.       subLoadText = "aus";
    136.     }
    137.  
    138.     if ((!useGMinsteadOfCookies && document.cookie.indexOf("subload_switch_buttons=on") != -1) || (useGMinsteadOfCookies && GM_getValue("subload_switch_buttons") == "on")) {
    139.       buttonStatus = "on";
    140.       buttonText = "aus";
    141.     }  
    142.  
    143.     var subMenu = document.querySelector("div.breadcrumb > ul");
    144.     if (document.getElementById("ngb_subload_switch") === null) {
    145.       subMenu.innerHTML += '<li><div style="float: right;"> \
    146. <button id="ngb_subload_switch" data-status="'+ subLoadStatus +'" style="margin-right: 10px; cursor: pointer; text-decoration: none;" title="NGB Subload umschalten">NGB-Sl ['+ subLoadText +']</button> \
    147. <button id="ngb_subload_switch_buttons" data-status="'+ buttonStatus +'" style="cursor: pointer; text-decoration: none;" title="NGB Subload Buttons umschalten">NGB-Sl Buttons ['+ buttonText +']</button></div></li>';
    148.       document.getElementById("ngb_subload_switch").addEventListener("click", toggleVisibility, true);
    149.       document.getElementById("ngb_subload_switch_buttons").addEventListener("click", toggleButtons, true);
    150.     }
    151.  
    152.     var displayStr = "inline-block";
    153.     if ((!useGMinsteadOfCookies && document.cookie.indexOf("subload_switch_buttons=off") != -1) || (useGMinsteadOfCookies && GM_getValue("subload_switch_buttons") == "off")) {
    154.       displayStr = "none";
    155.     }
    156.  
    157.     var toggleButtonsArray = document.getElementsByClassName("subLoadtoggleForum");
    158.     for (var i = 0; i < toggleButtonsArray.length; ++i) {
    159.       toggleButtonsArray[i].addEventListener("click", toggleSubLoad, true);
    160.       toggleButtonsArray[i].style.display = displayStr;
    161.     }
    162.  
    163.     hasLoaded = true;
    164.   }
    165. }
    166.  
    167. function loaderChangeStatus(loader) {
    168.   loader = loader.target;
    169.   if (loader.readyState == 4 && loader.status == 200) {
    170.     data = loader.responseText.replace(/\n|\t|\b/g, '');
    171.     try {
    172.       var threadLinks = data.match(/class="titl.*<\/a>/g);
    173.       var threadLastPosts = data.match(/<a .*lastpostdate.*<\/a>/g);
    174.       var threadPrefixes = data.replace(/\n|\t|\b|\r/g, '').match(/id="thread_prefix.*\<\/span>/g);
    175.       var threadAuthors = data.match(/<a[\s\w\b].* popupctr.*<\/a>/g);
    176.       var threadTimes = data.match(/<dd>.*<\/span>/g);  
    177.     } catch (error) {
    178.       console.log("[ERROR] Error in script: "+ error + ", lineNumber, "+error.lineNumber+", loader: " + loader.responseURL);
    179.       loaded++;
    180.       return;
    181.     }
    182.  
    183.     for (var i = 0; i < threadTimes.length; i++) {
    184.       if (threadTimes[i].match(/"time"/) === null) {
    185.         threadTimes.splice(i, 1);
    186.         i--;
    187.       }
    188.     }
    189.  
    190.     var forumId = loader.parent.parentNode.parentNode.parentNode.parentNode.id
    191.     if (window.location.pathname.indexOf("/forums/") != -1) {
    192.       forumId = loader.parent.parentNode.parentNode.parentNode.parentNode.parentNode.id;
    193.     }
    194.  
    195.     var htmlData = '<div class="ngbSubloadDiv ' + forumId +'" style="clear: both; display: inline-block; width: 100%; margin: 10px 0px 10px 20px;">';
    196.  
    197.     if ((!useGMinsteadOfCookies && document.cookie.indexOf("subload_"+ forumId +"=true") == -1) || (useGMinsteadOfCookies && GM_getValue("subload_"+forumId) == "false")) {
    198.       loader.parent.innerHTML += htmlData + '<button class="subLoadtoggleForum" data-name="'+forumId+'" data-index="'+ loader.index +'" style="clear:both; float: right; margin-top: 15px;">Add to subload</button></div>';
    199.       loaded++;
    200.  
    201.       checkLoad();
    202.       return;
    203.     }
    204.  
    205.  
    206.     if (threadLinks.length !== 0) {
    207.       try {
    208.         var threadTitle = "";
    209.         var threadUrl = '';
    210.         var threadAuthor = '';
    211.         var threadAuthorId = 0;
    212.         var threadTime = '';
    213.         var threadId = "";
    214.         var lastThreadPrefix = 0;
    215.  
    216.         var now = new Date();        
    217.         var offset = 0;
    218.         var offsetUser = Math.abs(threadAuthors.length - threadLinks.length);
    219.  
    220.         for (var x = 0; x < 8; x++) {
    221.           if (offset + x + offsetUser == threadAuthors.length || offset + x == threadLinks.length || offset + x == threadTimes.length) {
    222.             break;
    223.           }
    224.  
    225.           threadTitle = threadLinks[x + offset].match(/">.*<\/a>/g)[0];
    226.           threadTitle = threadTitle.substring(2, threadTitle.length-4);
    227.           threadUrl = threadLastPosts[x + offset].match(/href="threads[\s\wäöüÄÖÜ\\\/\#\?\+\-\_\=\(\)\[\]]*/g)[0];
    228.           threadUrl = threadUrl.substr(6, threadUrl.length - 1);
    229.           threadAuthor = threadAuthors[x + offset + offsetUser].match(/<strong\>[\s\w\däöüÄÖÜ\-\\\\/_\(\)\[\]].*<\/strong>/g)[0];
    230.           threadAuthor = threadAuthor.substring(8,threadAuthor.length-9);
    231.           threadAuthorId = threadAuthors[x + offset].match(/members\/[0-9]*\-/g)[0];
    232.           threadAuthorId.substring(7, threadAuthorId.length);
    233.           threadTime = threadTimes[x + offset].replace(/<dd>|<span class="time">|<\/span>/g, '');
    234.           threadId = threadLinks[x + offset].match(/href="threads\/[0-9]*/g)[0];
    235.           threadId = threadId.substring(14, threadId.length);
    236.  
    237.           if (threadTime.indexOf("Heute,") === -1 && threadTime.indexOf("Gestern,") === -1) {
    238.             var timeDate = threadTime.match(/[0-9].?/g);
    239.             var dateObj = new Date();
    240.             dateObj.setDate(parseInt(timeDate[0]));
    241.             dateObj.setMonth(parseInt(timeDate[1])-1);
    242.             dateObj.setFullYear(parseInt("20"+timeDate[2]));
    243.             dateObj.setHours(parseInt(timeDate[3]));
    244.             dateObj.setMinutes(parseInt(timeDate[4]));
    245.             dateObj.setSeconds(0);
    246.             dateObj.setMilliseconds(0);
    247.             if (dateObj.getTime() < now - ((3600 * 1000) * 24 * 30)) { // 30 - Anzahl der Tage die Themen alt sein duerfen
    248.               offset++;
    249.               x--;
    250.               continue;
    251.             }
    252.           }
    253.  
    254.           var prefix = "";
    255.           if (threadPrefixes !== null) {
    256.             for (var i = lastThreadPrefix; i < threadPrefixes.length; ++i) {
    257.               if (threadPrefixes[i].indexOf(threadId) != -1) {
    258.                 lastThreadPrefix = i;
    259.                 prefix = threadPrefixes[i].match(/>[\s\w\b\-\_\(\)\[\]äöüÄÖÜ\:\,\;\#\+\*\&\/]*<\/span>/g)[0].trimRight();
    260.                 prefix = prefix.substring(1, prefix.length-7);
    261.               }
    262.             }  
    263.           }
    264.  
    265.           if (prefix != "") {
    266.             htmlData += '<span style="clear: both; float:left;"><i>' + prefix + '</i>&nbsp;<a href="https://ngb.to/' + threadUrl + '" target="_blank">' + threadTitle + '</a></span>';  
    267.           } else {
    268.             htmlData += '<a style="clear: left; float: left;" href="https://ngb.to/' + threadUrl + '" target="_blank">' + threadTitle + '</a>';
    269.           }
    270.  
    271.           htmlData += '<p style="display: block; text-align: right; margin-left: 10%;">[ <a href="https://ngb.to/members/'+threadAuthorId+threadAuthor+'">' + threadAuthor + '</a>, ' + threadTime + ' Uhr ]</p>';
    272.         }
    273.  
    274.         loader.parent.innerHTML += htmlData + '<button class="subLoadtoggleForum" data-name="'+forumId+'" data-index="'+loader.index+'" style="clear:both; float: right; margin-top: 15px;">Remove of subload</button></div>';
    275.         loaded++;
    276.         checkLoad();
    277.  
    278.       } catch (error) {
    279.         console.log("[ERROR] Error in script: "+ error + ", lineNumber, "+error.lineNumber+", loader: " + loader.responseURL);
    280.       }
    281.     }
    282.  
    283.   } else if (loader.readyState == 4) {
    284.     console.log("[ERROR] Loader status: " + loader.responseURL + " : (" + loader.status + ") "+ loader.statusText);
    285.     loaded++;
    286.     checkLoad();
    287.   }
    288.  
    289.   return;
    290. }
    291.  
    292. function ajaxLoader(url, index) {
    293.   var loader = new XMLHttpRequest();
    294.   loader.addEventListener('readystatechange', loaderChangeStatus);
    295.   loader.parent = boardLinks[index].parentNode.parentNode;
    296.   loader.index = index;
    297.  
    298.   var forumId = loader.parent.parentNode.parentNode.parentNode.parentNode.id;
    299.   if (window.location.pathname.indexOf("/forums/") != -1) {
    300.     forumId = loader.parent.parentNode.parentNode.parentNode.parentNode.parentNode.id;
    301.   }
    302.  
    303.   if ((!useGMinsteadOfCookies && document.cookie.indexOf("subload_"+ forumId +"=true") == -1) || (useGMinsteadOfCookies && GM_getValue("subload_"+forumId) == "false")) {
    304.     var htmlData = '<div class="ngbSubloadDiv ' + forumId +'" style="clear: both; display: inline-block; width: 100%; margin: 10px 0px 10px 20px;">';
    305.     loader.parent.innerHTML += htmlData + '<button class="subLoadtoggleForum" data-name="'+forumId+'" data-index="'+loader.index+'" style="clear:both; float: right; margin-top: 15px;">Add to subload</button></div>';
    306.     loaded++;
    307.     checkLoad();
    308.     return;
    309.   }
    310.  
    311.   loader.open('GET', 'https://ngb.to/' + url.replace("http:\/\/", "https:\/\/"), true);
    312.   loader.send();
    313.   return;
    314. }
    315.  
    316. boardLinks = document.querySelectorAll('h2.forumtitle');
    317. for (var i = 0; i < boardLinks.length; ++i) {
    318.   var forumId = boardLinks[i].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.id;
    319.  
    320.   if (window.location.pathname.indexOf("/forums/") != -1) {
    321.     forumId = boardLinks[i].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.id;
    322.   }
    323.  
    324.   if (useGMinsteadOfCookies && GM_getValue("subload_"+forumId) != "true" && GM_getValue("subload_"+forumId) != "false") {
    325.     GM_setValue("subload_"+forumId, "false");
    326.   } else if (document.cookie.indexOf("subload_"+ forumId +"=true") == -1 && document.cookie.indexOf("subload_"+ forumId +"=false") == -1) {
    327.     document.cookie = "subload_"+ forumId +"=false";
    328.   }
    329. }
    330.  
    331. // Check for existing subload main cookies
    332. var subLoadOn = true;
    333. var buttonsOn = true;
    334. if (useGMinsteadOfCookies) {
    335.   if (GM_getValue("subload_switch") != "on" && GM_getValue("subload_switch") != "off") {
    336.     GM_setValue("subload_switch", "on");
    337.   } else if (GM_getValue("subload_switch") != "on") {
    338.     subLoadOn = false;
    339.   }
    340.  
    341.   if (GM_getValue("subload_switch_buttons") != "on" && GM_getValue("subload_switch_buttons") != "off") {
    342.     GM_setValue("subload_switch_buttons", "on");
    343.   } else if (GM_getValue("subload_switch_buttons") != "on") {
    344.     buttonsOn = false;
    345.   }
    346. } else {
    347.   if (document.cookie.indexOf("subload_switch=on") == -1 && document.cookie.indexOf("subload_switch=off") == -1) {
    348.     document.cookie = "subload_switch=on";
    349.   } else if (document.cookie.indexOf("subload_switch=on") == -1) {
    350.     subLoadOn = false;
    351.   }
    352.  
    353.   if (document.cookie.indexOf("subload_switch_buttons=on") == -1 && document.cookie.indexOf("subload_switch_buttons=off") == -1) {
    354.     document.cookie = "subload_switch_buttons=on";
    355.   } else if (document.cookie.indexOf("subload_switch_buttons=on") == -1) {
    356.     buttonsOn = false;
    357.   }
    358. }
    359.  
    360. if (subLoadOn) {
    361.   for (var i = 0; i < boardLinks.length; ++i) {
    362.     var hrefLink = boardLinks[i].innerHTML.match(/href=".*"/g) [0];
    363.     var url = hrefLink.substring(6, hrefLink.length - 1);
    364.     ajaxLoader(url, i);
    365.   }
    366. } else {
    367.   var subLoadStatus = "off";
    368.   var subLoadText = "an";
    369.  
    370.   var buttonStatus = "off";
    371.   var buttonText = "an";
    372.  
    373.   if (subLoadOn) {
    374.     subLoadStatus = "on";
    375.     subLoadText = "aus";
    376.   }
    377.  
    378.   if (buttonsOn) {
    379.     buttonStatus = "on";
    380.     buttonText = "aus";
    381.   }
    382.  
    383.   var subMenu = document.querySelector("div.breadcrumb > ul");
    384.   if (document.getElementById("ngb_subload_switch") === null) {
    385.     subMenu.innerHTML += '<li><div style="float: right;"> \
    386. <button id="ngb_subload_switch" data-status="'+ subLoadStatus +'" style="margin-right: 10px; cursor: pointer; text-decoration: none;" title="NGB Subload umschalten">NGB-Sl ['+ subLoadText +']</button> \
    387. <button id="ngb_subload_switch_buttons" data-status="'+ buttonStatus +'" style="cursor: pointer; text-decoration: none;" title="NGB Subload Buttons umschalten">NGB-Sl Buttons ['+ buttonText +']</button></div></li>';
    388.     document.getElementById("ngb_subload_switch").addEventListener("click", toggleVisibility, true);
    389.     document.getElementById("ngb_subload_switch_buttons").addEventListener("click", toggleButtons, true);
    390.   }
    391. }
    392.  
    Geändert von theSplit (12.06.17 um 21:54 Uhr) Grund: Version 1.2.4
    Gruß theSplit
    @ I might be sober. The good things... the bad things... all I ever know is here! @
    +++ thunderNote +++ Thom's Inventarverwaltung +++ Pi-Thread +++ IT-Talents Code Competitions +++ NGB-Statistik Opt-Out/Anonymisierung +++ Stonerhead +++ Add-on Flag Cookies +++ Google Image Directlinks +++ dwrox.net

  19. #19
    1998

    Veteran

    (Threadstarter)

    Avatar von theSplit
    Registriert seit
    Aug 2014
    Beiträge
    4.853
    ngb:news Artikel
    2

    Re: [Script] NGB Subload - Themenüberblick von Foren

    Update 1.2.5 (Bugfix)

    - Waren Themen in einem Forum "verschoben", sind die Benutzer um eine Stelle verrutscht - dies ist nun behoben (dies könnte auch bereits gemeldete Probleme beheben mit den Nicknames beheben)
    - Verschobene Themen haben keine Information zum letzten Benutzer des Themas, also werden diese korrekterweise nicht angezeigt
    - Themen mit "ß" werden nun auch korrekt eingelesen (Update 1)
    - Themen mit "!" werden nun auch korrekt eingelesen (Update 2)


    Code:
    1. // ==UserScript==
    2. // @name NGB Subloader
    3. // @namespace ngb_subload
    4. // @description NGB Subloader
    5. // @include https://ngb.to/
    6. // @include https://ngb.to/#*
    7. // @include https://ngb.to/forum*
    8. // @version 1.2.5
    9. // @author theSplit
    10. // @grant GM_setValue
    11. // @grant GM_getValue
    12. // ==/UserScript==
    13.  
    14.  
    15.  
    16. // Change either to: true OR false ---- in order to use OR not to use GM_setValue and GM_getValue with SQLite as storage out side the cookies, defaults: true
    17. var useGMinsteadOfCookies = true;
    18.  
    19. // Dont change this
    20. var loaded = 0;
    21. var hasLoaded = false;
    22. var boardLinks;
    23.  
    24.  
    25. function toggleVisibility(event) {
    26.   var ngbSubloadDivs = document.getElementsByClassName("ngbSubloadDiv");
    27.  
    28.   var show = "inline-block";
    29.   if (event.target.dataset.status == "on") {
    30.     show = "none";
    31.     event.target.dataset.status = "off";
    32.     event.target.innerHTML = "NGB-Sl [an]";
    33.     if (useGMinsteadOfCookies) {
    34.       GM_setValue("subload_switch", "off");
    35.     } else {
    36.       document.cookie = "subload_switch=off";
    37.     }
    38.  
    39.   } else {
    40.     event.target.dataset.status = "on";
    41.     event.target.innerHTML = "NGB-Sl [aus]";
    42.     if (useGMinsteadOfCookies) {
    43.       GM_setValue("subload_switch", "on");
    44.     } else {
    45.       document.cookie = "subload_switch=on";
    46.     }
    47.   }
    48.  
    49.   for (var i = 0; i < ngbSubloadDivs.length; ++i) {
    50.     ngbSubloadDivs[i].style.display = show;
    51.   }
    52.  
    53.   if (!hasLoaded) {
    54.     for (var i = 0; i < boardLinks.length; ++i) {
    55.       var hrefLink = boardLinks[i].innerHTML.match(/href=".*"/g) [0];
    56.       var url = hrefLink.substring(6, hrefLink.length - 1);
    57.       ajaxLoader(url, i);
    58.     }
    59.   }
    60.  
    61.   return false;
    62. }
    63.  
    64. function toggleButtons(event) {
    65.   var ngbSubloadToggles = document.getElementsByClassName("subLoadtoggleForum");
    66.  
    67.   var show = "inline-block";
    68.   if (event.target.dataset.status == "on") {
    69.     show = "none";
    70.     event.target.dataset.status = "off";
    71.     event.target.innerHTML = "NGB-Sl Buttons [an]";
    72.  
    73.     if (useGMinsteadOfCookies) {
    74.       GM_setValue("subload_switch_buttons", "off");
    75.     } else {
    76.       document.cookie = "subload_switch_buttons=off";
    77.     }
    78.   } else {
    79.     event.target.dataset.status = "on";
    80.     event.target.innerHTML = "NGB-Sl Buttons [aus]";
    81.  
    82.     if (useGMinsteadOfCookies) {
    83.       GM_setValue("subload_switch_buttons", "on");
    84.     } else {
    85.       document.cookie = "subload_switch_buttons=on";
    86.     }
    87.   }
    88.  
    89.   for (var i = 0; i < ngbSubloadToggles.length; ++i) {
    90.     ngbSubloadToggles[i].style.display = show;
    91.   }  
    92.  
    93.   return false;
    94. }
    95.  
    96.  
    97. function toggleSubLoad(event) {
    98.   var forumId = event.target.dataset.name;
    99.   if (useGMinsteadOfCookies) {
    100.     if (GM_getValue("subload_"+ forumId) == "true") {
    101.       GM_setValue("subload_"+ forumId, "false");
    102.     } else {
    103.       GM_setValue("subload_"+ forumId, "true");
    104.     }
    105.   } else {
    106.     if (document.cookie.indexOf("subload_"+ forumId +"=true") != -1) {
    107.       document.cookie = "subload_"+forumId+"=false";
    108.     } else {
    109.       document.cookie = "subload_"+forumId+"=true";
    110.     }
    111.   }
    112.  
    113.   var oldData = document.querySelector("div.ngbSubloadDiv."+forumId);
    114.   oldData.parentNode.removeChild(oldData);
    115.   loaded--;
    116.  
    117.   boardLinks = document.querySelectorAll('h2.forumtitle');
    118.   var index = parseInt(event.target.dataset.index);
    119.   var hrefLink = boardLinks[index].innerHTML.match(/href=".*"/g) [0];
    120.   var url = hrefLink.substring(6, hrefLink.length - 1);
    121.   ajaxLoader(url, index);
    122. }
    123.  
    124. function checkLoad() {
    125.   if (loaded >= boardLinks.length-2) {
    126.  
    127.     var subLoadStatus = "off";
    128.     var subLoadText = "an";
    129.  
    130.     var buttonStatus = "off";
    131.     var buttonText = "an";
    132.  
    133.     if ((!useGMinsteadOfCookies && document.cookie.indexOf("subload_switch=on") != -1) || (useGMinsteadOfCookies && GM_getValue("subload_switch") == "on")) {
    134.       subLoadStatus = "on";
    135.       subLoadText = "aus";
    136.     }
    137.  
    138.     if ((!useGMinsteadOfCookies && document.cookie.indexOf("subload_switch_buttons=on") != -1) || (useGMinsteadOfCookies && GM_getValue("subload_switch_buttons") == "on")) {
    139.       buttonStatus = "on";
    140.       buttonText = "aus";
    141.     }  
    142.  
    143.     var subMenu = document.querySelector("div.breadcrumb > ul");
    144.     if (document.getElementById("ngb_subload_switch") === null) {
    145.       subMenu.innerHTML += '<li><div style="float: right;"> \
    146. <button id="ngb_subload_switch" data-status="'+ subLoadStatus +'" style="margin-right: 10px; cursor: pointer; text-decoration: none;" title="NGB Subload umschalten">NGB-Sl ['+ subLoadText +']</button> \
    147. <button id="ngb_subload_switch_buttons" data-status="'+ buttonStatus +'" style="cursor: pointer; text-decoration: none;" title="NGB Subload Buttons umschalten">NGB-Sl Buttons ['+ buttonText +']</button></div></li>';
    148.       document.getElementById("ngb_subload_switch").addEventListener("click", toggleVisibility, true);
    149.       document.getElementById("ngb_subload_switch_buttons").addEventListener("click", toggleButtons, true);
    150.     }
    151.  
    152.     var displayStr = "inline-block";
    153.     if ((!useGMinsteadOfCookies && document.cookie.indexOf("subload_switch_buttons=off") != -1) || (useGMinsteadOfCookies && GM_getValue("subload_switch_buttons") == "off")) {
    154.       displayStr = "none";
    155.     }
    156.  
    157.     var toggleButtonsArray = document.getElementsByClassName("subLoadtoggleForum");
    158.     for (var i = 0; i < toggleButtonsArray.length; ++i) {
    159.       toggleButtonsArray[i].addEventListener("click", toggleSubLoad, true);
    160.       toggleButtonsArray[i].style.display = displayStr;
    161.     }
    162.  
    163.     hasLoaded = true;
    164.   }
    165. }
    166.  
    167. function loaderChangeStatus(loader) {
    168.   loader = loader.target;
    169.   if (loader.readyState == 4 && loader.status == 200) {
    170.     data = loader.responseText.replace(/\n|\t|\b/g, '');
    171.  
    172.     try {
    173.       var threadLinks = data.match(/class="title.*<\/a>/g);
    174.       var threadLastPosts = data.match(/<a .*lastpostdate.*\<\/a\>/g);
    175.       var threadPrefixes = data.replace(/\n|\t|\b|\r/g, '').match(/id="thread_prefix.*\<\/span\>/g);
    176.       var threadAuthors = data.match(/<a[\s\w\b].* popupctr.*\<\/a\>/g);
    177.       var threadTimes = data.match(/<dd>.*class="time".*\<\/span\>/g);  
    178.     } catch (error) {
    179.       console.log("[ERROR] Error in script: "+ error + ", lineNumber, "+error.lineNumber+", loader: " + loader.responseURL);
    180.       loaded++;
    181.       return;
    182.     }
    183.  
    184.     for (var i = 0; i < threadTimes.length; i++) {
    185.       if (threadTimes[i].match(/"time"/) === null) {
    186.         threadTimes.splice(i, 1);
    187.         i--;
    188.       }
    189.     }
    190.  
    191.     var forumId = loader.parent.parentNode.parentNode.parentNode.parentNode.id
    192.     if (window.location.pathname.indexOf("/forums/") != -1) {
    193.       forumId = loader.parent.parentNode.parentNode.parentNode.parentNode.parentNode.id;
    194.     }
    195.  
    196.     var htmlData = '<div class="ngbSubloadDiv ' + forumId +'" style="clear: both; display: inline-block; width: 100%; margin: 10px 0px 10px 20px;">';
    197.  
    198.     if ((!useGMinsteadOfCookies && document.cookie.indexOf("subload_"+ forumId +"=true") == -1) || (useGMinsteadOfCookies && GM_getValue("subload_"+forumId) == "false")) {
    199.       loader.parent.innerHTML += htmlData + '<button class="subLoadtoggleForum" data-name="'+forumId+'" data-index="'+ loader.index +'" style="clear:both; float: right; margin-top: 15px;">Add to subload</button></div>';
    200.       loaded++;
    201.  
    202.       checkLoad();
    203.       return;
    204.     }
    205.  
    206.  
    207.     if (threadLinks.length !== 0) {
    208.       try {
    209.         var threadsMoved = 0;
    210.  
    211.         if (threadPrefixes !== null) {
    212.           for (var i = 0; i < threadPrefixes.length; ++i) {
    213.             if (threadPrefixes[i].indexOf("Verschoben") != -1) {
    214.               ++threadsMoved;
    215.             }
    216.           }  
    217.         }
    218.        
    219.         var threadTitle = "";
    220.         var threadUrl = '';
    221.         var threadAuthor = '';
    222.         var threadAuthorId = 0;
    223.         var threadTime = '';
    224.         var threadId = "";
    225.         var lastThreadPrefix = 0;
    226.         var lastMovedThread = 0;
    227.  
    228.         var now = new Date();        
    229.         var offset = 0;
    230.         var offsetUser = Math.abs(threadAuthors.length - threadLinks.length) - threadsMoved;
    231.  
    232.         for (var x = 0; x < 8; x++) {
    233.           if (offset + x + offsetUser == threadAuthors.length || offset + x == threadLinks.length || offset + x == threadTimes.length) {
    234.             break;
    235.           }
    236.  
    237.           threadTitle = threadLinks[x + offset].match(/\"\>.*\<\/a\>/g)[0];
    238.           threadTitle = threadTitle.substring(2, threadTitle.length-4);
    239.           threadUrl = threadLastPosts[x + offset].match(/href="threads[\s\wäöüÄÖÜ\\\/\ß\#\?\+\-\_\=\(\)\[\]\!\%\$]*/g)[0];
    240.           threadUrl = threadUrl.substring(6, threadUrl.length);
    241.           threadId = threadLinks[x + offset].match(/href="threads\/[0-9]*/g)[0];
    242.           threadId = threadId.substring(14, threadId.length);
    243.           threadTime = threadTimes[x + offset].replace(/\<dd\>|\<span class\=\"time\"\>|<\/span>/g, '');
    244.           threadAuthor = threadAuthors[x + offset + offsetUser].match(/\<strong\>.*<\/strong>/g)[0];
    245.           threadAuthor = threadAuthor.substring(8,threadAuthor.length-9);
    246.           threadAuthorId = threadAuthors[x + offset].match(/members\/[0-9]*\-/g)[0];
    247.           threadAuthorId.substring(7, threadAuthorId.length);  
    248.          
    249.           if (threadTime.indexOf("Heute,") === -1 && threadTime.indexOf("Gestern,") === -1) {
    250.             var timeDate = threadTime.match(/[0-9].?/g);
    251.             var dateObj = new Date();
    252.             dateObj.setDate(parseInt(timeDate[0]));
    253.             dateObj.setMonth(parseInt(timeDate[1])-1);
    254.             dateObj.setFullYear(parseInt("20"+timeDate[2]));
    255.             dateObj.setHours(parseInt(timeDate[3]));
    256.             dateObj.setMinutes(parseInt(timeDate[4]));
    257.             dateObj.setSeconds(0);
    258.             dateObj.setMilliseconds(0);
    259.             if (dateObj.getTime() < now - ((3600 * 1000) * 24 * 30)) { // 30 - Anzahl der Tage die Themen alt sein duerfen
    260.               offset++;
    261.               x--;
    262.               continue;
    263.             }
    264.           }
    265.  
    266.           var prefix = "";
    267.           if (threadPrefixes !== null) {
    268.             for (var i = lastThreadPrefix; i < threadPrefixes.length; ++i) {
    269.               if (threadPrefixes[i].indexOf(threadId+'"') != -1) {
    270.                 lastThreadPrefix = i+1;
    271.                 prefix = threadPrefixes[i].match(/>[\s\w\b\-\_\(\)\[\]äöüÄÖÜ\:\,\;\#\+\*\&\/]*<\/span>/g)[0].trimRight();
    272.                 prefix = prefix.substring(1, prefix.length-7);
    273.               }
    274.             }  
    275.           }
    276.  
    277.           if (prefix != "") {
    278.             htmlData += '<span style="clear: both; float:left;"><i>' + prefix + '</i>&nbsp;<a href="https://ngb.to/' + threadUrl + '" target="_blank">' + threadTitle + '</a></span>';  
    279.           } else {
    280.             htmlData += '<a style="clear: left; float: left;" href="https://ngb.to/' + threadUrl + '" target="_blank">' + threadTitle + '</a>';
    281.           }
    282.          
    283.           if (prefix.indexOf("Verschoben") == -1) {
    284.             htmlData += '<p style="display: block; text-align: right; margin-left: 10%;">[ <a href="https://ngb.to/members/'+threadAuthorId+threadAuthor+'">' + threadAuthor + '</a>, ' + threadTime + ' Uhr ]</p>';
    285.           } else {
    286.             htmlData += '<p style="display: block; text-align: right; margin-left: 10%;">[ ' + threadTime + ' Uhr ]</p>';
    287.           }
    288.         }
    289.  
    290.         loader.parent.innerHTML += htmlData + '<button class="subLoadtoggleForum" data-name="'+forumId+'" data-index="'+loader.index+'" style="clear:both; float: right; margin-top: 15px;">Remove of subload</button></div>';
    291.         loaded++;
    292.         checkLoad();
    293.  
    294.       } catch (error) {
    295.         console.log("[ERROR] Error in script: "+ error + ", lineNumber, "+error.lineNumber+", loader: " + loader.responseURL);
    296.       }
    297.     }
    298.  
    299.   } else if (loader.readyState == 4) {
    300.     console.log("[ERROR] Loader status: " + loader.responseURL + " : (" + loader.status + ") "+ loader.statusText);
    301.     loaded++;
    302.     checkLoad();
    303.   }
    304.  
    305.   return;
    306. }
    307.  
    308. function ajaxLoader(url, index) {
    309.   var loader = new XMLHttpRequest();
    310.   loader.addEventListener('readystatechange', loaderChangeStatus);
    311.   loader.parent = boardLinks[index].parentNode.parentNode;
    312.   loader.index = index;
    313.  
    314.   var forumId = loader.parent.parentNode.parentNode.parentNode.parentNode.id;
    315.   if (window.location.pathname.indexOf("/forums/") != -1) {
    316.     forumId = loader.parent.parentNode.parentNode.parentNode.parentNode.parentNode.id;
    317.   }
    318.  
    319.   if ((!useGMinsteadOfCookies && document.cookie.indexOf("subload_"+ forumId +"=true") == -1) || (useGMinsteadOfCookies && GM_getValue("subload_"+forumId) == "false")) {
    320.     var htmlData = '<div class="ngbSubloadDiv ' + forumId +'" style="clear: both; display: inline-block; width: 100%; margin: 10px 0px 10px 20px;">';
    321.     loader.parent.innerHTML += htmlData + '<button class="subLoadtoggleForum" data-name="'+forumId+'" data-index="'+loader.index+'" style="clear:both; float: right; margin-top: 15px;">Add to subload</button></div>';
    322.     loaded++;
    323.     checkLoad();
    324.     return;
    325.   }
    326.  
    327.   loader.open('GET', 'https://ngb.to/' + url.replace("http:\/\/", "https:\/\/"), true);
    328.   loader.send();
    329.   return;
    330. }
    331.  
    332. boardLinks = document.querySelectorAll('h2.forumtitle');
    333. for (var i = 0; i < boardLinks.length; ++i) {
    334.   var forumId = boardLinks[i].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.id;
    335.  
    336.   if (window.location.pathname.indexOf("/forums/") != -1) {
    337.     forumId = boardLinks[i].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.id;
    338.   }
    339.  
    340.   if (useGMinsteadOfCookies && GM_getValue("subload_"+forumId) != "true" && GM_getValue("subload_"+forumId) != "false") {
    341.     GM_setValue("subload_"+forumId, "false");
    342.   } else if (document.cookie.indexOf("subload_"+ forumId +"=true") == -1 && document.cookie.indexOf("subload_"+ forumId +"=false") == -1) {
    343.     document.cookie = "subload_"+ forumId +"=false";
    344.   }
    345. }
    346.  
    347. // Check for existing subload main cookies
    348. var subLoadOn = true;
    349. var buttonsOn = true;
    350. if (useGMinsteadOfCookies) {
    351.   if (GM_getValue("subload_switch") != "on" && GM_getValue("subload_switch") != "off") {
    352.     GM_setValue("subload_switch", "on");
    353.   } else if (GM_getValue("subload_switch") != "on") {
    354.     subLoadOn = false;
    355.   }
    356.  
    357.   if (GM_getValue("subload_switch_buttons") != "on" && GM_getValue("subload_switch_buttons") != "off") {
    358.     GM_setValue("subload_switch_buttons", "on");
    359.   } else if (GM_getValue("subload_switch_buttons") != "on") {
    360.     buttonsOn = false;
    361.   }
    362. } else {
    363.   if (document.cookie.indexOf("subload_switch=on") == -1 && document.cookie.indexOf("subload_switch=off") == -1) {
    364.     document.cookie = "subload_switch=on";
    365.   } else if (document.cookie.indexOf("subload_switch=on") == -1) {
    366.     subLoadOn = false;
    367.   }
    368.  
    369.   if (document.cookie.indexOf("subload_switch_buttons=on") == -1 && document.cookie.indexOf("subload_switch_buttons=off") == -1) {
    370.     document.cookie = "subload_switch_buttons=on";
    371.   } else if (document.cookie.indexOf("subload_switch_buttons=on") == -1) {
    372.     buttonsOn = false;
    373.   }
    374. }
    375.  
    376. if (subLoadOn) {
    377.   for (var i = 0; i < boardLinks.length; ++i) {
    378.     var hrefLink = boardLinks[i].innerHTML.match(/href=".*"/g) [0];
    379.     var url = hrefLink.substring(6, hrefLink.length - 1);
    380.     ajaxLoader(url, i);
    381.   }
    382. } else {
    383.   var subLoadStatus = "off";
    384.   var subLoadText = "an";
    385.  
    386.   var buttonStatus = "off";
    387.   var buttonText = "an";
    388.  
    389.   if (subLoadOn) {
    390.     subLoadStatus = "on";
    391.     subLoadText = "aus";
    392.   }
    393.  
    394.   if (buttonsOn) {
    395.     buttonStatus = "on";
    396.     buttonText = "aus";
    397.   }
    398.  
    399.   var subMenu = document.querySelector("div.breadcrumb > ul");
    400.   if (document.getElementById("ngb_subload_switch") === null) {
    401.     subMenu.innerHTML += '<li><div style="float: right;"> \
    402. <button id="ngb_subload_switch" data-status="'+ subLoadStatus +'" style="margin-right: 10px; cursor: pointer; text-decoration: none;" title="NGB Subload umschalten">NGB-Sl ['+ subLoadText +']</button> \
    403. <button id="ngb_subload_switch_buttons" data-status="'+ buttonStatus +'" style="cursor: pointer; text-decoration: none;" title="NGB Subload Buttons umschalten">NGB-Sl Buttons ['+ buttonText +']</button></div></li>';
    404.     document.getElementById("ngb_subload_switch").addEventListener("click", toggleVisibility, true);
    405.     document.getElementById("ngb_subload_switch_buttons").addEventListener("click", toggleButtons, true);
    406.   }
    407. }
    Geändert von theSplit (10.02.18 um 16:39 Uhr) Grund: Themen mit "ß" + "!"... einlesen korrigiert/ergänzt
    Gruß theSplit
    @ I might be sober. The good things... the bad things... all I ever know is here! @
    +++ thunderNote +++ Thom's Inventarverwaltung +++ Pi-Thread +++ IT-Talents Code Competitions +++ NGB-Statistik Opt-Out/Anonymisierung +++ Stonerhead +++ Add-on Flag Cookies +++ Google Image Directlinks +++ dwrox.net

  20. #20
    1998

    Veteran

    (Threadstarter)

    Avatar von theSplit
    Registriert seit
    Aug 2014
    Beiträge
    4.853
    ngb:news Artikel
    2

    Re: [Script] NGB Subload - Themenüberblick von Foren

    Update auf 1.2.6

    - Cookie Speicherung komplett deaktivert, nun werden nur noch die GM.get/.set verwendet um Einstellungen zu speichern
    - Aktualisiert auf Greasemonkey GM.setValue and GM.getValue Funktionen, auch in Hinblick das Werte als Promises zurückgeliefert werden
    - Fehler behoben das Benutzernamen/Zeiten/Titel in Foren mit Unterforen falsch dargestellt werden
    - Hinzugefügt das Postings und Themen von Unterforen, so fern das letzte, im Hauptforum sichtbare, Posting nicht älter als 30 Tage alt ist, mit angezeigt werden
    - Fehler behoben das Zeitangaben falsche Zeiten verursachen
    - URLs mit Parametern/Ankern hinzugefügt die das Skript hier im Forum auslösen können....
    - Behoben, das verschobene Themen die anzeige Fehlerhaft gemacht haben
    - Regex etwas weiter angepasst, was in einem Regex weniger endete
    - Code Cleanups

    Viel Spaß damit!


    Greasemonkey Code:

    Spoiler: 



    Code:
    1.  
    2. // ==UserScript==
    3. // @name    NGB Subloader
    4. // @namespace   ngb_subload
    5. // @description NGB Subloader
    6. // @include https://ngb.to/
    7. // @include https://ngb.to/?*
    8. // @include https://ngb.to/#*
    9. // @include https://ngb.to/forum*
    10. // @version 1.2.6
    11. // @author  theSplit
    12. // @grant   GM.getValue
    13. // @grant   GM.setValue
    14. // ==/UserScript==
    15.  
    16. var loaded = 0
    17. var hasLoaded = false
    18. var boardLinks
    19.  
    20. async function toggleButtons (event) {
    21.   var ngbSubloadToggles = document.getElementsByClassName('subLoadtoggleForum')
    22.  
    23.   var show = 'inline-block'
    24.   if (event.target.dataset.status === 'on') {
    25.     show = 'none'
    26.     event.target.dataset.status = 'off'
    27.     event.target.innerHTML = 'NGB-Sl Buttons [an]'
    28.     await GM.setValue('subload_switch_buttons', 'off')
    29.   } else {
    30.     event.target.dataset.status = 'on'
    31.     event.target.innerHTML = 'NGB-Sl Buttons [aus]'
    32.     await GM.setValue('subload_switch_buttons', 'on')
    33.   }
    34.  
    35.   for (var i = 0; i < ngbSubloadToggles.length; ++i) {
    36.     ngbSubloadToggles[i].style.display = show
    37.   }
    38.  
    39.   return false
    40. }
    41.  
    42. async function toggleSubLoad (event) {
    43.   var forumId = event.target.dataset.name
    44.   var forumState = await GM.getValue('subload_' + forumId, 'false') === 'true' ? 'false' : 'true'
    45.   await GM.setValue('subload_' + forumId, forumState)
    46.  
    47.   var oldData = document.querySelector('div.ngbSubloadDiv.' + forumId)
    48.   oldData.parentNode.removeChild(oldData)
    49.   loaded--
    50.  
    51.   boardLinks = document.querySelectorAll('h2.forumtitle')
    52.   var index = parseInt(event.target.dataset.index)
    53.   var hrefLink = boardLinks[index].innerHTML.match(/href=".*"/g)[0]
    54.   var url = hrefLink.substring(6, hrefLink.length - 1)
    55.   ajaxLoader(url, index)
    56. }
    57.  
    58. async function checkLoad () {
    59.   if (loaded >= boardLinks.length - 2) {
    60.     var subLoadStatus = 'off'
    61.     var subLoadText = 'an'
    62.  
    63.     var buttonStatus = 'off'
    64.     var buttonText = 'an'
    65.  
    66.     if (await GM.getValue('subload_switch', 'on') === 'on') {
    67.       subLoadStatus = 'on'
    68.       subLoadText = 'aus'
    69.     }
    70.  
    71.     if (await GM.getValue('subload_switch_buttons', 'on') === 'on') {
    72.       buttonStatus = 'on'
    73.       buttonText = 'aus'
    74.     }
    75.  
    76.     var subMenu = document.querySelector('div.breadcrumb > ul')
    77.     if (document.getElementById('ngb_subload_switch') === null) {
    78.       subMenu.innerHTML += '<li><div style="float: right;"><button id="ngb_subload_switch" data-status="' + subLoadStatus + '" style="margin-right: 10px; cursor: pointer; text-decoration: none;" title="NGB Subload umschalten">NGB-Sl [' + subLoadText + ']</button><button id="ngb_subload_switch_buttons" data-status="' + buttonStatus + '" style="cursor: pointer; text-decoration: none;" title="NGB Subload Buttons umschalten">NGB-Sl Buttons [' + buttonText + ']</button></div></li>'
    79.       document.getElementById('ngb_subload_switch').addEventListener('click', toggleVisibility, true)
    80.       document.getElementById('ngb_subload_switch_buttons').addEventListener('click', toggleButtons, true)
    81.     }
    82.  
    83.     var displayStr
    84.     if (await GM.getValue('subload_switch_buttons', 'on') === 'off') displayStr = 'none'
    85.     else displayStr = 'inline-block'
    86.  
    87.     var toggleButtonsList = document.querySelectorAll('.subLoadtoggleForum')
    88.     for (var button of toggleButtonsList) {
    89.       button.addEventListener('click', toggleSubLoad, true)
    90.       button.style.display = displayStr
    91.     }
    92.  
    93.     hasLoaded = true
    94.   }
    95. }
    96.  
    97. async function loaderChangeStatus (loader) {
    98.   loader = loader.target
    99.   if (loader.readyState === 4 && loader.status === 200) {
    100.     var data = loader.responseText.replace(/\n|\t|\b/g, '')
    101.     var i = 0
    102.  
    103.     try {
    104.       var threadLinks = data.match(/<a.*(id|class)="(thread_title|threadtitle).*<\/a>/g)
    105.       var threadPrefixes = data.replace(/\n|\t|\b|\r/g, '').match(/id="thread_prefix.*<\/span>/g)
    106.       var threadAuthors = data.match(/<a.*username.*popupctr.*<\/a>/g)
    107.       var threadTimes = data.match(/(<dd>|<p).*class="time".*<\/span>/g)
    108.       var threadTitleData = data.replace(/\n|\t|\b|\r/g, '').match(/class="threadtitle".*<\/a>/g)
    109.     } catch (error) {
    110.       console.log('[ERROR] Error in script: ' + error + ', lineNumber, ' + error.lineNumber + ', loader: ' + loader.responseURL)
    111.       loaded++
    112.       return
    113.     }
    114.  
    115.     for (i = 0; i < threadTimes.length; i++) {
    116.       if (threadTimes[i].match(/"time"/) === null) {
    117.         threadTimes.splice(i, 1)
    118.         i--
    119.       }
    120.     }
    121.  
    122.     var forumId = loader.parent.parentNode.parentNode.parentNode.parentNode.id
    123.     if (window.location.pathname.indexOf('/forums/') !== -1) {
    124.       forumId = loader.parent.parentNode.parentNode.parentNode.parentNode.parentNode.id
    125.     }
    126.  
    127.     var htmlData = '<div class="ngbSubloadDiv ' + forumId + '" style="clear: both; display: inline-block; width: 100%; margin: 10px 0px 10px 20px;">'
    128.  
    129.     if (await GM.getValue('subload_' + forumId, 'true') === 'false') {
    130.       loader.parent.innerHTML += htmlData + '<button class="subLoadtoggleForum" data-name="' + forumId + '" data-index="' + loader.index + '" style="clear:both; float: right; margin-top: 15px;">Add to subload</button></div>'
    131.       loaded++
    132.  
    133.       checkLoad()
    134.       return
    135.     }
    136.  
    137.     if (threadLinks.length !== 0) {
    138.       try {
    139.         var threadsMoved = []
    140.  
    141.         if (threadPrefixes !== null) {
    142.           for (i = 0; i < threadLinks.length; ++i) {
    143.             if (threadTitleData[i] !== undefined && threadTitleData[i].indexOf('id="thread_prefix') !== -1 && threadTitleData[i].indexOf('Verschoben:') !== -1) threadsMoved.push(i)
    144.           }
    145.         }
    146.  
    147.         var threadTitle = ''
    148.         var threadUrl = ''
    149.         var threadAuthor = ''
    150.         var threadAuthorId = 0
    151.         var threadTime = ''
    152.         var threadId = ''
    153.         var lastThreadPrefix = 0
    154.  
    155.         var now = new Date()
    156.        
    157.         var offset = 0
    158.        
    159.         for (var x = 0; x < 8; x++) {
    160.           if (offset + x === threadLinks.length || offset + x === threadTimes.length) {
    161.             break
    162.           }
    163.  
    164.           threadTitle = threadLinks[x + offset].match(/">.*<\/a>/g)[0]
    165.           threadTitle = threadTitle.substring(2, threadTitle.length - 4)
    166.           threadUrl = threadLinks[x + offset].match(/href="threads[\s\wäöüÄÖÜ\/ß#?+\-_=()\[\]!\*%$]*/g)[0]
    167.           threadUrl = threadUrl.substring(6, threadUrl.length)
    168.           threadId = threadLinks[x + offset].match(/href="threads\/[0-9]*/g)[0]
    169.           threadId = threadId.substring(14, threadId.length)
    170.  
    171.           if (threadsMoved.indexOf(x + offset) === -1) {
    172.             threadAuthor = threadAuthors[x + offset].match(/<strong>.*<\/strong>/g)[0]
    173.             threadAuthor = threadAuthor.substring(8, threadAuthor.length - 9)
    174.             threadAuthorId = threadAuthors[x + offset].match(/members\/[0-9]*/g)[0]
    175.             threadAuthorId.substring(7, threadAuthorId.length)
    176.  
    177.             if (threadTimes !== null) {
    178.               threadTime = threadTimes[x + offset].replace(/<dd>|<span class="time">|<p class="lastpostdate">|<\/span>|<\/p>/g, '')
    179.              
    180.               if (threadTime.indexOf('Heute,') === -1 && threadTime.indexOf('Gestern,') === -1) {
    181.                                 var timeDate = threadTime.match(/[0-9].?/g)
    182.                 var dateObj = new Date()
    183.                 dateObj.setTime(0)
    184.                 dateObj.setDate(parseInt(timeDate[0]))
    185.                 dateObj.setMonth(parseInt(timeDate[1]) - 1)
    186.                 dateObj.setFullYear(parseInt('20' + timeDate[2]))
    187.                 dateObj.setHours(parseInt(timeDate[3]))
    188.                 dateObj.setMinutes(parseInt(timeDate[4]))
    189.                 dateObj.setSeconds(0)
    190.                 dateObj.setMilliseconds(0)
    191.                
    192.                 if (dateObj.getTime() < now.getTime() - ((3600 * 1000) * 24 * 30)) { // 30 - Anzahl der Tage die Themen alt sein duerfen
    193.                   offset++
    194.                   x--
    195.                   continue
    196.                 }
    197.               }
    198.             }
    199.           } else {
    200.             ++offset;
    201.           }
    202.  
    203.           var prefix = ''
    204.           if (threadPrefixes !== null) {
    205.             for (i = lastThreadPrefix; i < threadPrefixes.length; ++i) {
    206.               if (threadPrefixes[i].indexOf(threadId + '"') !== -1) {
    207.                 lastThreadPrefix = i + 1
    208.                 prefix = threadPrefixes[i].match(/>[\s\w\b\-_()\[\]äöüÄÖÜ:,;#+*&\/]*<\/span>/g)[0].trimRight()
    209.                 prefix = prefix.substring(1, prefix.length - 7)
    210.               }
    211.             }
    212.           }
    213.  
    214.           if (prefix !== '') {
    215.             htmlData += '<span style="clear: both; float:left;"><i>' + prefix + '</i>&nbsp;<a href="https://ngb.to/' + threadUrl + '" target="_blank">' + threadTitle + '</a></span>'
    216.           } else {
    217.             htmlData += '<a style="clear: left; float: left;" href="https://ngb.to/' + threadUrl + '" target="_blank">' + threadTitle + '</a>'
    218.           }
    219.  
    220.           if (prefix.indexOf('Verschoben') === -1) {
    221.             if (threadTime != '') {
    222.                 htmlData += '<p style="display: block; text-align: right; margin-left: 10%;">[ <a href="https://ngb.to/members/' + threadAuthorId + '-' + threadAuthor + '">' + threadAuthor + '</a>, ' + threadTime + ' Uhr ]</p>'
    223.             } else {
    224.               htmlData += '<p style="display: block; text-align: right; margin-left: 10%;">[ <a href="https://ngb.to/members/' + threadAuthorId + '-' + threadAuthor + '">' + threadAuthor + '</a> ]</p>'
    225.             }
    226.           } else {
    227.             if (threadTime != '') htmlData += '<p style="display: block; text-align: right; margin-left: 10%;">[ ' + threadTime + ' Uhr ]</p>'
    228.           }
    229.         }
    230.  
    231.         loader.parent.innerHTML += htmlData + '<button class="subLoadtoggleForum" data-name="' + forumId + '" data-index="' + loader.index + '" style="clear:both; float: right; margin-top: 15px;">Remove of subload</button></div>'
    232.         loaded++
    233.         checkLoad()
    234.       } catch (error) {
    235.         console.log('[ERROR] Error in script: ' + error + ', lineNumber, ' + error.lineNumber + ', loader: ' + loader.responseURL)
    236.       }
    237.     }
    238.   } else if (loader.readyState === 4) {
    239.     console.log('[ERROR] Loader status: ' + loader.responseURL + ' : (' + loader.status + ') ' + loader.statusText)
    240.     loaded++
    241.     checkLoad()
    242.   }
    243. }
    244.  
    245. async function ajaxLoader (url, index) {
    246.   var loader = new XMLHttpRequest()
    247.   loader.addEventListener('readystatechange', loaderChangeStatus)
    248.   loader.parent = boardLinks[index].parentNode.parentNode
    249.   loader.index = index
    250.  
    251.   var forumId = loader.parent.parentNode.parentNode.parentNode.parentNode.id
    252.   if (window.location.pathname.indexOf('/forums/') !== -1) forumId = loader.parent.parentNode.parentNode.parentNode.parentNode.parentNode.id
    253.  
    254.   if (await GM.getValue('subload_' + forumId, 'false') === 'false') {
    255.     var htmlData = '<div class="ngbSubloadDiv ' + forumId + '" style="clear: both; display: inline-block; width: 100%; margin: 10px 0px 10px 20px;">'
    256.     loader.parent.innerHTML += htmlData + '<button class="subLoadtoggleForum" data-name="' + forumId + '" data-index="' + loader.index + '" style="clear:both; float: right; margin-top: 15px;">Add to subload</button></div>'
    257.     loaded++
    258.     checkLoad()
    259.     return
    260.   }
    261.  
    262.   if (url.indexOf('https://ngb.to/') === -1) loader.open('GET', 'https://ngb.to/' + url.replace('http://', 'https://'))
    263.   else loader.open('GET', url.replace('http://', 'https://'))
    264.   loader.send()
    265. }
    266.  
    267. async function toggleVisibility (event) {
    268.   var ngbSubloadDivs = document.querySelectorAll('.ngbSubloadDiv')
    269.  
    270.   var show = 'inline-block'
    271.   if (event.target.dataset.status === 'on') {
    272.     show = 'none'
    273.     event.target.dataset.status = 'off'
    274.     event.target.innerHTML = 'NGB-Sl [an]'
    275.     await GM.setValue('subload_switch', 'off')
    276.   } else {
    277.     event.target.dataset.status = 'on'
    278.     event.target.innerHTML = 'NGB-Sl [aus]'
    279.     await GM.setValue('subload_switch', 'on')
    280.   }
    281.  
    282.   for (var i = 0; i < ngbSubloadDivs.length; ++i) {
    283.     ngbSubloadDivs[i].style.display = show
    284.   }
    285.  
    286.   if (!hasLoaded) {
    287.     for (i = 0; i < boardLinks.length; ++i) {
    288.       var hrefLink = boardLinks[i].innerHTML.match(/href=".*"/g)[0]
    289.       var url = hrefLink.substring(6, hrefLink.length - 1)
    290.       ajaxLoader(url, i)
    291.     }
    292.   }
    293.  
    294.   return false
    295. }
    296.  
    297. boardLinks = document.querySelectorAll('h2.forumtitle')
    298.  
    299. async function initFunc() {
    300.  
    301.   for (var i = 0; i < boardLinks.length; ++i) {
    302.     var forumId = boardLinks[i].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.id
    303.  
    304.     if (window.location.pathname.indexOf('/forums/') !== -1) forumId = boardLinks[i].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.id
    305.     if (await GM.getValue('subload_' + forumId, 'false') !== 'true') await GM.setValue('subload_' + forumId, 'false')
    306.   }
    307.  
    308.   var subLoadOn = true
    309.   var buttonsOn = true
    310.  
    311.   if (await GM.getValue('subload_switch', 'on') === 'off') subLoadOn = false
    312.     else await GM.setValue('subload_switch', 'on')
    313.  
    314.     if (await GM.getValue('subload_switch_buttons', 'on') === 'off') buttonsOn = false
    315.     else await GM.setValue('subload_switch_buttons', 'on')
    316.  
    317.   if (subLoadOn) {
    318.     for (var i = 0; i < boardLinks.length; ++i) {
    319.       var hrefLink = boardLinks[i].innerHTML.match(/href=".*"/g)[0]
    320.       var url = hrefLink.substring(6, hrefLink.length - 1)
    321.       ajaxLoader(url, i)
    322.     }
    323.   } else {
    324.     var subLoadStatus = 'off'
    325.     var subLoadText = 'an'
    326.  
    327.     var buttonStatus = 'off'
    328.     var buttonText = 'an'
    329.  
    330.     if (subLoadOn) {
    331.       subLoadStatus = 'on'
    332.       subLoadText = 'aus'
    333.     }
    334.  
    335.     if (buttonsOn) {
    336.       buttonStatus = 'on'
    337.       buttonText = 'aus'
    338.     }
    339.  
    340.     var subMenu = document.querySelector('div.breadcrumb > ul')
    341.     if (document.getElementById('ngb_subload_switch') === null) {
    342.       subMenu.innerHTML += '<li><div style="float: right;"><button id="ngb_subload_switch" data-status="' + subLoadStatus + '" style="margin-right: 10px; cursor: pointer; text-decoration: none;" title="NGB Subload umschalten">NGB-Sl [' + subLoadText + ']</button><button id="ngb_subload_switch_buttons" data-status="' + buttonStatus + '" style="cursor: pointer; text-decoration: none;" title="NGB Subload Buttons umschalten">NGB-Sl Buttons [' + buttonText + ']</button></div></li>'
    343.       document.getElementById('ngb_subload_switch').addEventListener('click', toggleVisibility, true)
    344.       document.getElementById('ngb_subload_switch_buttons').addEventListener('click', toggleButtons, true)
    345.     }
    346.   }
    347. }
    348.  
    349.  
    350. // ----------------------------------------------------------------------------------
    351. initFunc()
    352.  
    353.  
    Geändert von theSplit (10.02.18 um 16:58 Uhr)
    Gruß theSplit
    @ I might be sober. The good things... the bad things... all I ever know is here! @
    +++ thunderNote +++ Thom's Inventarverwaltung +++ Pi-Thread +++ IT-Talents Code Competitions +++ NGB-Statistik Opt-Out/Anonymisierung +++ Stonerhead +++ Add-on Flag Cookies +++ Google Image Directlinks +++ dwrox.net

Berechtigungen

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