Advertisement
Guest User

Untitled

a guest
Mar 30th, 2020
354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.70 KB | None | 0 0
  1. // ==UserScript==
  2. // @name twitch2
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description try to take over the world!
  6. // @author You
  7. // @include *://*.twitch.tv/*
  8. // @include *://twitch.tv/*
  9. // @grant unsafeWindow
  10. // ==/UserScript==
  11.  
  12. (function(wnd) {
  13. 'use strict';
  14.  
  15. wnd.initReticle = function(){
  16. let hdr = document.querySelector("[data-target=channel-header-left]");
  17. if(hdr)
  18. {
  19. hdr.insertAdjacentHTML('beforeend','<a class="channel-header__item tw-align-items-center tw-flex-shrink-0 tw-interactive tw-link tw-link--hover-underline-none" href="#" onclick="ondomload(); return false;">crX</a>');
  20. }
  21. wnd.drawReticle(4,2,20, 'red');
  22. };
  23.  
  24.  
  25.  
  26. wnd.document.addEventListener("DOMContentLoaded", function(event) {
  27. setTimeout(() => {
  28. wnd.initReticle();
  29. }, 10000);
  30. });
  31.  
  32.  
  33. wnd.drawReticle = function(space,lineWid, wid, color){
  34. let twPlayerClass = [
  35. ".video-player",
  36. ".video-player__default-player",
  37. ".persistent-player",
  38. ".player-root" ,
  39. ".highwind-video-player__overlay"
  40. ];
  41. let w = Math.round(wid*0.5);
  42. let h = w;
  43. twPlayerClass.forEach( c => {
  44. let o = document.querySelector(c);
  45. if(o)
  46. {
  47. let canvas = document.getElementById('crosshair');
  48. if(!canvas)
  49. {
  50. o.insertAdjacentHTML('afterbegin','<canvas id="crosshair" style="padding: 0 0 0 0;z-index:1000000; position:absolute; top: calc(50% - ' + w+'px); left: calc(50% - ' +w+'px);"></canvas>');
  51. canvas = document.getElementById('crosshair');
  52. canvas.height=wid;
  53. canvas.width =wid;
  54.  
  55. const ctx = canvas.getContext('2d');
  56. if(ctx)
  57. {
  58. ctx.lineWidth = lineWid;
  59. ctx.strokeStyle = color;
  60. ctx.moveTo(0, h);
  61. ctx.lineTo(w - space, h);
  62. ctx.moveTo(w + space, h);
  63. ctx.lineTo(canvas.clientWidth, h);
  64. ctx.moveTo(w, 0);
  65. ctx.lineTo(w, h - space);
  66. ctx.moveTo(w, h + space);
  67. ctx.lineTo(w, canvas.clientHeight);
  68. ctx.closePath();
  69. ctx.stroke();
  70. }
  71. console.log('reticle', o, canvas);
  72. }
  73. }
  74. });
  75. }
  76.  
  77.  
  78.  
  79. })(unsafeWindow );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement