Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name NBA Day Calendar
- // @namespace http://tampermonkey.net/
- // @version 0.1
- // @description try to take over the world!
- // @author You
- // @match https://jumperbrasil.lance.com.br/calendario-transmissoes-nba-brasil/
- // @icon https://www.google.com/s2/favicons?sz=64&domain=lance.com.br
- // @grant none
- // ==/UserScript==
- const removeElements = function() {
- let ad_container = document.querySelectorAll('.pp-paywall__container')[0];
- let ad_backgroun = document.querySelectorAll('.pp-paywall__background')[0];
- if(ad_container) ad_container.parentElement?.removeChild(ad_container);
- if(ad_backgroun) ad_backgroun.parentElement?.removeChild(ad_backgroun);
- }
- const setDateFunctions = function() {
- Date.prototype.getMonthName = function() {
- var monthNames = [ "Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho",
- "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro" ];
- return monthNames[this.getMonth()];
- }
- Date.prototype.getDateBr = function() {
- const dia = this.getDate().toString();
- const diaF = (dia.length == 1) ? '0'+dia : dia;
- const mes = (this.getMonth()+1).toString();
- const mesF = (mes.length == 1) ? '0'+mes : mes;
- const anoF = this.getFullYear().toString().substr(2,2);
- return diaF+"/"+mesF+"/"+anoF;
- }
- }
- const getDateContent = function(datebr) {
- let dcontent = null;
- var dTags = document.getElementsByTagName("p");
- for (var i = 0; i < dTags.length; i++) {
- if (dTags[i].textContent.indexOf(datebr) != -1) {
- dcontent = dTags[i];
- break;
- }
- }
- return dcontent;
- }
- const getDayCalendar = function(dcontent, datebr) {
- let day_calendar = null;
- let day_anchor = null;
- if(dcontent) {
- console.log(dcontent);
- dcontent.scrollIntoView();
- for (var i = 0; i < dcontent.childNodes.length; i++) {
- if(dcontent.childNodes[i].data && dcontent.childNodes[i].data.indexOf(datebr) != -1) {
- day_calendar = dcontent.childNodes[i];
- break;
- } else if (dcontent.childNodes[i].tagName?.toUpperCase() == 'BR') {
- day_anchor?.scrollIntoView();
- day_anchor = dcontent.childNodes[i];
- }
- }
- console.log(day_calendar);
- }
- return day_calendar;
- }
- const setHighlightContent = function(day_calendar) {
- let div = document.createElement('DIV');
- div.style = "color:white;background-color:#ed3833";
- div.innerHTML = day_calendar.textContent;
- day_calendar.previousSibling.insertAdjacentElement('afterend', div);
- day_calendar.parentElement.removeChild(day_calendar)
- };
- const letsgo = function(){
- console.log('Onload disparado');
- //Get Date Now
- setDateFunctions();
- const date = new Date();
- let month = date.getMonthName();
- let datebr = date.getDateBr();
- console.log('NBA Day Calendar --> Date:', month, datebr);
- //Get Date content
- let dcontent = getDateContent(datebr);
- if (!dcontent) {
- window.alert('Nao temos jogos nesta data: (' + datebr + ').\nVai trabalhar ou estudar meu caro!');
- return false;
- }
- console.log('NBA Day Calendar --> DateContent: ', dcontent);
- //Get Day Calendar
- let day_calendar = getDayCalendar(dcontent, datebr);
- console.log('NBA Day Calendar --> DayCalendar: ', day_calendar);
- //Destak content
- setHighlightContent(day_calendar);
- //Remove Elements
- setTimeout(function() {
- removeElements();
- console.log('NBA Day Calendar --> removeElements Ok');
- }, 10000);
- }
- letsgo();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement