Using Grease/tampermonkey, How Can I Have The Currently Viewed Definition At Dictionary.com Open At Thesaurus.com?
Using Greasemonkey or Tampermonkey, how can I have the currently viewed definition at Dictionary.com open at Thesaurus.com (and vice versa) when the links circled in red are clicke
Solution 1:
The follow code was able to fully achieve all goals outlined in my question:
// ==UserScript==
// @name Restore links behavior at Thesaurus.com
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match *://www.thesaurus.com/*
// @match *://www.dictionary.com/*
// @run-at document-end
// @grant none
// ==/UserScript==
(function() {
'use strict';
document.querySelectorAll('[data-linkid]').forEach(el => el.removeAttribute('data-linkid'));
document.addEventListener('click', function(e) {
var link = e.target.closest('a');
//var link = e.target.closest('#content a'); // limit to the #content area
var path = window.location.pathname; // /browse/myword
if (link && link.getAttribute('href') != '#') {
e.stopPropagation();
}
if (link && link.getAttribute('href') == 'http://www.thesaurus.com/') {
link.setAttribute('href', 'http://www.thesaurus.com' + path);
}
else if (link && link.getAttribute('href') == 'http://www.dictionary.com/') {
link.setAttribute('href', 'http://www.dictionary.com' + path);
}
}, true);
})();
Post a Comment for "Using Grease/tampermonkey, How Can I Have The Currently Viewed Definition At Dictionary.com Open At Thesaurus.com?"