自动复制pushbullet最后一条文字信息

auto copy last message when pushbullet push a new message

  1. // ==UserScript==
  2. // @name 自动复制pushbullet最后一条文字信息
  3. // @description auto copy last message when pushbullet push a new message
  4. // @include https://www.pushbullet.com
  5. // @version 0.2
  6. // @author yechenyin
  7. // @namespace https://greasyfork.org/users/3586-yechenyin
  8. // @match https://www.pushbullet.com*
  9. // @require https://code.jquery.com/jquery-1.11.2.min.js
  10. // @grant GM_setClipboard
  11. // @run-at document-end
  12. // ==/UserScript==
  13.  
  14.  
  15. jQuery.fn.inserted = function(action) {
  16. var selector = this.selector;
  17. var reaction = function(records) {
  18. records.map(function(record) {
  19. if (record.target !== document.body && $(record.target).find(selector).length) {
  20. action.call($(record.target).find(selector).last());
  21. }
  22. });
  23. };
  24.  
  25. var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
  26. if (MutationObserver) {
  27. var observer = new MutationObserver(reaction);
  28. observer.observe(document.body, {
  29. childList: true,
  30. subtree: true
  31. });
  32. } else {
  33. //setInterval(reaction, 100);
  34. }
  35. };
  36.  
  37. console.log($('.text-part').last().text());
  38. $('.text-part').inserted(function () {
  39. GM_setClipboard($('.text-part').last().text().replace(/\s+$/, ''));
  40. });
  41.  
  42.  
  43.