141 lines
4.0 KiB
HTML
141 lines
4.0 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="renderer" content="webkit" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
|
|
<title>微博RSS订阅生成器</title>
|
|
<link rel="stylesheet" href="css/bootstrap.min.css">
|
|
<link rel="shortcut icon" href="favicon.ico"/>
|
|
<style>
|
|
.content {
|
|
max-width: 500px;
|
|
margin-left: auto;
|
|
margin-right: auto;
|
|
padding: 15px;
|
|
}
|
|
.head {
|
|
margin-top: 70px;
|
|
}
|
|
.intro {
|
|
margin-top: 30px;
|
|
}
|
|
.loading {
|
|
margin-top: 20px;
|
|
}
|
|
.result {
|
|
margin-top: 20px;
|
|
}
|
|
.footer-bottom {
|
|
margin-top: 100px;
|
|
}
|
|
.reader-list {
|
|
margin-top: 20px;
|
|
}
|
|
#form {
|
|
margin-top: 18px;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<div class="row">
|
|
<div class="content">
|
|
<div class="head">
|
|
<h2 class="text-center">Weibo to RSS</h2>
|
|
<p class="intro">优雅地使用 RSS 阅读器订阅喜欢的微博博主</p>
|
|
<p>食用方式:<br>1. 在输入框中粘贴你想订阅的微博地址<br>2. 点击“生成”按钮,获得RSS订阅源</p>
|
|
<form id="form">
|
|
<div class="input-group">
|
|
<input id="text-input" type="text" class="form-control" placeholder="https://weibo.com/kaifulee">
|
|
<span class="input-group-btn">
|
|
<button class="btn btn-default">生成</button>
|
|
</span>
|
|
</div>
|
|
<div class="input-group" style="margin-top: 10px;">
|
|
<span class="input-group-addon">页码</span>
|
|
<input id="page-input" type="text" class="form-control" value="1" placeholder="1 / 7 / 1-10 / 1,3,5">
|
|
</div>
|
|
</form>
|
|
</div>
|
|
<div class="loading" style="display: none;"><p class="text-center">加载中...</p></div>
|
|
<div class="result" style="display: none;">
|
|
<p>生成的RSS订阅源:</p>
|
|
<div class="input-group">
|
|
<input id="foo" type="text" class="form-control" value="">
|
|
<span class="input-group-btn">
|
|
<button id="copy-btn" data-clipboard-action="copy" data-clipboard-target="#foo" class="btn btn-default">复制到剪贴板</button>
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="footer-bottom">
|
|
<div class="container">
|
|
<p class="text-mute text-center">Powered by <a href="https://github.com/zgq354/weibo-rss" target="_blank">weibo-rss</a>.</p>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
<script src="js/jquery-3.2.1.min.js"></script>
|
|
<script src="js/clipboard.min.js"></script>
|
|
<script>
|
|
var prefix = {
|
|
inoreader: "https://www.inoreader.com/?add_feed=",
|
|
feedly: "https://cloud.feedly.com/#subscription/feed/",
|
|
};
|
|
|
|
// 初始化Clipboard插件
|
|
var clipboard = new Clipboard('#copy-btn');
|
|
clipboard.on('success', function(e) {
|
|
console.log(e);
|
|
});
|
|
clipboard.on('error', function(e) {
|
|
console.log(e);
|
|
});
|
|
|
|
// 链接处理
|
|
$('#form').on('submit', function (e) {
|
|
e.preventDefault();
|
|
$(".result").hide();
|
|
$(".loading").show();
|
|
|
|
var input = $("#text-input").val();
|
|
var temp = input.match(/weibo\.(com|cn)\/(u|(profile))?\/?(\d{10})/);
|
|
if (!temp) {
|
|
temp = input.match(/weibo\.(com|cn)\/(u|(profile))?\/?([^?]+?)($|\?)/);
|
|
if (!temp) {
|
|
showResult(false);
|
|
} else {
|
|
$.get("api/domain2uid?domain=" + temp[4], function (data) {
|
|
showResult(data.uid);
|
|
}).fail(function (err) {
|
|
showResult(false);
|
|
});
|
|
}
|
|
} else {
|
|
showResult(temp[4]);
|
|
}
|
|
});
|
|
// 显示结果
|
|
function showResult(uid) {
|
|
$(".loading").hide();
|
|
// console.log(uid);
|
|
if (!uid) {
|
|
alert("数据获取失败");
|
|
return;
|
|
}
|
|
var baseUrl = location.href.split("?")[0];
|
|
if (baseUrl.substr(-1, 1) !== "/") baseUrl += "/";
|
|
var page = $.trim($("#page-input").val()) || "1";
|
|
var feedUrl = baseUrl + "rss/user/" + uid + "?page=" + encodeURIComponent(page);
|
|
|
|
$("#foo").val(feedUrl);
|
|
for (var reader in prefix) {
|
|
$("#" + reader).attr("href", prefix[reader] + feedUrl);
|
|
}
|
|
$(".result").show();
|
|
}
|
|
</script>
|
|
</html>
|