Greasy Fork is available in English.

Discussioni » Richieste di creazione

I want to create a small script for changing a small part of a url

§
Pubblicato: 21/03/2021
Modificato: 21/03/2021

Hi,

I want to create a script in which when I get into an artist profile in deviantart.com, the url changes -
from "deviantart.com/user" or "deviantart.com/user/gallery"
to "deviantart.com/user/gallery/all

It should probably be just a few lines of code, and should be easy enough with regex like ^https?:\/\/www\.deviantart\.com\/[a-zA-Z0-9\-\_]+(?:\/gallery)?, but I'm not sure how to implement that into a script.

Can anybody please help me with it?

§
Pubblicato: 21/03/2021

A little bit later

§
Pubblicato: 21/03/2021
// ==UserScript==
// @name          deviantart.com: redirect to gallery
// @description   Performs redirect from any user page to the user "gallery/all"
// @author        Konf
// @namespace     https://greasyfork.org/users/424058
// @icon          https://www.google.com/s2/favicons?domain=deviantart.com&sz=32
// @version       1.0.0
// @include       /^https?:\/\/www\.deviantart\.com\/[a-zA-Z0-9\-\_]+(?:\/gallery)?$/
// @run-at        document-start
// @grant         none
// @noframes
// ==/UserScript==

(function() {
  const userName = location.pathname.split('/')[1];

  window.location.href = location.origin + '/' + userName + '/gallery/all';
})();
§
Pubblicato: 23/03/2021

@Konf, thank you very much! 🙏

Pubblica risposta

Accedi per pubblicare una risposta.