Skip to content

Instantly share code, notes, and snippets.

@keesiemeijer
Last active January 20, 2020 07:06
Show Gist options
  • Select an option

  • Save keesiemeijer/e5010e61a6f9948b0d739f7fb542de18 to your computer and use it in GitHub Desktop.

Select an option

Save keesiemeijer/e5010e61a6f9948b0d739f7fb542de18 to your computer and use it in GitHub Desktop.
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

keesiemeijer commented Oct 25, 2018

Copy link
Copy Markdown
Author

Installation

For Firefox install Install Greasemonkey.
For Chrome install Tampermonkey

Click this link to Download and install this redirect user script

@vbnetgenius

Copy link
Copy Markdown

Thanks dude ...

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