ANTICHAT

ANTICHAT (https://forum.antichat.xyz/index.php)
-   Общие вопросы программирования (https://forum.antichat.xyz/forumdisplay.php?f=206)
-   -   помогите с Tampermonkey (https://forum.antichat.xyz/showthread.php?t=1457920)

Sep 15.11.2022 00:57

в стиле 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"
;



https://i.imgur.com/IIW1zBR.png

https://i.imgur.com/FaPig7X.png

im0rg 15.11.2022 10:29

JavaScript:





Код:

document
.
getElementsByClassName
(
"profile-body-level-info-progress"
)
.
getElementsByTagName
(
'div'
)


Sep 15.11.2022 14:54

Цитата:

Сообщение от im0rg

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.pngsep · 15 Ноя 2022 в 13:54' data-fancybox="lb-post-1195411" data-lb-caption-extra-html="" data-lb-sidebar-href="" data-single-image="1" data-src="/proxy.php?image=https%3A%2F%2Fi.imgur.com%2FDogn3m y.png&hash=b29232be5facf6a0d11028121889d6d2" style="cursor: pointer;" title="Dogn3my.png">
https://i.imgur.com/Dogn3my.png

полный скрин

https://i.imgur.com/rKK306M.png

если делаю так document.getElementsByClassName("profile-body-level-info-progress")[0].style.background='#00ff00'; то

МЕНЯЕТСЯ НЕ ТО ЧТО Я ХОЧУ

https://i.imgur.com/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 15.11.2022 16:23

Цитата:

Сообщение от sep

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

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

https://i.imgur.com/Dogn3my.png

полный скрин

https://i.imgur.com/rKK306M.png

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

https://i.imgur.com/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 15.11.2022 16:37

Цитата:

Сообщение от im0rg

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 (обновление страницы)

im0rg 15.11.2022 16:44

Цитата:

Сообщение от sep

спасибо работает но как пофиксить баг что работает только после f5 (обновление страницы)

DOMContentLoaded

Sep 15.11.2022 17:14

Цитата:

Сообщение от im0rg

DOMContentLoaded

а как ее в скрпт вставить ? я хз


Время: 20:37