Change Deviantart "sort by" option back to newest

This replaces the default "/gallery" URL with "/gallery/all?order=newest" in order to make newest sort default for a user's gallery page. You must click on the "all" gallery, or manually refresh the page to activate. This just a quick patch because I don't know JS.

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Change Deviantart "sort by" option back to newest
// @namespace    https://www.deviantart.com
// @version      2025-11-16
// @description  This replaces the default "/gallery" URL with "/gallery/all?order=newest" in order to make newest sort default for a user's gallery page. You must click on the "all" gallery, or manually refresh the page to activate. This just a quick patch because I don't know JS.
// @author       Michael Washboard
// @match        https://www.deviantart.com/*gallery
// @match        https://www.deviantart.com/*gallery/all
// @icon         https://st.deviantart.net/eclipse/icons/favicon-v2-16x16.png
// @grant        none
// @license MIT
// ==/UserScript==
const { href } = window.location;
if (href.slice(-1) == 'l') {
  window.location.replace(href + '?order=newest')
} else if (href.slice(-1) !== '/all?order=newest') {
  window.location.replace(href + '/all?order=newest');
}