Created
March 17, 2022 11:58
-
-
Save vaaski/3d7108166a9c2de9cf5b4a4efdcbbe64 to your computer and use it in GitHub Desktop.
adds an "install in content manager" anchor to every car
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name Add direct content manager install links | |
| // @description Add direct content manager install links | |
| // @version 0.1 | |
| // @author vaaski | |
| // @match http://assettoland.net/* | |
| // @exclude http://assettoland.net/cars* | |
| // @icon https://www.google.com/s2/favicons?sz=64&domain=assettoland.net | |
| // @grant none | |
| // ==/UserScript== | |
| ;(() => { | |
| // @ts-check | |
| /** | |
| * | |
| * @param {string} downloadURL the url to download in content manager | |
| * @returns {string} | |
| */ | |
| const createInstallURL = (downloadURL) => | |
| `acmanager://install?url=${encodeURIComponent(downloadURL)}` | |
| /** | |
| * @param {Element} el | |
| */ | |
| const attachInstallLink = (el) => { | |
| /** @type {HTMLAnchorElement} */ | |
| // @ts-expect-error we know this is an anchor element | |
| const a = el | |
| const newAnchor = document.createElement("a") | |
| const parent = a.parentElement | |
| newAnchor.innerText = "install in content manager" | |
| newAnchor.href = createInstallURL(a.href) | |
| newAnchor.style.color = "white" | |
| parent.appendChild(newAnchor) | |
| } | |
| document.querySelectorAll("a.fusion-column-anchor").forEach(attachInstallLink) | |
| })() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment