HFUT Captcha Filler

自动填充合肥工业大学信息门户的登录验证码,调用百度云通用文字识别接口,不保证准确度。

当前为 2020-04-01 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @namespace https://greasyfork.org/users/443103
  3. // @name HFUT Captcha Filler
  4. // @name:en HFUT Captcha Filler
  5. // @name:zh 合工大信息门户验证码自动填充
  6. // @name:zh-CN 合工大信息门户验证码自动填充
  7. // @description 自动填充合肥工业大学信息门户的登录验证码,调用百度云通用文字识别接口,不保证准确度。
  8. // @description:en Automatically fill the captcha on my.hfut.edu.cn, using baiduyun api.
  9. // @description:zh 自动填充合肥工业大学信息门户的登录验证码,调用百度云通用文字识别接口,不保证准确度。
  10. // @description:zh-CN 自动填充合肥工业大学信息门户的登录验证码,调用百度云通用文字识别接口,不保证准确度。
  11. // @include *://my.hfut.edu.cn/*
  12. // @version 1.0.3
  13. // @author Zijun Yu
  14. // @grant GM_xmlhttpRequest
  15. // ==/UserScript==
  16.  
  17. // 百度云已关闭通用文字识别api
  18.  
  19. "use strict";
  20. setTimeout(function () {
  21. var api = 'https://aip.baidubce.com/rest/2.0/ocr/v1/general_basic?access_token=24.a227a80dd03bacb2059c50d1021d6cf7.2592000.1583841714.282335-18426133';
  22. var imgElement = document.getElementById('captchaImg');
  23. var canvasElement = document.createElement('canvas');
  24. canvasElement.height = 100;
  25. canvasElement.width = 230;
  26. canvasElement.getContext('2d').drawImage(imgElement, 0, 0);
  27. var base64 = canvasElement.toDataURL().split(',')[1];
  28. GM_xmlhttpRequest({
  29. method: 'POST',
  30. url: api,
  31. headers: { "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8" },
  32. data: 'image=' + encodeURIComponent(base64),
  33. onload: function (res) {
  34. var response = JSON.parse(res.response);
  35. document.getElementById('code').value = response.words_result[0].words;
  36. }
  37. });
  38. }, 1000);