Last active
June 29, 2023 13:50
-
-
Save mrfoxtalbot/54662f5ce7af1a7ea6f0ad56d09bd364 to your computer and use it in GitHub Desktop.
Show all threads in WP.org
This file contains 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 WordPress topic redirect | |
// @namespace WordPress_topic_redirect | |
// @description Forces https, adds view=all to topic urls and redirects if needed. | |
// @version 1 | |
// @grant none | |
// @run-at document-start | |
// @include *://*wordpress.org/support/topic/* | |
// @include https://wordpress.org/support/plugin/* | |
// @include https://wordpress.org/support/theme/* | |
// @include https://wordpress.org/support/users/* | |
// @include https://wordpress.org/support/forum/* | |
// ==/UserScript== | |
( function() { | |
var search = window.location.search; | |
var https_protocol = window.location.protocol.replace( /http\:/g, 'https:' ); | |
var url = https_protocol + "//" + window.location.host + window.location.pathname; | |
var new_url = ( https_protocol != window.location.protocol ) ? url : false; | |
if ( search ) { | |
pattern = /view=all/g; | |
if ( !pattern.test( search ) ) { | |
new_url = ( ( new_url ) ? new_url : url ) + search + '&view=all'; | |
} | |
} else { | |
new_url = ( ( new_url ) ? new_url : url ) + '?view=all'; | |
} | |
if ( new_url ) { | |
window.location.replace( new_url + window.location.hash ); | |
} | |
} )(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment