Created
November 1, 2025 00:21
-
-
Save kashif-umair/04091f57a969bde333c4f46f2ff9d505 to your computer and use it in GitHub Desktop.
Ruby on Rails API Version Selector
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 Ruby on Rails API Version Selector | |
| // @namespace http://kashif.ie/ | |
| // @version 2025-10-31 | |
| // @description Add a dropdown on ruby on rails API website to go to a different version | |
| // @author KULKING | |
| // @match https://api.rubyonrails.org/* | |
| // @icon https://www.google.com/s2/favicons?sz=64&domain=rubyonrails.org | |
| // @grant none | |
| // ==/UserScript== | |
| (function () { | |
| const versions = ['8.1.0', '7.0.8.7', '7.1.5.1', '7.2.2.1', '6.1.7.6']; | |
| function addDropdown() { | |
| const trigger = document.createElement('select'); | |
| trigger.id = 'select_ror_version'; | |
| // only your styles | |
| Object.assign(trigger.style, { | |
| position: 'fixed', | |
| top: '30px', | |
| left: '90%', | |
| height: '30px', | |
| width: '300px', | |
| transform: 'translate(-50%, -50%)', | |
| 'border-radius': '5px', | |
| zIndex: '999999999' | |
| }); | |
| const currentVersion = document.querySelector(".banner span").innerText.replace("Ruby on Rails ", ""); | |
| console.log(currentVersion); | |
| for(const opt of versions) { | |
| let option = document.createElement('option'); | |
| option.text = opt; | |
| option.value = `v${opt}`; | |
| if(currentVersion === opt) { | |
| option.selected = true | |
| } | |
| trigger.appendChild(option); | |
| } | |
| document.body.prepend(trigger); | |
| trigger.addEventListener('change', e => { | |
| e.preventDefault(); | |
| let selectedVersion = e.target.value; | |
| console.log("Navigating to version:", selectedVersion); | |
| location.href = `https://api.rubyonrails.org/${selectedVersion}`; | |
| }); | |
| } | |
| setTimeout(function() { | |
| console.log("Working"); | |
| addDropdown(); | |
| }, 200); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment