QPushForTerm.Ptt

在term.ptt點擊imgur連結時發送推播到Qpush裝置

  1. // ==UserScript==
  2. // @name QPushForTerm.Ptt
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description 在term.ptt點擊imgur連結時發送推播到Qpush裝置
  6. // @author You
  7. // @match https://term.ptt.cc/
  8. // @icon https://www.google.com/s2/favicons?domain=tampermonkey.net
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15. $(document).on("click", "a", function() {
  16. var name = '' // QPush的推名
  17. var code = '' // QPush的推碼
  18.  
  19. if(/^https:\/\/i.imgur.com\/.*$/.test(this.href))
  20. {
  21. var data = new FormData();
  22. data.append( 'name', name );
  23. data.append( 'code', code );
  24. data.append( 'sig', '' );
  25. data.append( 'cache', false );
  26. data.append( 'msg[text]', this.href );
  27.  
  28. var xhr = new XMLHttpRequest();
  29.  
  30. xhr.open( 'POST', 'https://qpush.me/pusher/push_site/', true );
  31. xhr.onreadystatechange = function ( response ) {};
  32. xhr.send( data );
  33. return false;
  34. }
  35.  
  36. });
  37. })();