Skip to content

Instantly share code, notes, and snippets.

@RustingSword
Created March 27, 2020 06:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RustingSword/e52c6f53133be8d625646d966780dc17 to your computer and use it in GitHub Desktop.
Save RustingSword/e52c6f53133be8d625646d966780dc17 to your computer and use it in GitHub Desktop.
km and v2ex tweak
// ==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