Better multireddit URL

Replace the browser URL with one you can actually share

当前为 2016-08-28 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Better multireddit URL
  3. // @namespace http://cantcode.com
  4. // @description Replace the browser URL with one you can actually share
  5. // @include http://www.reddit.com/me/m/*
  6. // @include https://www.reddit.com/me/m/*
  7. // @version 1.1
  8. // ==/UserScript==
  9.  
  10. if (document.querySelector('.visibility-group input[name=visibility]:checked').value === 'private')
  11. return;
  12.  
  13. 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];
  14.  
  15. window.history.replaceState({}, "", "/user/" + username + "/m/" + window.location.pathname.split("/")[3]);