JS помогите с Tampermonkey

sep

Известный
Автор темы
672
76
в стиле profile-body-level-info-progress нет цвета синей полоски а в profile-body-level-info-progress>div есть
но как написать profile-body-level-info-progress>div в
var element = document.getElementsByClassName("profile-body-level-info-progress")[0]; я незнаю

я овер новичок только начел прошу подобного объяснение с примерами если не сложно

код:
var element = document.getElementsByClassName("profile-body-level-info-progress")[0];
element.style.background="#3bafda";

IIW1zBR.png



FaPig7X.png
 
Решение
спасибо но не пашет делал так
var element = document.getElementsByClassName("profile-body-level-info-progress").getElementsByTagName('div')
element.style.background="#00ff00";

если меняю в как на фото работает а в скрипте нет
Dogn3my.png


полный скрин

rKK306M.png


если делаю так document.getElementsByClassName("profile-body-level-info-progress")[0].style.background='#00ff00'; то
МЕНЯЕТСЯ НЕ ТО ЧТО Я ХОЧУ
sDr1yTu.png


И ДА СКРИПТ РАБОТАЕТ ТОЛЬКО КОГДА ПЕРЕЗАГРУЖАЮ СТРАНИЧКУ
ФУЛЛ КОД:
// ==UserScript==
// @name        lip-monopoly-one
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author...

sep

Известный
Автор темы
672
76
JavaScript:
document.getElementsByClassName("profile-body-level-info-progress").getElementsByTagName('div')
спасибо но не пашет делал так
var element = document.getElementsByClassName("profile-body-level-info-progress").getElementsByTagName('div')
element.style.background="#00ff00";

если меняю в как на фото работает а в скрипте нет
Dogn3my.png


полный скрин

rKK306M.png


если делаю так document.getElementsByClassName("profile-body-level-info-progress")[0].style.background='#00ff00'; то
МЕНЯЕТСЯ НЕ ТО ЧТО Я ХОЧУ
sDr1yTu.png


И ДА СКРИПТ РАБОТАЕТ ТОЛЬКО КОГДА ПЕРЕЗАГРУЖАЮ СТРАНИЧКУ
ФУЛЛ КОД:
// ==UserScript==
// @name        lip-monopoly-one
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       lip
// @match        https://monopoly-one.com/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// ==/UserScript==
'use strict';

// Your code here...
document.getElementsByClassName("_img")[0].style.backgroundImage="url('https://i.imgur.com/su4kW3N.png')";
//
document.getElementsByClassName("profile-top-info-main-nick")[0].style.color='#00ff00';
document.getElementsByClassName("title title-3")[0].style.color='ff0000';
document.getElementsByClassName("profile-body-level-info-rank")[0].style.color='#ff0000';
document.getElementsByClassName("profile-top-stat")[0].style.color='#ffffff';
//
//document.getElementsByClassName("profile-body-level-info-progress").getElementsByTagName('div').style.background='#00ff00';
//
var element = document.getElementsByClassName("profile-body-level-info-progress").getElementsByTagName('div');
element.style.background="#00ff00";
 
Последнее редактирование:

im0rg

Известный
Друг
587
215
спасибо но не пашет делал так
var element = document.getElementsByClassName("profile-body-level-info-progress").getElementsByTagName('div')
element.style.background="#00ff00";

если меняю в как на фото работает а в скрипте нет
Dogn3my.png


полный скрин

rKK306M.png


если делаю так document.getElementsByClassName("profile-body-level-info-progress")[0].style.background='#00ff00'; то
МЕНЯЕТСЯ НЕ ТО ЧТО Я ХОЧУ
sDr1yTu.png


И ДА СКРИПТ РАБОТАЕТ ТОЛЬКО КОГДА ПЕРЕЗАГРУЖАЮ СТРАНИЧКУ
ФУЛЛ КОД:
// ==UserScript==
// @name        lip-monopoly-one
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       lip
// @match        https://monopoly-one.com/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// ==/UserScript==
'use strict';

// Your code here...
document.getElementsByClassName("_img")[0].style.backgroundImage="url('https://i.imgur.com/su4kW3N.png')";
//
document.getElementsByClassName("profile-top-info-main-nick")[0].style.color='#00ff00';
document.getElementsByClassName("title title-3")[0].style.color='ff0000';
document.getElementsByClassName("profile-body-level-info-rank")[0].style.color='#ff0000';
document.getElementsByClassName("profile-top-stat")[0].style.color='#ffffff';
//
//document.getElementsByClassName("profile-body-level-info-progress").getElementsByTagName('div').style.background='#00ff00';
//
var element = document.getElementsByClassName("profile-body-level-info-progress").getElementsByTagName('div');
element.style.background="#00ff00";
JavaScript:
// ==UserScript==
// @name        lip-monopoly-one
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       lip
// @match        https://monopoly-one.com/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// ==/UserScript==
'use strict';

// Your code here...
document.getElementsByClassName("_img")[0].style.backgroundImage="url('https://i.imgur.com/su4kW3N.png')";
//
document.getElementsByClassName("profile-top-info-main-nick")[0].style.color='#00ff00';
document.getElementsByClassName("title title-3")[0].style.color='ff0000';
document.getElementsByClassName("profile-body-level-info-rank")[0].style.color='#ff0000';
document.getElementsByClassName("profile-top-stat")[0].style.color='#ffffff';
//
//document.getElementsByClassName("profile-body-level-info-progress").getElementsByTagName('div').style.background='#00ff00';
//
var element = document.getElementsByClassName("profile-body-level-info-progress").item(0).getElementsByTagName('div').item(0);
element.style.background="#00ff00";
 
  • Нравится
Реакции: sep

sep

Известный
Автор темы
672
76
JavaScript:
// ==UserScript==
// @name        lip-monopoly-one
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       lip
// @match        https://monopoly-one.com/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// ==/UserScript==
'use strict';

// Your code here...
document.getElementsByClassName("_img")[0].style.backgroundImage="url('https://i.imgur.com/su4kW3N.png')";
//
document.getElementsByClassName("profile-top-info-main-nick")[0].style.color='#00ff00';
document.getElementsByClassName("title title-3")[0].style.color='ff0000';
document.getElementsByClassName("profile-body-level-info-rank")[0].style.color='#ff0000';
document.getElementsByClassName("profile-top-stat")[0].style.color='#ffffff';
//
//document.getElementsByClassName("profile-body-level-info-progress").getElementsByTagName('div').style.background='#00ff00';
//
var element = document.getElementsByClassName("profile-body-level-info-progress").item(0).getElementsByTagName('div').item(0);
element.style.background="#00ff00";
спасибо работает но как пофиксить баг что работает только после f5 (обновление страницы)