您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
copies field names in a format to paste into the GIS-L spreadsheet
当前为
- // ==UserScript==
- // @name ArcGIS Server Fields to GIS-L
- // @namespace https://fxzfun.com/
- // @version 0.1
- // @description copies field names in a format to paste into the GIS-L spreadsheet
- // @author FXZFun
- // @match *://*/*rest/services*
- // @icon https://www.google.com/s2/favicons?sz=64&domain=waze.com
- // @grant none
- // @license GNU GPLv3
- // ==/UserScript==
- (function() {
- 'use strict';
- var fieldsHeading = [...document.querySelectorAll("b")].filter(_ => _.innerText == "Fields:")[0];
- for (var field of fieldsHeading.nextElementSibling.children) {
- field.innerHTML = `<label id="${field.innerText.split("(")[0]}"><input type="checkbox" />${field.innerHTML}</label>`;
- }
- fieldsHeading.outerHTML += "<button id='copyBtn' onclick='copyFields()'>Copy Selected Fields</button>";
- window.copyFields = function() {
- var fields = [...document.querySelectorAll("input")].filter(_ => _.checked).map(_ => _.parentElement.id.trim()).join(", ");
- copyTextToClipboard(location.href + " " + fields);
- }
- // from https://stackoverflow.com/a/30810322
- function fallbackCopyTextToClipboard(text) {
- var textArea = document.createElement("textarea");
- textArea.value = text;
- // Avoid scrolling to bottom
- textArea.style.top = "0";
- textArea.style.left = "0";
- textArea.style.position = "fixed";
- document.body.appendChild(textArea);
- textArea.focus();
- textArea.select();
- try {
- var successful = document.execCommand('copy');
- var msg = successful ? 'successful' : 'unsuccessful';
- if (msg) document.getElementById("copyBtn").innerText = "Copied";
- } catch (err) {
- document.getElementById("copyBtn").innerText = "Error copying";
- console.error('Fallback: Oops, unable to copy', err);
- }
- document.body.removeChild(textArea);
- }
- function copyTextToClipboard(text) {
- if (!navigator.clipboard) {
- fallbackCopyTextToClipboard(text);
- return;
- }
- navigator.clipboard.writeText(text).then(function() {
- document.getElementById("copyBtn").innerText = "Copied";
- }, function(err) {
- document.getElementById("copyBtn").innerText = "Error copying";
- console.error('Fallback: Oops, unable to copy', err);
- });
- }
- })();