Fixes pinterest middle click open image in new tab
当前为
// ==UserScript==
// @name Pinterest middle click open image in new tab
// @namespace FuckPinterest
// @version 0.3
// @description Fixes pinterest middle click open image in new tab
// @author codingjoe
// @match *.pinterest.com/*
// @include *.pinterest.com/*
// @grant none
// @run-at document-end
// ==/UserScript==
(function() {
'use strict';
function fuckPinterest() {
Array.from(document.querySelectorAll("[data-force-refresh='1']")).forEach(function (curr) {
curr.removeAttribute("data-force-refresh");
curr.outerHTML = curr.outerHTML;
});
}
// old function
/*function fuckPinterest() {
// search all _mn class types
Array.from(document.getElementsByClassName("_mn")).forEach(function (curr) {
var element = curr.firstChild.firstChild.firstChild;
// look for the image
if (element && element.firstChild && element.firstChild.tagName === "IMG") {
var img = element.firstChild;
var pic = img.srcset;
pic = pic.substring(pic.lastIndexOf("https"), pic.lastIndexOf(" 4x"));
curr.parentNode.parentNode.innerHTML = "<a href=\"" + pic + "\">" + img.outerHTML + "</a>";
}
});
}*/
// check for new images on scroll
window.addEventListener("scroll", fuckPinterest);
// delay first load to prevent page breaking
window.setTimeout(fuckPinterest, 900);
})();