// ==UserScript== // @name Stack Overflow Gold Tag Badge Hammer-with-list script // @version 0.8.4 // @description Placeholder // @author @blackgreen // @include /^https?://(?:[^/.]+\.)*(?:stackoverflow\.com)/(?:q(?:uestions)?\/\d+|review|tools|admin|users|search|\?|$)/ // @exclude *://chat.stackoverflow.com/* // @exclude *://chat.stackexchange.com/* // @exclude *://chat.*.stackexchange.com/* // @exclude *://stackexchange.com/* // @exclude *://api.*.stackexchange.com/* // @exclude *://data.stackexchange.com/* // @require https://code.jquery.com/jquery-3.5.0.min.js // @require https://github.com/SO-Close-Vote-Reviewers/UserScripts/raw/master/gm4-polyfill.js // @require https://cdn.jsdelivr.net/gh/makyen/extension-and-userscript-utilities@94cbac04cb446d35dd025974a7575b25b9e134ca/executeInPage.js // @grant GM_setValue // @grant GM_getValue // @grant GM.setValue // @grant GM.getValue // @connect raw.githubusercontent.com // @grant GM_openInTab // @grant GM_xmlhttpRequest // @grant GM.openInTab // @grant GM.xmlHttpRequest // @downloadURL https://raw.githubusercontent.com/blackgreen100/SO-hammer-with-list/master/script.user.js // @updateURL https://raw.githubusercontent.com/blackgreen100/SO-hammer-with-list/master/script.user.js // ==/UserScript== /* jshint jquery: true */ /* globals GM, StackExchange, $, makyenUtilities */ // eslint-disable-line no-unused-vars, no-redeclare (function() { 'use strict'; const executeInPage = makyenUtilities.executeInPage; const isSuggestedEditReviewPage = /^\/review\/suggested-edits(?:\/|$)/i.test(window.location.pathname); const host = 'https://stackoverflow.com' // Duplicate management // Copied and adapted from https://stackapps.com/questions/8061/duplicate-target-manager/8062#8062 function getStorageKey(){ return document.location.hostname.replace(/\./, '_') + '_sowhl_lists'; } async function loadOriginals(reload = false) { if (DUPELINKS.length > 0 && !reload){ return DUPELINKS; } const key = getStorageKey(); const originalsJson = await GM.getValue(key, '[]'); DUPELINKS = JSON.parse(originalsJson); return DUPELINKS.sort((a, b) => a[0].localeCompare(b[0])) } async function storeOriginals() { const key = getStorageKey(); const linksJson = JSON.stringify(DUPELINKS); return GM.setValue(key, linksJson); } // DUPELINKS model: // [ // ['name', [ { qid: 1234, title: "title" }, ...]], // ] let DUPELINKS = [] function moveLink(i, from, to) { const links = DUPELINKS[i][1] links.splice(to, 0, links.splice(from, 1)[0]); }; function addSlinkClassToAllLinkChildren(el) { el.find('a').addClass('s-link'); } //Add the CSS needed for the CV Request GUI. $(document.documentElement).append($('' + '' + '')); //Send GUI Item function GuiPopup(_gui, _guiType) { this.gui = _gui; this.guiType = _gui.guiType; this.item = $('' + '