Skip to content

Instantly share code, notes, and snippets.

@VitoVan
Created July 21, 2017 09:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save VitoVan/bf00ce496b44c56417a675c521fe67e8 to your computer and use it in GitHub Desktop.
Save VitoVan/bf00ce496b44c56417a675c521fe67e8 to your computer and use it in GitHub Desktop.
Enable Gift ClickOnce Feature (V2EX)
/*
MIT License
Copyright (c) 2017
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
//Enable Gift ClickOnce Feature
$('a[href="/mission/daily"]')
.attr('id', 'gift_v2excellent')
.attr('href', '#')
.click(function() {
$('#gift_v2excellent').text('正在领取......');
$.get('/mission/daily', function(result) {
var giftLink = $('<output>')
.append($.parseHTML(result))
.find('input[value^="领取"]')
.attr('onclick')
.match(/\/mission\/daily\/redeem\?once=\d+/g)[0];
$.get(giftLink, function(checkResult) {
var okSign = $('<output>')
.append($.parseHTML(checkResult))
.find('li.fa.fa-ok-sign');
if (okSign.length > 0) {
$.get('/balance', function(result) {
var amount = $('<output>')
.append($.parseHTML(result))
.find('table>tbody>tr:contains("每日登录"):first>td:nth(2)')
.text();
$('#gift_v2excellent').html(
'已领取 <strong>' + amount + '</strong> 铜币。'
);
setTimeout(function() {
$('#Rightbar>.sep20:nth(1)').remove();
$('#Rightbar>.box:nth(1)').remove();
}, 2000);
});
}
});
});
return false;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment