您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Turns every changeset into a link that leads to this useful OSM change inspector.
当前为
- // ==UserScript==
- // @name Link OpenStreetMap changesets to achavi / Open on achavi
- // @description Turns every changeset into a link that leads to this useful OSM change inspector.
- // @namespace greasyfork.org/users/4813-swyter
- // @match https://www.openstreetmap.org/user/*/history
- // @match https://www.openstreetmap.org/changeset/*
- // @grant none
- // @version 2020.04.05
- // @author Swyter
- // @run-at document-start
- // ==/UserScript==
- function __relinkifier()
- {
- console.log('[i] relinkifier()', document.querySelectorAll('div.changesets div.details'));
- for (var elem of document.querySelectorAll('div.changesets div.details'))
- elem.innerHTML = elem.innerHTML.replace(/#(\d+)/g, `#<a title='View revision $1 on achavi.' ach href=https://nrenner.github.io/achavi/?changeset=$1>$1</a>`);
- /* swy: and do the same thing in the *changeset* page, where as a title; in this case the element is static,
- so we don't need to wait for JS to grab it and it in there */
- (title = document.querySelector('div#sidebar_content > h2')) &&
- (title.innerHTML = title.innerHTML.replace(/(\d+)/g, `<a title='View revision $1 on achavi.' ach href=https://nrenner.github.io/achavi/?changeset=$1>$1</a>`));
- }
- window.addEventListener('DOMContentLoaded', function()
- {
- /* swy: create an observer instance (in the *history* page) linked to the callback function as shown here:
- https://www.freecodecamp.org/forum/t/how-can-i-detect-or-trigger-an-event-when-text-in-p-tag-is-changed/270692/4 */
- new MutationObserver(function(mutationsList, observer)
- {
- for (var mutation of mutationsList)
- if (mutation.type == 'childList')
- console.log('[i] changesets frame refreshed, re-running the link-ifier: ', mutation);
- __relinkifier();
- }).observe(document.querySelector('div#sidebar_content') || document.createElement('dummy'), { childList: true, subtree: true });
- __relinkifier();
- });
- /* --- */
- /* swy: the guys at Greasemonkey are a bunch of incompetent folks, they break stuff all the time */
- function GM_addStyle(text) { document.documentElement.appendChild(((thing = document.createElement('style')).textContent = text) && thing); }
- GM_addStyle(`
- div#sidebar_content > h2 a[ach],
- div#sidebar_content > div.changesets .details a[ach]
- {
- color: #192d86 !important;
- }
- `);