BitChute: search video on twitter

Adds links allowing search on Twitter (by title and url) to video detail screen.

  1. // ==UserScript==
  2. // @name BitChute: search video on twitter
  3. // @version 2
  4. // @grant none
  5. // @require https://cdn.jsdelivr.net/npm/jquery@3.4.1/dist/jquery.min.js
  6. // @match https://www.bitchute.com/*
  7. // @author monnef
  8. // @description Adds links allowing search on Twitter (by title and url) to video detail screen.
  9. // @namespace monnef.eu
  10. // ==/UserScript==
  11.  
  12. const cls = 'tw-link';
  13.  
  14. const genTwitterSearchURL = str => `https://twitter.com/search?q=${encodeURIComponent(str)}&src=typed_query`;
  15.  
  16. const pipe = (...args) => {
  17. const [input, ...fs] = args;
  18. return fs.reduce((acc, x) => x(acc), input);
  19. }
  20.  
  21.  
  22. const chopVideoLink = x => x.replace(/\/\?.*/, '');
  23.  
  24. const work = () => {
  25. const titleEl = $('#video-title');
  26. if (titleEl.hasClass(cls)) { return; }
  27. titleEl.addClass(cls);
  28. const pubDateEl = $('.video-publish-date');
  29. const linkAddressByTitle = genTwitterSearchURL(titleEl.text());
  30. const linkAddressByURL = genTwitterSearchURL(pipe(document.location.href, chopVideoLink));
  31. const titleSearchEl = $('<a/>').text('title').attr('target', '_blank').attr('href', linkAddressByTitle);
  32. const urlSearchEl = $('<a/>').text('URL').attr('target', '_blank').attr('href', linkAddressByURL);
  33. const el = $('<div>').text('Search on Twitter: ').append(titleSearchEl).append(' / ').append(urlSearchEl);
  34. pubDateEl.after(el);
  35. };
  36.  
  37. $(() => setInterval(work, 1000));