获取阿里云TOKEN.js 965 B

1234567891011121314151617181920212223242526272829303132
  1. // ==UserScript==
  2. // @name 获取阿里云token
  3. // @version 1
  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 access_token = t.access_token;
  11. var refresh_token = t.refresh_token;
  12. var default_drive_id=t.default_drive_id;
  13. setCookie('access_token', access_token, 30);
  14. setCookie('refresh_token', refresh_token, 30);
  15. setCookie('default_drive_id',default_drive_id,30);
  16. alert('COOKIE获取成功 注意:如果不包含access_token请刷新几次\r\n'+document.cookie);
  17. }
  18. function setCookie(name, value, day) {
  19. if (day) {
  20. //当设置的时间等于0时,不设置expires属性,cookie在浏览器关闭后删除
  21. var expires = day * 24 * 60 * 60 * 1000;
  22. var date = new Date(+ new Date() + expires);
  23. document.cookie =
  24. name + '=' + value + ';expires=' + date.toUTCString();
  25. } else {
  26. document.cookie = name + '=' + value;
  27. }
  28. }