Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A Greasemonkey user script that forces https, adds view=all to topic urls and redirects if needed
// ==UserScript==
// @name WordPress topic redirect
// @namespace WordPress_topic_redirect
// @description Forces https, adds view=all to topic urls and redirects if needed in the WordPress support forums.
// @version 1
// @grant none
// @run-at document-start
// @include *://*wordpress.org/support/topic/*
// @include *://wordpress.org/support/users/*
// @include *://wordpress.org/support/theme/*
// @include *://wordpress.org/support/plugin/*
// @include *://wordpress.org/support/forum/*
// ==/UserScript==
/*
*
* For installation instructions see the first comment of this gist.
*
* https://gist.github.com/keesiemeijer/e5010e61a6f9948b0d739f7fb542de18
*
*/
( 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 ) {
var 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 );
}
} )();
@keesiemeijer

This comment has been minimized.

Copy link
Owner Author

@keesiemeijer keesiemeijer commented Oct 25, 2018

Installation

For Firefox install Install Greasemonkey.
For Chrome install Tampermonkey

Click this link to Download and install this redirect user script

@vbnetgenius

This comment has been minimized.

Copy link

@vbnetgenius vbnetgenius commented Jan 20, 2020

Thanks dude ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment