Skip to content

Instantly share code, notes, and snippets.

@Kenya-West
Created June 26, 2020 12:38
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 Kenya-West/fa360cfceec979c4ca7b257be36d9c94 to your computer and use it in GitHub Desktop.
Save Kenya-West/fa360cfceec979c4ca7b257be36d9c94 to your computer and use it in GitHub Desktop.
VK-link-fixier

Description

A js file for Tampermonkey that allows you to copy any russian mobile phone number in VK.com website redirect to the new item page. This project is a script for VK website.

How to contribute

Clone this project on GitHub and start your changes. If you want to use the script from source code, then create new script in Tampermonkey extension and put source code in opened window.

How to use this script?

You need Tampermonkey extension installed on your browser to use this style.

You can install the script from Greasyfork.

P. S. Author is not affiliated in any kind of mentioned organizations.

// ==UserScript==
// @name VK link fixier
// @namespace http://vk.com/
// @version 0.1
// @description This script removes 'vk.com/away' links redirects
// @author Kenya-West
// @include https://vk.com/*
// @grant none
// ==/UserScript==
setInterval(function () {
main()
}, 500)
function main() {
const links = document.querySelectorAll("a[href^='/away.php']");
links.forEach(link => {
let result = fixLink(link.href);
if (result) {
link.href = result;
}
});
function fixLink(href) {
if (href.substr(0, 23) === "https://vk.com/away.php") {
let last = href.indexOf("&", 0);
if (last === -1) {
last = 1000;
}
const url = decodeURIComponent(href.substr(27, last - 27));
return url;
}
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment