Участник:Madness/UserScript

Материал из Lurkmore
Версия от 06:01, 3 сентября 2014; imported>Madness (Новая страница: «Простой юзерскрипт, который добавляет на страницу участника кнопку «Вклад». {{NSFW|1=|2=<nowiki></no...»)
(разн.) ← Предыдущая версия | Текущая версия (разн.) | Следующая версия → (разн.)
Перейти к навигацииПерейти к поиску

Простой юзерскрипт, который добавляет на страницу участника кнопку «Вклад».

 
<source lang="java">// ==UserScript==

// @name Add contribute // @namespace gelbooru // @include http://lurkmore.to/* // @include https://lurkmore.to/* // @version 1 // @grant none // ==/UserScript== var pageUrl = document.URL; if (pageUrl.search("%D0%A3%D1%87%D0%B0%D1%81%D1%82%D0%BD%D0%B8%D0%BA:")==-1) return;

var headtext = document.getElementById("firstHeading").getElementsByClassName("headtext")[0].innerHTML; var userName = headtext.slice("Участник:".length,headtext.search("/")==-1 ? headtext.length : headtext.search("/")); userName.replace(/ /g,"_"); var contrLink = "http://lurkmore.to/Служебная:Contributions/"+userName;

var pBody = document.getElementById("p-cactions").getElementsByClassName("pBody")[0].getElementsByTagName("ul")[0]; var listOfLI = pBody.getElementsByTagName("li"); var newLi = document.createElement("li"); newLi.innerHTML = '<a href="'+contrLink+'">Вклад</a>';

pBody.insertBefore(newLi,listOfLI[1]);</source>