Greasy Fork is available in English.

让你的飞书更好用(优化版)

让飞书文档不受权限限制,可以复制任意内容,可以打开右键菜单(复制下载图片)

  1. // ==UserScript==
  2. // @name 让你的飞书更好用(优化版)
  3. // @license GPL License
  4. // @namespace https://bytedance.com
  5. // @version 0.5
  6. // @description 让飞书文档不受权限限制,可以复制任意内容,可以打开右键菜单(复制下载图片)
  7. // @author NOABC
  8. // @match *://*.feishu.cn/*
  9. // @match *://*.larkoffice.com/*
  10. // @icon https://www.google.com/s2/favicons?sz=64&domain=feishu.cn
  11. // @grant none
  12. // @run-at document-start
  13. // ==/UserScript==
  14. (function () {
  15. // Override addEventListener to handle copy and contextmenu events
  16. const overrideEventListeners = () => {
  17. const rawAddEventListener = EventTarget.prototype.addEventListener;
  18. EventTarget.prototype.addEventListener = function (type, listener, options) {
  19. if (type === 'copy') {
  20. rawAddEventListener.call(this, type, event => {
  21. event.stopImmediatePropagation();
  22. return null;
  23. }, options);
  24. return;
  25. }
  26. if (type === 'contextmenu') {
  27. rawAddEventListener.call(this, type, event => {
  28. event.stopImmediatePropagation();
  29. return listener(event);
  30. }, options);
  31. return;
  32. }
  33. rawAddEventListener.call(this, type, listener, options);
  34. };
  35. };
  36.  
  37. // Override XMLHttpRequest to manipulate permission responses
  38. const overrideXHR = () => {
  39. const rawOpen = XMLHttpRequest.prototype.open;
  40. XMLHttpRequest.prototype.open = function (method, url, ...rest) {
  41. this.addEventListener('readystatechange', function () {
  42. if (this.readyState === 4 && url.includes('space/api/suite/permission/document/actions/state/')) {
  43. let response = this.responseText;
  44. try {
  45. response = JSON.parse(response);
  46. if (response.data && response.data.actions && response.data.actions.copy !== 1) {
  47. response.data.actions.copy = 1;
  48. Object.defineProperty(this, 'responseText', { value: JSON.stringify(response) });
  49. Object.defineProperty(this, 'response', { value: response });
  50. }
  51. } catch (e) {
  52. console.error('Failed to modify response:', e);
  53. }
  54. }
  55. }, false);
  56. rawOpen.call(this, method, url, ...rest);
  57. };
  58. };
  59.  
  60. // Run overrides immediately and on DOMContentLoaded
  61. overrideEventListeners();
  62. overrideXHR();
  63. document.addEventListener('DOMContentLoaded', () => {
  64. overrideEventListeners();
  65. overrideXHR();
  66. });
  67. })();