Better multireddit URL

I don't want your dumb default URL

当前为 2015-04-19 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Better multireddit URL
  3. // @namespace http://cantcode.com
  4. // @description I don't want your dumb default URL
  5. // @include http://www.reddit.com/me/m/*
  6. // @version 1.0
  7. // ==/UserScript==
  8.  
  9. if (document.querySelector('.visibility-group input[name=visibility]').value === 'private') return
  10.  
  11. var username = /reddit\.com\/user\/([\-\w\.#=]*)\/?(?:comments)?\/?(?:\?(?:[a-z]+=[a-zA-Z0-9_%]*&?)*)?$/i.exec(document.querySelector("#header-bottom-right .user a:first-child").getAttribute('href'))[1]
  12.  
  13. window.history.pushState({}, "", "/" + username + "/m/" + window.location.pathname.split("/")[3])