twimg_redirect_orig

Redirect twimg to :orig

  1. // ==UserScript==
  2. // @name twimg_redirect_orig
  3. // @namespace http://catherine.v0cyc1pp.com/twimg_redirect_orig.user.js
  4. // @match *://pbs.twimg.com/media/*
  5. // @match *://pbs.twimg.com/media/*:large
  6. // @match *://pbs.twimg.com/media/*:thumb
  7. // @match *://pbs.twimg.com/media/*:small
  8. // @exclude https://pbs.twimg.com/media/*:orig#*
  9. // @run-at document-start
  10. // @author greg10
  11. // @license GPL 3.0
  12. // @version 1.9
  13. // @grant none
  14. // @description Redirect twimg to :orig
  15. // @license MIT
  16. // ==/UserScript==
  17. var str = document.location + "";
  18. //mobile.twitter.com用の不要な文字列をはずす
  19. str = str.replace( /&name=[^&]+/, "");
  20. str = str.replace( /\?format=/, ".");
  21. str = str.replace( /:(thumb|small|large|orig).*$/, "");
  22. //str = str.replace( /^https:/, "http:"); // httpが自動的にhttpsにリダイレクトされるようになったので、この行をONにすると無限ループになる。したがってOFFにする。出力されるURLはhttpsになる。2017/7/21
  23. var ext = str.substr( str.length - 3, 3);
  24. //console.log("ext="+ext);
  25. var url = str + ":orig#." + ext;
  26. window.location.replace( url );
  27.