获取阿里云盘TOKEN.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // ==UserScript==
  2. // @name 获取阿里云盘token
  3. // @version 2
  4. // @run-at end
  5. // @match https://www.aliyundrive.com
  6. // ==/UserScript==
  7. var l=localStorage.getItem('token')
  8. if (l!=null) {
  9. let t=JSON.parse(l);
  10. var expires = 30 * 24 * 60 * 60 * 1000;
  11. var date = new Date(+ new Date() + expires);
  12. var dateformat=date.toISOString();
  13. var access_token = t.access_token;
  14. var refresh_token = t.refresh_token;
  15. var default_drive_id=t.default_drive_id;
  16. var expire_time=dateformat;
  17. var expires_in="720000";
  18. setCookie('access_token',access_token,30);
  19. setCookie('refresh_token',refresh_token,30);
  20. setCookie('default_drive_id',default_drive_id,30);
  21. setCookie('expire_time',dateformat,30);
  22. setCookie('expires_in',expires_in,30);
  23. alert('COOKIE获取成功 注意:如果不包含access_token请刷新几次\r\n'+document.cookie);
  24. }
  25. function setCookie(name, value, day) {
  26. if (day) {
  27. //当设置的时间等于0时,不设置expires属性,cookie在浏览器关闭后删除
  28. var expires = day * 24 * 60 * 60 * 1000;
  29. var date = new Date(+ new Date() + expires);
  30. document.cookie =
  31. name + '=' + value + ';expires=' + date.toUTCString();
  32. } else {
  33. document.cookie = name + '=' + value;
  34. }
  35. }