您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Améliore l'interface Zendesk et ajoute des fonctionnalités supplémentaires
当前为
- // ==UserScript==
- // @name Zendesk Enhancements
- // @namespace http://tampermonkey.net/
- // @version 1.2
- // @description Améliore l'interface Zendesk et ajoute des fonctionnalités supplémentaires
- // @author Morgan & gann
- // @match https://*.zendesk.com/*
- // @grant GM_addStyle
- // @license MIT
- // ==/UserScript==
- (function() {
- 'use strict';
- // Définition d'un style commun pour les éléments personnalisés
- var customCSS = `
- .custom-button, .djm-task-link {
- padding: 5px 10px;
- background-color: limegreen;
- font-size: 16px;
- color: black;
- border: 1px solid transparent;
- border-radius: 4px;
- cursor: pointer;
- text-align: center;
- text-decoration: none;
- display: inline-block;
- margin: 5px;
- }
- .sc-1oduqug-0.jdCBDY {
- margin-top: 30px;
- }
- iframe#web-messenger-container {
- display: none;
- }
- .app_view.app-1019154.apps_ticket_sidebar iframe {
- height: 80vh!important;
- }
- `;
- GM_addStyle(customCSS);
- // Initialisation des fonctions personnalisées
- setTimeout(function() {
- customFunction()
- }, 500);
- function customFunction(message) {
- setTimeout(function() {
- checkUrlAndRunScriptInitializeInputLinks();
- checkUrlAndRunScriptTransformUrlsToLinks();
- }, 500);
- }
- // Écoute les changements de navigation
- window.addEventListener('popstate', function() {
- customFunction('Chemin changé: ' + window.location.pathname);
- });
- // Surcharge des méthodes d'historique
- function overrideHistoryMethod(methodName) {
- var originalMethod = history[methodName];
- history[methodName] = function(state) {
- if (typeof history['on' + methodName] == "function") {
- history['on' + methodName]({state: state});
- }
- customFunction('Chemin changé par ' + methodName + ': ' + window.location.pathname);
- return originalMethod.apply(history, arguments);
- };
- }
- overrideHistoryMethod('pushState');
- overrideHistoryMethod('replaceState');
- window.history.onpushstate = function(e) {
- window.dispatchEvent(new CustomEvent('pushstate', e));
- };
- window.history.onreplacestate = function(e) {
- window.dispatchEvent(new CustomEvent('replacestate', e));
- };
- // Événements sur les en-têtes de tableau
- var theads = document.querySelectorAll('thead');
- theads.forEach(function(thead) {
- thead.addEventListener('click', function(event) {
- customFunction('Un thead a été cliqué' + event.target);
- });
- });
- function transformUrlsToLinks() {
- const cells = document.querySelectorAll('.beWvMU');
- const urlRegex = /(https?:\/\/[^\s]+)/g;
- if (cells.length > 0) {
- cells.forEach((cell, index) => {
- const textContent = cell.textContent;
- if (urlRegex.test(textContent)) {
- const link = document.createElement('a');
- link.setAttribute('href', textContent.match(urlRegex)[0]);
- link.textContent = textContent.match(urlRegex)[0];
- link.classList.add('custom-button');
- cell.textContent = '';
- cell.appendChild(link);
- }
- });
- }
- }
- function checkUrlAndRunScriptTransformUrlsToLinks() {
- if (window.location.pathname.startsWith('/agent/filters/')) {
- transformUrlsToLinks();
- }
- }
- function initializeInputLinks() {
- var inputElements = document.querySelectorAll('.custom_field_14504424601628 input');
- inputElements.forEach(function(inputElement) {
- var existingLink = inputElement.parentNode.parentNode.querySelector('.djm-task-link');
- if (existingLink) {
- existingLink.remove();
- }
- var linkElement = document.createElement('a');
- linkElement.textContent = 'Tâche';
- linkElement.style.display = 'none';
- linkElement.classList.add('djm-task-link');
- inputElement.parentNode.parentNode.insertBefore(linkElement, inputElement.nextSibling);
- checkForUrl(inputElement, linkElement);
- inputElement.addEventListener('input', function() {
- console.log('Événement input détecté.');
- checkForUrl(inputElement, linkElement);
- });
- });
- }
- function checkForUrl(inputElement, linkElement) {
- if (inputElement.value.match(/(https?:\/\/[^\s]+)/g)) {
- linkElement.href = inputElement.value;
- linkElement.style.display = 'inline-block';
- } else {
- linkElement.style.display = 'none';
- }
- }
- function checkUrlAndRunScriptInitializeInputLinks() {
- if (window.location.pathname.startsWith('/agent/tickets/')) {
- initializeInputLinks();
- }
- }
- // Fonction pour fermer tous les onglets inactifs
- function closeInactiveTabs() {
- const closeButtons = [...document.querySelectorAll('div[role="tab"][data-selected="false"] button[data-test-id="close-button"]')];
- closeButtons.forEach(btn => btn.click());
- }
- // Fonction pour ajouter le bouton "Close All"
- function addCloseAllButton() {
- const toolbar = document.querySelector('div[data-test-id="header-tablist"] > div.sc-19uji9v-0');
- if (toolbar && !document.getElementById('close-all-button')) {
- const closeButton = document.createElement('button');
- closeButton.id = 'close-all-button';
- closeButton.textContent = 'X Close all';
- closeButton.className = 'custom-button';
- closeButton.addEventListener('click', closeInactiveTabs);
- toolbar.appendChild(closeButton);
- }
- }
- // Ajout du bouton "Close All" au chargement de la page
- window.addEventListener('load', addCloseAllButton);
- // Observer les changements dans le DOM pour charger dynamiquement le bouton
- const observer = new MutationObserver(addCloseAllButton);
- observer.observe(document.body, { childList: true, subtree: true });
- })();