Created
March 27, 2020 06:37
-
-
Save RustingSword/e52c6f53133be8d625646d966780dc17 to your computer and use it in GitHub Desktop.
km and v2ex tweak
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Remove kmref | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author You | |
// @match http://km.oa.com/* | |
// @match https://www.v2ex.com/* | |
// @run-at document-idle | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
var links = document.getElementsByTagName('a'); | |
for (var i = 0; i < links.length; i++) { | |
var kmref = links[i].href.indexOf('?kmref='); | |
if (kmref != -1) { | |
links[i].href = links[i].href.substring(0, kmref); | |
} | |
var v2ex = links[i].href.indexOf('#reply'); | |
if (v2ex != -1) { | |
links[i].href = links[i].href.substring(0, v2ex) + '?p=1'; | |
} else { | |
if (links[i].href.indexOf('www.v2ex.com/t/') != -1) { | |
if (links[i].href.indexOf("?p=") == -1) { | |
links[i].href += '?p=1'; | |
} | |
} | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment