Ameila
Ameila

Reputation: 13

Removing Tradingview logo on Ticker Widget

Can someone please help me remove the tradingview marketing logo. I've tired almost everything and somehow the code get's messed up. I'm using this widget from tradingview (https://www.tradingview.com/widget/ticker/) and wanted to know if:

I am not sure how to go about making it so it can appear on a website.

Upvotes: 1

Views: 7060

Answers (2)

Thomas Fischer
Thomas Fischer

Reputation: 1

In lightweight-charts.js you have to remove this line:

this.if() && (this.tf(), this.en = this.nf(), this.en && (this.Kd = this.sf(), this.Xd = document.createElement("style"), this.Xd.innerText = "a#tv-attr-logo{--fill:#131722;--stroke:#fff;position:absolute;left:10px;bottom:10px;height:19px;width:35px;margin:0;padding:0;border:0;z-index:3;}a#tv-attr-logo[data-dark]{--fill:#D1D4DC;--stroke:#131722;}", this.Zd = document.createElement("a"), this.Zd.href = `https://www.tradingview.com/?utm_medium=lwc-link&utm_campaign=lwc-chart${this.ef()}`, this.Zd.title = "Charting by TradingView", this.Zd.id = "tv-attr-logo", this.Zd.target = "_blank", this.Zd.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 35 19" width="35" height="19" fill="none"><g fill-rule="evenodd" clip-path="url(#a)" clip-rule="evenodd"><path fill="var(--stroke)" d="M2 0H0v10h6v9h21.4l.5-1.3 6-15 1-2.7H23.7l-.5 1.3-.2.6a5 5 0 0 0-7-.9V0H2Zm20 17h4l5.2-13 .8-2h-7l-1 2.5-.2.5-1.5 3.8-.3.7V17Zm-.8-10a3 3 0 0 0 .7-2.7A3 3 0 1 0 16.8 7h4.4ZM14 7V2H2v6h6v9h4V7h2Z"/><path fill="var(--fill)" d="M14 2H2v6h6v9h6V2Zm12 15h-7l6-15h7l-6 15Zm-7-9a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z"/></g><defs><clipPath id="a"><path fill="var(--stroke)" d="M0 0h35v19H0z"/></clipPath></defs></svg>', this.Zd.toggleAttribute("data-dark", "dark" === this.Kd), this.Gd.appendChild(this.Xd), this.Gd.appendChild(this.Zd)))

it's in the class cs. or when you use lightweight-charts as cdn do this instead:

var id_count = $('[id=tv-attr-logo]');
                if (id_count.length > 0) {
                    $('[id=tv-attr-logo]').remove();
                }

Upvotes: 0

someone
someone

Reputation: 358

For removing that, you could inject javascript code into it:

document.querySelector('.tv-header__link').remove();

tv-header__link is the class of the logo anchor tag...

The function remove() removes the querySelected element, like the name says.

MDN Page of remove()

With querySelector() you can select elements with a certain class or id, so my code selects the element with a class of 'tv-header__link', which is the tradingview-logo in the header, and removes it with the help of the remove() function.

MDN Page of document.querySelector()

MDN Page of element.querySelector()

Upvotes: 2

Related Questions