Android 开发者镜像站重定向

Android 开发者谷歌官方网站自动跳转到无需穿墙的镜像站。

  1. // ==UserScript==
  2. // @name Android 开发者镜像站重定向
  3. // @name:en Android Developer Chinese Version
  4. // @namespace
  5. // @version 1.0
  6. // @description Android 开发者谷歌官方网站自动跳转到无需穿墙的镜像站。
  7. // @description:en Go to developer.android.google.cn when visit developer.android.com in China.
  8. // @author LEORChn
  9. // @match http*://developer.android.com/*
  10. // @match http*://link.zhihu.com/*
  11. // @match http*://www.jianshu.com/*
  12. // @run-at document-start
  13. // @grant none
  14. // @namespace https://gf.qytechs.cn/users/159546
  15. // ==/UserScript==
  16. var hf=location.href;
  17. var reg=hf.split('=http');
  18. var newwindow=false;
  19. (function() {
  20. //alert('detect: '+hf);//知乎的鼠标事件捕捉不到,但是可以加载一点数据,就用读图模式。简书可以抓鼠标事件,就用光标模式
  21. if(location.host==='developer.android.com') {//源墙站 自跳转,但无法在未加载的情况下跳转。以抢读模式支持
  22. jump();
  23. }else if(reg.length==2){//知乎、 ,以抢读模式支持
  24. prepare();
  25. }
  26. if(location.host==='www.jianshu.com'){//简书 ,以光标模式支持
  27. window.addEventListener('mousedown', function(e){
  28. //alert(e);
  29. hf=e.target.toString();//此处的target并非String对象所以需要toString
  30. reg=hf.split('=http');//hf被重载,所以reg也要一起重载
  31. newwindow=true;
  32. if(hf.startsWith('http'))prepare();
  33. },true);
  34. }
  35. })();
  36.  
  37. function prepare(){
  38. //alert(hf);
  39. hf= hf.replace(reg[0]+'=','');
  40. hf= decodeURIComponent(hf);
  41. //alert(hf);
  42. jump();
  43. }
  44.  
  45. function jump(){
  46. hf=hf.replace('developer.android.com','developer.android.google.cn');
  47. //alert('-> '+hf);
  48. if(newwindow) window.open(hf);
  49. else location.replace(hf);
  50. }

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址