Skip to content

Instantly share code, notes, and snippets.

@vincentzhang96
Last active May 30, 2017 15:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vincentzhang96/266e51cd07abdf3e0f457a8d74ad48f9 to your computer and use it in GitHub Desktop.
Save vincentzhang96/266e51cd07abdf3e0f457a8d74ad48f9 to your computer and use it in GitHub Desktop.
Automatically redirects forum pages to sort by last reply instead of thread creation
// ==UserScript==
// @name DNNA Forum Last Reply Default
// @namespace com.divinitor
// @include http://forum.dragonnest.com/forum/*
// @version 1
// @grant none
// ==/UserScript==
/*
The MIT License
Copyright 2017 Vahr
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
window.addEventListener('load', function() {
var isSubForum = /forum\/[a-z\-]+?\/[^\/]+?$/.test(location.href);
if (isSubForum) {
console.log("Is subforum, testing for filter");
// Don't override an existing filter
var idx = location.href.indexOf('filter_sort');
if (idx === -1) {
console.log("Redirecting to lastcontent sort")
location.replace(location.href + '?filter_sort=lastcontent');
} else {
console.log("Redirect skipped, already filtered");
}
} else {
console.log("Redirect skipped, not subforum")
}
}, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment