javascript [一键订阅Inoreader书签脚本]可用于在浏览器创建一个“一键订阅至Inoreader”的脚本书签按钮

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript [一键订阅Inoreader书签脚本]可用于在浏览器创建一个“一键订阅至Inoreader”的脚本书签按钮相关的知识,希望对你有一定的参考价值。

javascript: (function () {
  var host = 'https://rsshub.app/';
  var w = 800;
  var h = 600;
  var add = 'https://www.inoreader.com/?add_feed=';
  var cnblog = 'https://www.cnblogs.com/';
  var csdn = 'https://blog.csdn.net/';
  var jianshu_user = host + 'jianshu/user/';
  var zhihu_user = host + '/zhihu/people/activities/';
  var zhihu_collection = host + 'zhihu/collection/';
  var bilibili_user = host + 'bilibili/user/video/';
  var jike_topic = host + 'jike/topic/';
  var jike_square = host + 'jike/topic/square/';
  var jike_user = host + 'jike/user/';
  var twitter_user = host + 'twitter/user/';
  var weibo_user = host + 'weibo/user/';
  var instagram_user = host + 'instagram/user/';
  var youtube_channel = host + 'youtube/channel/';

  var url =
    'https://www.inoreader.com/bookmarklet/subscribe/' +
    encodeURIComponent(location.href);
  if (location.host == 'www.cnblogs.com') {
    url = add + cnblog + location.pathname.split('/')[1] + '/rss';
  } else if (location.host == 'www.jianshu.com') {
    if (location.pathname.split('/')[1] == 'u') {
      url = add + jianshu_user + location.pathname.split('/')[2];
    } else {
      alert('请在简书用户页面使用');
      return;
    }
  } else if (location.host == 'www.zhihu.com') {
    if (
      location.pathname.split('/')[1] == 'people' ||
      location.pathname.split('/')[1] == 'org'
    ) {
      url = add + zhihu_user + location.pathname.split('/')[2];
    } else if (location.pathname.split('/')[1] == 'collection') {
      url = add + zhihu_collection + location.pathname.split('/')[2];
    } else {
      alert('请在知乎用户页面使用');
      return;
    }
  } else if (location.host == 'blog.csdn.net') {
    url = add + csdn + location.pathname.split('/')[1] + '/rss/list';
  } else if (location.host == 'space.bilibili.com') {
    url = add + bilibili_user + location.pathname.split('/')[1];
  } else if (location.host == 'web.okjike.com') {
    var path = location.pathname.split('/');
    if (path[1] == 'topic') {
      if (path[3] == 'official') {
        url = add + jike_topic + path[2];
      } else if (path[3] == 'user') {
        url = add + jike_square + path[2];
      }
    } else if (path[1] == 'user') {
      url = add + jike_user + path[2];
    } else {
      alert('请在即刻用户页或主题页使用');
      return;
    }
  } else if (location.host == 'twitter.com') {
    url = add + twitter_user + location.pathname.split('/')[1];
  } else if (location.host == 'm.weibo.cn') {
    var path = location.pathname.split('/');
    if (path[1] == 'profile') {
      url = add + weibo_user + path[2];
    } else {
      alert('请在微博用户主页使用');
      return;
    }
  } else if (location.host == 'weibo.com' || location.host == 'www.weibo.com') {
    url = add + weibo_user + $CONFIG.oid;
  } else if (location.host == 'www.instagram.com') {
    var path = location.pathname.split('/');
    if (path[1] == 'p') {
      alert('请在用户主页使用');
      return;
    } else {
      url = add + instagram_user + path[1];
    }
  } else if (location.host == 'www.youtube.com') {
    if (location.pathname.split('/')[1] == 'channel') {
      url = add + youtube_channel + location.pathname.split('/')[2];
    } else {
      alert('请在YouTube频道页使用');
    }
  } else if (location.host == 'w.qnmlgb.tech') {
    if (location.pathname.split('/')[1] == 'authors') {
      url = add + 'https://q.qnmlgb.tech/w/rss/' + location.pathname.split('/')[2];
    } else {
      alert('请在公众号主页使用');
    }
  }
  console.log(url);
  var b = window.screenLeft != undefined ? window.screenLeft : screen.left;
  var c = window.screenTop != undefined ? window.screenTop : screen.top;
  var width = window.innerWidth ?
    window.innerWidth :
    document.documentElement.clientWidth ?
    document.documentElement.clientWidth :
    screen.width;
  var height = window.innerHeight ?
    window.innerHeight :
    document.documentElement.clientHeight ?
    document.documentElement.clientHeight :
    screen.height;
  var d = width / 2 - w / 2 + b;
  var e = height / 2 - h / 2 + c;
  var f = window.open(
    url,
    new Date().getTime(),
    'width=' +
    w +
    ', height=' +
    h +
    ', top=' +
    e +
    ', left=' +
    d +
    'location=yes,resizable=yes,status=no,scrollbars=no,personalbar=no,toolbar=no,menubar=no'
  );
  if (window.focus) {
    f.focus();
  }
})();

以上是关于javascript [一键订阅Inoreader书签脚本]可用于在浏览器创建一个“一键订阅至Inoreader”的脚本书签按钮的主要内容,如果未能解决你的问题,请参考以下文章

贝宝订阅每月选项并立即购买全价一键通话

html 一键取消订阅AMPscript

如何在 JavaScript/TypeScript 中创建具有非唯一键的地图?

javascript 一键提交多个表单

JavaScript-动画原理如何使用js进行动画效果的实现

无需 Javascript 即可为 Apple 设备一键复制页面