您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Ajoute une balise style à la page
当前为
- // ==UserScript==
- // @name Improve Zendesk
- // @namespace http://tampermonkey.net/
- // @version 1.0
- // @description Ajoute une balise style à la page
- // @author Morgan
- // @match *://djmdigital.zendesk.com/*
- // @grant GM_addStyle
- // @license MIT
- // ==/UserScript==
- (function() {
- 'use strict';
- var customCSS = `
- .sc-1oduqug-0.jdCBDY {
- margin-top: 30px;
- }
- button.sc-n5wku7-0.htHdVo.StyledButton-sc-qe3ace-0.iTTOJs, .play-next button, button.sc-137q24h-0.fBxYYr.StyledButton-sc-qe3ace-0.iHPrzf,button.sc-isqijc-0.bCgRtB.StyledButton-sc-qe3ace-0.cBBpso {
- padding: 5px 60px;
- background-color: limegreen;
- font-size: large;
- color:black
- }
- iframe#web-messenger-container {
- display: none;
- }
- .app_view.app-1019154.apps_ticket_sidebar iframe {
- height: 80vh!important;
- }
- /* Task link */
- a.djm-task-link {
- padding: 0px 102px;
- background-color: limegreen;
- font-size: large;
- color: black;
- border: 1px solid transparent;
- border-radius: 4px;
- cursor: pointer;
- position:relative;
- }
- `;
- GM_addStyle(customCSS);
- setTimeout(function() {
- customFunction()
- }, 500); // SetTimeout avec un délai de 1 seconde
- function customFunction(message) {
- setTimeout(function() {
- // Ajoutez vos appels de fonction ici
- checkUrlAndRunScriptInitializeInputLinks()
- checkUrlAndRunScriptTransformUrlsToLinks()
- }, 500); // SetTimeout avec un délai de 1 seconde
- }
- // Écoute les changements de chemin causés par des actions de navigation
- window.addEventListener('popstate', function() {
- customFunction('Chemin changé: ' + window.location.pathname);
- });
- // Fonction pour surcharger history.pushState et history.replaceState
- 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);
- };
- }
- // Surcharge history.pushState et history.replaceState
- overrideHistoryMethod('pushState');
- overrideHistoryMethod('replaceState');
- // Déclenche les événements personnalisés après surcharge
- window.history.onpushstate = function(e) {
- window.dispatchEvent(new CustomEvent('pushstate', e));
- };
- window.history.onreplacestate = function(e) {
- window.dispatchEvent(new CustomEvent('replacestate', e));
- };
- // Sélectionner tous les éléments 'thead'
- var theads = document.querySelectorAll('thead');
- // Ajouter un event listener sur chaque 'thead'
- theads.forEach(function(thead) {
- thead.addEventListener('click', function(event) {
- // Code à exécuter lorsque l'événement 'click' est déclenché sur un 'thead'
- customFunction('Un thead a été cliqué' + event.target)
- });
- });
- function transformUrlsToLinks() {
- const cells = document.querySelectorAll('.hKkHGP');
- 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];
- cell.textContent = '';
- cell.appendChild(link);
- }
- });
- }
- }
- // Fonction pour vérifier l'URL et exécuter le script si nécessaire
- function checkUrlAndRunScriptTransformUrlsToLinks() {
- if (window.location.pathname.startsWith('/agent/filters/')) {
- transformUrlsToLinks()
- }
- }
- // Fonction qui initialise les liens des inputs
- function initializeInputLinks() {
- var inputElements = document.querySelectorAll('.custom_field_14504424601628 input');
- inputElements.forEach(function(inputElement) {
- // Supprime les anciens liens s'ils existent
- var existingLink = inputElement.parentNode.parentNode.querySelector('.djm-task-link');
- if (existingLink) {
- existingLink.remove();
- }
- // Crée un nouvel élément <a> pour chaque input
- var linkElement = document.createElement('a');
- // linkElement.setAttribute('target', '_blank');
- linkElement.textContent = 'Tâche';
- linkElement.style.display = 'none'; // Cache initialement l'élément de lien
- linkElement.classList.add('djm-task-link');
- inputElement.parentNode.parentNode.insertBefore(linkElement, inputElement.nextSibling);
- // Vérifie la valeur de l'input et met à jour le lien dès la création
- checkForUrl(inputElement, linkElement);
- // Ajoute un écouteur d'événements sur chaque input pour détecter les changements de valeur
- inputElement.addEventListener('input', function() {
- console.log('Événement input détecté.');
- checkForUrl(inputElement, linkElement);
- });
- });
- }
- // Fonction qui vérifie si la valeur de l'input contient une URL et met à jour le lien
- function checkForUrl(inputElement, linkElement) {
- if (inputElement.value.match(/(https?:\/\/[^\s]+)/g)) {
- linkElement.href = inputElement.value;
- linkElement.style.display = 'inline';
- } else {
- linkElement.style.display = 'none';
- }
- }
- // Fonction pour vérifier l'URL et exécuter le script si nécessaire
- function checkUrlAndRunScriptInitializeInputLinks() {
- if (window.location.pathname.startsWith('/agent/tickets/')) {
- initializeInputLinks();
- }
- }
- })();