K-Meleon on Goanna :  K-Meleon Web Browser Forum
Building K-Meleon on top of the Goanna engine 
www.bitchute.com - patch
Posted by: Kris_88
Date: February 06, 2022 12:19PM

Patch script for bitchute.com



if(window.location.hostname == 'www.bitchute.com') {

  document.addEventListener("beforescriptexecute", function(e) {
    var s;

    if(e.target.src == 'https://cdn.jsdelivr.net/npm/p2p-media-loader-core@latest/build/p2p-media-loader-core.min.js'winking smiley {
      e.preventDefault();
      e.stopPropagation();
      // skip p2p-media-loader-core.min.js
    };


    if(e.target.src == 'https://www.bitchute.com/static/v136/js/common.js'winking smiley {
      e.preventDefault();
      e.stopPropagation();

      // patch common.js
      var xhr = new XMLHttpRequest();
      xhr.open("GET", e.target.src, false);
      xhr.send(null);
      if(xhr.status === 200) {
        s = document.createElement('script');
        s.type = 'text/javascript';
        s.innerHTML = xhr.responseText.replace('catch{}', 'catch(e) {}');
        s.async = false;
        e.target.parentNode.insertBefore(s, e.target.nextSibling);
      };
    };


    if(e.target.src == 'https://cdnjs.cloudflare.com/ajax/libs/plyr/3.6.9/plyr.polyfilled.min.js'winking smiley {
      e.preventDefault();
      e.stopPropagation();

      // replace plyr.polyfilled.min.js
      s = document.createElement('script');
      s.type = 'text/javascript';
      s.src = 'https://cdnjs.cloudflare.com/ajax/libs/plyr/3.3.9/plyr.polyfilled.min.js';;
      s.async = false;
      e.target.parentNode.insertBefore(s, e.target.nextSibling);

      // replace plyr.min.css
      var lnk = document.getElementsByTagName("link");
      for(var l of lnk) {
        if(l.href=='https://cdnjs.cloudflare.com/ajax/libs/plyr/3.6.9/plyr.min.css'winking smiley
          l.href='https://cdnjs.cloudflare.com/ajax/libs/plyr/3.3.9/plyr.css';;
      };
    };

  }, true);


  window.addEventListener("play", function(e) {

    // add download link
    var vid = document.getElementById("player");
    if(vid) {
      var lnk = document.getElementById("dld-id1");
      if(!lnk) {
        lnk = document.createElement('a');
        lnk.id = 'dld-id1';
        lnk.style = 'color:blue;';
        lnk.setAttribute('target', '_blank');
        lnk.innerText = 'Download';
        var ptr = document.querySelector('div.video-statistics');
        if(ptr) { ptr.appendChild(lnk) } else {
          vid.parentElement.parentElement.parentElement.appendChild(lnk);
        };
      };
      lnk.href = vid.currentSrc;
      lnk.download = document.title;
    };
  });

};

You can use polyfill injector to install this script:
http://kmeleonbrowser.org/forum/read.php?9,153735

Alternatively you can add header lines and use some sort of Greasemonkey

// ==UserScript==
// @name        bitchute
// @namespace   btc1
// @include     https://www.bitchute.com/*
// @run-at document-start
// @version     1
// @grant       none
// ==/UserScript==



Edited 4 time(s). Last edit at 02/13/2022 03:19AM by Kris_88.

Options: ReplyQuote
Re: www.bitchute.com - patch
Posted by: J.G.
Date: February 08, 2022 07:27AM

Thanks for your helpful ideas! smiling smiley

Options: ReplyQuote
Re: www.bitchute.com - patch (cloudflare userscript by Kris)
Posted by: siria
Date: February 08, 2022 03:53PM

Thanks for your skills and efforts, Kris.
Pity I can't use it myself on old systems, and keep wishing you'd have appeared years before, when there was much more life yet here, a lot more users, and exactly such addon skills were direly missed (Dorian could surely have done it too, but far too much time already needed to catch up with Mozilla's tricky engine updates)

Just a hint about posting code:
The forum handles stuff like "[ i ]" as invisible bbcode tag, making text italic.
To avoid this, there are 2 switches between editor field and subject line:
☑ Disable bbcode for this message
☑ Disable smileys for this message

Options: ReplyQuote
Re: www.bitchute.com - patch (cloudflare userscript by Kris)
Posted by: Kris_88
Date: February 10, 2022 07:34AM

Oh, it turned out to be unexpected for me.
Typically, the CODE tag protects the text from accidental recognition of other tags.
Thanks!

Options: ReplyQuote
Re: www.bitchute.com - patch (cloudflare userscript by Kris)
Posted by: Kris_88
Date: February 11, 2022 08:36AM

Unfortunately, it is no longer working.
The playful hands of the bitchute developers changed something again. )
Let's wait a bit...

Options: ReplyQuote
Re: www.bitchute.com - patch (cloudflare userscript by Kris)
Posted by: siria
Date: February 11, 2022 08:51AM

Quote
Kris_88
Oh, it turned out to be unexpected for me.
Typically, the CODE tag protects the text from accidental recognition of other tags.

There's a misunderstanding.... Simply edit the first post again and do check the 2 boxes, then you can paste the original js-code as is and it shows up. And js-clueless users can simply copy-paste too.

Options: ReplyQuote
Re: www.bitchute.com - patch (cloudflare userscript by Kris)
Posted by: Kris_88
Date: February 11, 2022 09:39AM

In this case, the "Code" Tag does not work and indents are lost.

Options: ReplyQuote
Re: www.bitchute.com - patch (cloudflare userscript by Kris)
Posted by: JohnHell
Date: February 11, 2022 10:20PM

Alternatively you can just escape the square brackets (quote this post to see the changes) with a backslash:
          if(lnk[i].href=='https://cdnjs.cloudflare.com/ajax/libs/plyr/3.6.9/plyr.min.css'winking smiley
            lnk[i].href='https://cdnjs.cloudflare.com/ajax/libs/plyr/3.3.9/plyr.css';;

Note that sometimes work, some might not.

In the other hand does JavaScript care about spaces between square brackets? It doesn't with parenthesis. So you could leave as you did now.

Options: ReplyQuote
Re: www.bitchute.com - patch (cloudflare userscript by Kris)
Posted by: Kris_88
Date: February 13, 2022 03:30AM

JohnHell, thank you!
I did not know that BB codes can be escaped.
Yes, the spaces inside the brackets do not interfere with the script.
But now it is no longer relevant, since there are no [i] in the new version of the script.

I updated the script, added the download button. Now it works.

Options: ReplyQuote


K-Meleon forum is powered by Phorum.