Skip to content

Instantly share code, notes, and snippets.

@ttttmr
Last active March 6, 2023 17:02
Show Gist options
  • Save ttttmr/577acf8a7ddf97c8972a6132a15e238a to your computer and use it in GitHub Desktop.
Save ttttmr/577acf8a7ddf97c8972a6132a15e238a to your computer and use it in GitHub Desktop.
一键订阅到Inoreader,相关:一键复制RSS https://gist.github.com/ttttmr/d44e40e92abb4966edcdee2e09fe8ffc
javascript: (function () {
let rsshub_host = 'https://rsshub.app';
let cnblog = 'https://www.cnblogs.com/';
let csdn = 'https://blog.csdn.net/';
let jianshu_user = '/jianshu/user/';
let zhihu_user = '/zhihu/people/activities/';
let zhihu_collection = '/zhihu/collection/';
let bilibili_user = '/bilibili/user/video/';
let jike_topic = '/jike/topic/';
let jike_square = '/jike/topic/square/';
let jike_user = '/jike/user/';
let twitter_user = '/twitter/user/';
let weibo_user = '/weibo/user/';
let instagram_user = '/instagram/user/';
let youtube_channel = '/youtube/channel/';
let github_issues = '/github/issue/';
let w = 800;
let h = 600;
let feedurl = '';
let domain = location.host;
let path = location.pathname.split('/');
if (domain == 'www.cnblogs.com') {
feedurl = cnblog + path[1] + '/rss';
} else if (domain == 'blog.csdn.net') {
feedurl = csdn + path[1] + '/rss/list';
}
if (feedurl != '') {
console.log('RSS found in Website');
} else {
console.log('RSS not found in Website');
console.log('Trying RSSHub ... ');
let rsshub_path = '';
if (domain == 'www.jianshu.com') {
if (path[1] == 'u') {
rsshub_path = jianshu_user + path[2];
} else {
alert('Use it in Jianshu user page');
return;
}
} else if (domain == 'www.zhihu.com') {
if (path[1] == 'people' || path[1] == 'org') {
rsshub_path = zhihu_user + path[2];
} else if (path[1] == 'collection') {
rsshub_path = zhihu_collection + path[2];
} else {
alert('Use it in Zhihu user page');
return;
}
} else if (domain == 'space.bilibili.com') {
rsshub_path = bilibili_user + path[1];
} else if (domain == 'web.okjike.com') {
if (path[1] == 'topic') {
if (path[3] == 'official') {
rsshub_path = jike_topic + path[2];
} else if (path[3] == 'user') {
rsshub_path = jike_square + path[2];
}
} else if (path[1] == 'user') {
rsshub_path = jike_user + path[2];
} else {
alert('Use it in Jike user or topic page');
return;
}
} else if (domain == 'twitter.com') {
rsshub_path = twitter_user + path[1];
} else if (domain == 'm.weibo.cn') {
if (path[1] == 'profile') {
rsshub_path = weibo_user + path[2];
} else {
alert('Use it in Weibo user home page');
return;
}
} else if (domain == 'weibo.com' || domain == 'www.weibo.com') {
rsshub_path = weibo_user + $CONFIG.oid;
} else if (domain == 'www.instagram.com') {
if (path[1] == 'p') {
alert('Use it in Instagram user home page');
return;
} else {
rsshub_path = instagram_user + path[1];
}
} else if (domain == 'www.youtube.com') {
if (path[1] == 'channel') {
rsshub_path = youtube_channel + path[2];
} else {
alert('Use it in YouTube channel page');
return;
}
} else if (domain == 'github.com') {
if (path[3] == 'issues'){
rsshub_path = github_issues + path[1] + '/' + path[2];
} else {
alert('Use it in GitHub Issues page');
return;
}
}
if (rsshub_path == '') {
console.log('RSS not found');
} else {
console.log('RSS found in RSSHub');
feedurl = rsshub_host + rsshub_path;
}
}
if (feedurl) {
console.log(feedurl);
feedurl = 'https://www.inoreader.com/?add_feed=' + feedurl;
} else {
feedurl = 'https://www.inoreader.com/bookmarklet/subscribe/' + encodeURIComponent(location.href);
}
console.log(feedurl);
let b = window.screenLeft != undefined ? window.screenLeft : screen.left;
let c = window.screenTop != undefined ? window.screenTop : screen.top;
let width = window.innerWidth ?
window.innerWidth :
document.documentElement.clientWidth ?
document.documentElement.clientWidth :
screen.width;
let height = window.innerHeight ?
window.innerHeight :
document.documentElement.clientHeight ?
document.documentElement.clientHeight :
screen.height;
let d = width / 2 - w / 2 + b;
let e = height / 2 - h / 2 + c;
let f = window.open(
feedurl,
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();
}
})();
@ttttmr
Copy link
Author

ttttmr commented Jun 18, 2018

更多说明另见 https://tmr.js.org/p/dd73704/

@rupigcute
Copy link

配合Inoreader 超好用直接按一下就可以存RSS了!!!必推啊~

@Maecenas
Copy link

感谢!因为 GitHub Gist 没有 Watch 功能追踪更新,不知道能不能在脚本里加入更新提示呀?

@ttttmr
Copy link
Author

ttttmr commented May 15, 2019

感谢!因为 GitHub Gist 没有 Watch 功能追踪更新,不知道能不能在脚本里加入更新提示呀?

我设置公开了,应该可以在GitHub上订阅了

@ttttmr
Copy link
Author

ttttmr commented Jun 8, 2019

Gist不再更新,移步至 https://github.com/ttttmr/UserJS

Gist is no longer updated, the latest version is at https://github.com/ttttmr/UserJS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment