Skip to content

Instantly share code, notes, and snippets.

@y4code
Created October 26, 2020 05:16
Show Gist options
  • Save y4code/47ca6a6df1af96242de2bd253b16f77b to your computer and use it in GitHub Desktop.
Save y4code/47ca6a6df1af96242de2bd253b16f77b to your computer and use it in GitHub Desktop.
v2ex按感谢数量查看帖子.js
// let ori = [];
// ori.sort(
// compare,
// )
// function compare(a: any, b: any): number {
// var a_compare = Number(a.getElementsByClassName('small fade')[0].innerText.substring(1)) ?? 0;
// var b_compare = Number(b.getElementsByClassName('small fade')[0].innerText.substring(1)) ?? 0;
// if (a_compare > b_compare) { // 按某种排序标准进行比较, a 小于 b
// return -1;
// }
// if (a_compare < b_compare) {
// return 1;
// }
// return 0;
// }
// #r_7013167 > table > tbody > tr > td: nth - child(3) > span.small.fade > img
// #r_7014240 > table > tbody > tr > td:nth-child(3) > span.small.fade > img
var origin = $('div[class=cell][id^=r_]')
function compare(a, b) {
var a_compare = Number(a.getElementsByClassName('small fade')[0]?.innerText.substring(1) ?? 0);
var b_compare = Number(b.getElementsByClassName('small fade')[0]?.innerText.substring(1) ?? 0);
if (a_compare > b_compare) { // 按某种排序标准进行比较, a 小于 b
console.log('-1')
return -1;
}
if (a_compare < b_compare) {
console.log('1')
return 1;
}
console.log('0')
return 0;
}
var sorted = origin.sort(compare);
$(".box")[5].remove();
sorted.appendTo($(".box")[5]);
// origin.forEach(e => {
// console.log(e.getElementsByClassName('small fade')[0]?.innerText.substring(1) ?? 0);
// });
@y4code
Copy link
Author

y4code commented Mar 11, 2021

// ==UserScript==
// @name 假装在用Terminal,实际在上V2EX
// @namespace http://tampermonkey.net/
// @Version 0.1
// @description try to take over the world!
// @author You
// @match https://v2ex.com/*
// @grant none
// ==/UserScript==

(function () {
'use strict';

// Your code here...
[].forEach.call(document.getElementsByTagName("*"), (element => {
    element.style.filter = 'grayscale(1)';
    element.style.background = 'black';
    element.style.color = 'white';
    // console.log(element)
}))

})();

@y4code
Copy link
Author

y4code commented May 17, 2021

// ==UserScript==
// @name 移除虎牙交友直播间
// @namespace http://tampermonkey.net/
// @Version 0.1
// @description try to take over the world!
// @author You
// @match https://www.huya.com/l
// @grant none
// ==/UserScript==

(function () {
'use strict';
[].filter.call($(".game-live-item"), (e) => {
return e.innerText.includes('交友')
|| e.innerText.includes('王者荣耀')
|| e.innerText.includes('地下城与勇士')
|| e.innerText.includes('和平精英')
}).forEach(e => e.remove())
})();

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