Discussions » Demandes de création de scripts
need help please
.replace('area120.', '').replace('&m=1', '')
This works too and also removes all parameters, not only specific m=1
'https://' + location.hostname.split('.').slice(1).join('.')
'https://' + location.hostname.replace('area120.', '')
Like the last one but better
.replace('area120.', '').replace('&m=1', '')
Thank you so much , at this time i like to use this code
Another issue please @Konf if you don't mind, i have script bypass all shortlinks, for some website , sometimes when clicked the link opened in new tab page, is there any javascript code that can make all links clicked opened in same window ? thanks.
@bloggerpemula, maybe source code of this: https://chrome.google.com/webstore/detail/death-to-blank/gneobebnilffgkejpfhlgkmpkipgbcno
Also this: https://gist.github.com/tayiorbeii/6a1b8c4441590e202f8c88d783271802
But that wouldn't work for links attached to DOM by scripts or not attached to DOM at all...
Also this: https://gist.github.com/tayiorbeii/6a1b8c4441590e202f8c88d783271802
But that wouldn't work for links attached to DOM by scripts or not attached to DOM at all...
Thanks so much for this link, i will test it ,actually i have more questions to improve my scripts , i hope you wanna help me if you have much time ,
Another question , my scripts is multiple code collection for multiple sites, sometimes i see my code is more better if running in document-start and document-end for some other codes , is that possible to make my scripts run together between start and the end ? thank you
i see my code is more better if running in document-start and document-end for some other codes , is that possible to make my scripts run together between start and the end ?
You should read and understand this part
And then use maybe something like this:
// ==UserScript==
// @name Should be tested on somewhat heavy website
// @version 1.0.0
// @include *
// @run-at document-start
// @grant none
// @noframes
// ==/UserScript==
(function() {
'use strict';
console.log(
'This would run as fast as possible (document-start)',
performance.now()
);
if (['interactive', 'complete'].includes(document.readyState)) {
onHtmlLoaded();
} else {
document.addEventListener('DOMContentLoaded', onHtmlLoaded);
}
function onHtmlLoaded() {
console.log(
'This would run when or after the DOMContentLoaded',
performance.now()
);
}
})();
Thanks so much , i will try to understand first before implementing that code, my another questions , my switch case code is like this
const l = (h => {
switch (h.host) {
case 'site .com':
if (h.pathname === '/' && h.searchParams.has('link')) {
return 'https://shortlinks site/' + h.searchParams.get('link');
} break;
default:
break;
}
})(new URL(location.href));
if (l) {
location.href = l;
}
There is no delay or timer in return the link , is there possible to give same delay/timer code or add message "You will be Redirecting in 5 second etc", i try to searching in google but still not get what i want.
const delay = 5;
if (l) {
notify('You will be redirected in ${delay} seconds');
setTimeout(() => location.href = l, delay * 1000);
}
function notify(txt) {
const m = document.createElement('div');
m.style.padding = '10px';
m.style.zIndex = 99999999;
m.style.position = 'fixed';
m.style.top = '15px';
m.style.left = '15px';
m.style.fontFamily = 'sans-serif';
m.style.backgroundColor = 'orange';
m.innerText = txt;
document.body.appendChild(m);
}
Omg you read my mind , thanks so much , tested working almost perfect, but i got eslint error "arrow function should not return assignment" i try to fix it but timeout not working, that code is running for all case , is that possible that code run when i call the function ? and how to make the text in center ? i try to add with code "m.style.align = 'center';" but not working.
i got eslint error "arrow function should not return assignment"
I think it would disappear if you replace setTimeout(() => location.href = l, delay * 1000);
with setTimeout(() => { location.href = l }, delay * 1000);
is that possible that code run when i call the function
What code? What function?
how to make the text in center ?
function notify(txt, width = 250) {
const m = document.createElement('div');
m.style.padding = '10px';
m.style.zIndex = 99999999;
m.style.position = 'fixed';
m.style.boxSizing = 'border-box';
m.style.width = `${width}px`;
m.style.top = '20px';
m.style.left = `${innerWidth / 2 - width / 2}px`;
m.style.fontFamily = 'sans-serif';
m.style.backgroundColor = 'orange';
m.innerText = txt;
document.body.appendChild(m);
}
I think it would disappear if you replacesetTimeout(() => location.href = l, delay * 1000);
withsetTimeout(() => { location.href = l }, delay * 1000);
oh my mistake misplaced the end of "}"
What code? What function?
That function code delay and notify , example case 'site .com':
>> something like this , because for several sites i don't want delay or notify
if (h.pathname === '/' && h.searchParams.has('link')) {
return 'https://shortlinks site/' + h.searchParams.get('link');
} delay; notify; break;
for several sites i don't want delay or notify
Instead of a link string only, you can return settings object from the function
{ isNotifyNeeded, redirectDelay, link }
const l = (h => {
const result = { isNotifyNeeded: false, redirectDelay: 0, link: undefined };
switch (h.host) {
case 'site .com':
if (h.pathname === '/' && h.searchParams.has('link')) {
result.link = 'https://shortlinks site/' + h.searchParams.get('link');
result.redirectDelay = 5;
return result;
}
break;
default:
break;
}
})(new URL(location.href));
if (l) {
const { isNotifyNeeded, redirectDelay, link } = l;
if (isNotifyNeeded) {
notify(`You will be redirected in ${redirectDelay} seconds`);
}
setTimeout(() => location.href = link, redirectDelay * 1000);
}
You just awesome , Thanks so much for helping me , I hope you are always healthy and have more great income there,
i will implementing this code to my scripts , i'm forget my another questions , when remember i will be here again, Thank You ... Regards
const l = (h => { const result = { isNotifyNeeded: false, redirectDelay: 0, link: undefined }; switch (h.host) { case 'site .com': if (h.pathname === '/' && h.searchParams.has('link')) { result.link = 'https://shortlinks site/' + h.searchParams.get('link'); result.redirectDelay = 5; return result; } break; default: break; } })(new URL(location.href)); if (l) { const { isNotifyNeeded, redirectDelay, link } = l; if (isNotifyNeeded) { notify(`You will be redirected in ${redirectDelay} seconds`); } setTimeout(() => location.href = link, redirectDelay * 1000); }
with this code , result of this site is not complete , how to fix it ?
complete link https://faucetworld.in/extend_count.php?&key=NLvVfsAMw7&short_name=rota.cc
result is https://faucetworld.in/extend_count.php?
idk
with this code
location = location.href.replace('area120.', '')
can remove https://area120.google.com&m=1 to be https://google.com&m=1 , but i want alo remove parameter "&m=1" what i need to do ? please help me thank you .