Last active
January 20, 2020 07:06
-
-
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
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 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 ); | |
} | |
} )(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Installation
For Firefox install Install Greasemonkey.
For Chrome install Tampermonkey
Click this link to Download and install this redirect user script