Greasy Fork is available in English.

게시판 » 개발

Modify Html tag

작성: 2024-04-09
수정: 2024-04-09

Hi everyone,

I would like to create a simple script that modifies the html tag, only on a specific site, as follows:

from <html lang="it"


<html lang="en-US"

Anyone want give me support?

Thanks in advance

작성: 2024-04-11
수정: 2024-04-11

This code should work:

document.querySelector('html').lang = "en-US";

Or, if you want to make use of a variable:

let elementHTML;
elementHTML = document.querySelector('html');
elementHTML.lang = "en-US";
작성: 2024-04-23

Thanks for replying.
Could you please share me the complete code to use? (including the initial commits)
I tried but it doesn't seem to work.
When I load the specific page that I inserted in // @match, the extension icon flashes in the browser but the final result is not as expected, as you can see in my console (see attached image).


작성: 2024-04-23

This code should work:

// ==UserScript==
// @name        Sent lang to en-us
// @namespace   set-lang-to-en-us
// @description Redirect to raw archived pages.
// @supportURL
// @match       *://*/*
// @version     0.1
// @run-at      document-end
// @grant       none
// ==/UserScript==

(function () {

  document.querySelector('html').lang = "en-US";


If it does not work, please write the URL of that page so I can test it.

document.documentElement.lang = "en-US";

댓글 남기기

댓글을 남기려면 로그인하세요.