Sleazy Fork is available in English.

Handy Image

Shows just fullsize Image with hotkeys & without pop-ups on many image-hosting sites

< 脚本Handy Image的反馈

提问/评论

§
发表于:2017-10-06

Custom JS Action not working in Tampermonkey and Firefox

Trying to add some custom styling but it doesn't work in Tampermonkey v4.5.5564 and Firefox 56. It worked in Greasemonkey 3.17.

Owyn作者
§
发表于:2017-10-06

I have Firefox 56 and it works here. alert("hi");

Try asking on Tampermonkey forum ( https://forum.tampermonkey.net/ ), maybe they just blocked custom js actions cuz it was not safe by their judgment

§
发表于:2017-10-09

Are you able to use the code below? I can't. I think it's because of this https://stackoverflow.com/questions/2303147/injecting-js-functions-into-the-page-from-a-greasemonkey-script-on-chrome.

function addGlobalStyle(css) {
var head, style;
head = document.getElementsByTagName('head')[0];
if (!head) { return; }
style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = css;
head.appendChild(style);
}
addGlobalStyle('body{background-image:url("chrome://global/skin/media/imagedoc-darknoise.png")!important;}');
addGlobalStyle('body>img:only-of-type{margin:8px auto!important;display:block;max-width:100%;height:auto!important;width:auto!important;}');
Owyn作者
§
发表于:2017-10-09
编辑于:2017-10-09

Are you able to use the code below? I can't.

but does alert("hi"); work fine for you? - if so then it's the problem of the code itself

document.createElement()

it's protected by the script against aggressive ads, try using protected_createElement(), it should be accessible from custom js action cuz it is executed from inside the script

§
发表于:2017-10-10

alert("hi"); works, but the code I'm trying doesn't work. I tried using protected_createElement() but got the error TypeError: document.protected_createElement is not a function

Owyn作者
§
发表于:2017-10-10

You'r right, for some reason original createdocument works in js action,

and I've tested your original code - it adds two <style> elements to the head fine in my firefox

发表回复

登录以发表回复。