議論 » 開発

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"

to

<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).

Thanks

§
投稿日: 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  https://greasyfork.org/en/discussions/development/238912-modify-html-tag
// @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";

返信を投稿

返信を投稿するにはログインしてください。