As I wrote in my comment under the question I don't necessarily think this is the best idea for submission to Elsevier journals, but it can be done if you modify the .bst file a bit.
I'm sure there are other ways to achieve this, but here is what I did.
elsarticle-num-names.bst already has a way to typeset some parts of the reference as a link to the URL (the titles of @misc entries with a url field are already linked to the URL directly), so we can use this machinery and extend it to extend the link area to the complete article and to consider DOIs as well.
The extensions for DOIs is more or less straightforward. Extending the link area required some shuffling around of macros and functions.
The diff to elsarticle-num-names.bst (v2.1 [2019-04-15], the current version on CTAN) is
--- elsarticle-num.bst 2019-04-05 15:29:24.000000000 +0200
+++ link-elsarticle-num.bst 2020-03-26 21:55:15.423852900 +0100
@@ -114,32 +114,51 @@
}
FUNCTION {setup.inlinelink}
-{ makeinlinelink
- { hrefform #1 = % hypertex
- { "\special {html:<a href=" quote$ * url * quote$ * "> }{" * 'openinlinelink :=
+{
+ doi empty$
+ {
+ url empty$
+ { "" }
+ { url }
+ if$
+ }
+ { doiurl doi * }
+ if$
+ duplicate$ empty$
+ 'pop$
+ {
+ hrefform #1 = % hypertex
+ { "\special {html:<a href=" quote$ * swap$ * quote$ * "> }" * 'openinlinelink :=
"\special {html:</a>}" 'closeinlinelink :=
}
{ hrefform #2 = % hyperref
- { "\href{" url * "}{" * 'openinlinelink :=
+ { "\href{" swap$ * "}{" * 'openinlinelink :=
"}" 'closeinlinelink :=
}
- 'skip$
+ 'pop$
if$ % hrefform #2 =
}
if$ % hrefform #1 =
#0 'makeinlinelink :=
}
- 'skip$
- if$ % makeinlinelink
+ if$
}
-FUNCTION {add.inlinelink}
+FUNCTION {add.openinlinelink}
{ openinlinelink empty$
'skip$
- { openinlinelink swap$ * closeinlinelink *
+ { openinlinelink write$
"" 'openinlinelink :=
}
if$
}
+FUNCTION {add.closeinlinelink}
+{ closeinlinelink empty$
+ 'skip$
+ { closeinlinelink write$
+ "" 'closeinlinelink :=
+ }
+ if$
+}
FUNCTION {output.nonnull}
{ % Save the thing we've been asked to output
's :=
@@ -157,7 +176,6 @@
% Write out what's currently at the top of the stack, using the
% original output.nonnull function.
s
- add.inlinelink
output.nonnull.original % invoke the original output.nonnull
}
{ % Still in brackets. Add open-bracket or (continuation) comma, add the
@@ -203,12 +221,6 @@
if$
}
-FUNCTION {fin.entry.original}
-{ add.period$
- write$
- newline$
-}
-
FUNCTION {new.block}
{ output.state before.all =
'skip$
@@ -472,7 +484,7 @@
FUNCTION {write.url}
{ url empty$
{ skip$ }
- { "\newline\urlprefix\url{" url * "}" * write$ newline$ }
+ { "\newline\urlprefix\nolinkurl{" url * "}" * write$ newline$ }
if$
}
@@ -1032,13 +1044,11 @@
}
FUNCTION {make.href.hypertex}
{
- "\special {html:<a href=" quote$ *
- swap$ * quote$ * "> }" * swap$ *
- "\special {html:</a>}" *
+ pop$
}
FUNCTION {make.href.hyperref}
{
- "\href {" swap$ * "} {\path{" * swap$ * "}}" *
+ pop$ "\path{" swap$ * "}" *
}
FUNCTION {make.href}
{ hrefform #2 =
@@ -1054,12 +1064,7 @@
FUNCTION {format.url}
{ inlinelinks #1 = url empty$ or
{ "" }
- { hrefform #1 =
- { % special case -- add HyperTeX specials
- urlintro "\url{" url * "}" * url make.href.hypertex * }
- { urlintro "\url{" * url * "}" * }
- if$
- }
+ { urlintro "\nolinkurl{" * url * "}" * }
if$
}
@@ -1104,14 +1109,13 @@
FUNCTION {output.bibitem}
{ outside.brackets 'bracket.state :=
output.bibitem.original
- inlinelinks url empty$ not and
- { #1 'makeinlinelink := }
- { #0 'makeinlinelink := }
- if$
+ setup.inlinelink
+ add.openinlinelink
}
FUNCTION {fin.entry}
-{ output.web.refs % urlbst
+{
+ output.web.refs % urlbst
makeinlinelink % ooops, it appears we didn't have a title for inlinelink
{ setup.inlinelink % add some artificial link text here, as a fallback
"[link]" output.nonnull }
@@ -1121,7 +1125,14 @@
{ "]" * }
'skip$
if$
- fin.entry.original
+ add.period$
+ write$
+ type$ "webpage" =
+ 'skip$
+ 'write.url
+ if$
+ add.closeinlinelink
+ newline$
}
FUNCTION {webpage}
@@ -1139,7 +1150,6 @@
}
if$
new.block
- title empty$ 'skip$ 'setup.inlinelink if$
format.title "title" output.check
inbrackets "online" output
new.block
@@ -1159,7 +1169,6 @@
FUNCTION {article}
{ output.bibitem
format.authors "author" output.check
- title empty$ 'skip$ 'setup.inlinelink if$ % urlbst
format.title "title" output.check
crossref missing$
{ journal
@@ -1179,7 +1188,6 @@
'skip$
if$
fin.entry
- write.url
}
FUNCTION {book}
@@ -1194,7 +1202,6 @@
if$
}
if$
- title empty$ 'skip$ 'setup.inlinelink if$ % urlbst
format.btitle "title" output.check
crossref missing$
{ format.edition output
@@ -1208,20 +1215,17 @@
if$
format.note output
fin.entry
- write.url
}
FUNCTION {booklet}
{ output.bibitem
format.authors output
- title empty$ 'skip$ 'setup.inlinelink if$ % urlbst
format.title "title" output.check
howpublished output
address output
format.note output
format.date "year" output.check
fin.entry
- write.url
}
FUNCTION {inbook}
@@ -1236,7 +1240,6 @@
if$
}
if$
- title empty$ 'skip$ 'setup.inlinelink if$ % urlbst
format.btitle "title" output.check
crossref missing$
{
@@ -1254,13 +1257,11 @@
format.pages "pages" output.check
format.note output
fin.entry
- write.url
}
FUNCTION {incollection}
{ output.bibitem
format.authors "author" output.check
- title empty$ 'skip$ 'setup.inlinelink if$ % urlbst
format.title "title" output.check
crossref missing$
{ format.in.ed.booktitle "booktitle" output.check
@@ -1277,13 +1278,11 @@
format.pages "pages" output.check
format.note output
fin.entry
- write.url
}
FUNCTION {inproceedings}
{ output.bibitem
format.authors "author" output.check
- title empty$ 'skip$ 'setup.inlinelink if$ % urlbst
format.title "title" output.check
crossref missing$
{ format.in.ed.booktitle "booktitle" output.check
@@ -1303,7 +1302,6 @@
format.pages "pages" output.check
format.note output
fin.entry
- write.url
}
FUNCTION {conference} { inproceedings }
@@ -1320,7 +1318,6 @@
}
{ format.authors output.nonnull }
if$
- title empty$ 'skip$ 'setup.inlinelink if$ % urlbst
format.btitle "title" output.check
author empty$
{ organization empty$
@@ -1339,13 +1336,11 @@
format.note output
format.date "year" output.check
fin.entry
- write.url
}
FUNCTION {mastersthesis}
{ output.bibitem
format.authors "author" output.check
- title empty$ 'skip$ 'setup.inlinelink if$ % urlbst
format.title "title" output.check
bbl.mthesis format.thesis.type output.nonnull
school "school" output.check
@@ -1353,26 +1348,22 @@
format.note output
format.date "year" output.check
fin.entry
- write.url
}
FUNCTION {misc}
{ output.bibitem
format.authors output
- title empty$ 'skip$ 'setup.inlinelink if$ % urlbst
format.title output
howpublished output
format.note output
format.date "year" output.check
fin.entry
- write.url
empty.misc.check
}
FUNCTION {phdthesis}
{ output.bibitem
format.authors "author" output.check
- title empty$ 'skip$ 'setup.inlinelink if$ % urlbst
format.title "title" output.check
bbl.phdthesis format.thesis.type output.nonnull
school "school" output.check
@@ -1380,7 +1371,6 @@
format.note output
format.date "year" output.check
fin.entry
- write.url
}
FUNCTION {proceedings}
@@ -1389,7 +1379,6 @@
{ organization output }
{ format.editors output.nonnull }
if$
- title empty$ 'skip$ 'setup.inlinelink if$ % urlbst
format.btitle "title" output.check
format.bvolume output
format.number.series output
@@ -1413,13 +1402,11 @@
if$
format.note output
fin.entry
- write.url
}
FUNCTION {techreport}
{ output.bibitem
format.authors "author" output.check
- title empty$ 'skip$ 'setup.inlinelink if$ % urlbst
format.title "title" output.check
format.tr.number output.nonnull
institution "institution" output.check
@@ -1427,18 +1414,15 @@
format.note output
format.date "year" output.check
fin.entry
- write.url
}
FUNCTION {unpublished}
{ output.bibitem
format.authors "author" output.check
- title empty$ 'skip$ 'setup.inlinelink if$ % urlbst
format.title "title" output.check
format.note "note" output.check
format.date "year" output.check
fin.entry
- write.url
}
FUNCTION {default.type} { misc }
@@ -1487,6 +1471,8 @@
write$ newline$
" \def\href#1#2{#2} \def\path#1{#1}\fi"
write$ newline$
+ "\providecommand*{\nolinkurl}{\url}"
+ write$ newline$
}
EXECUTE {begin.bib}
The modified file link-elsarticle-num.bst can be downloaded from https://gist.github.com/moewew/1519006f9de5500db470bcc4701edeb5 (that page also has a nice diff to the original).
With that link-elsarticle-num.bst the following MWE
\documentclass[number]{elsarticle}
\usepackage[T1]{fontenc}
\usepackage[colorlinks]{hyperref}
\begin{filecontents}{\jobname.bib}
@article{sigfridsson,
author = {Sigfridsson, Emma and Ryde, Ulf},
title = {Comparison of Methods for Deriving Atomic Charges from the
Electrostatic Potential and Moments},
journal = {Journal of Computational Chemistry},
year = 1998,
volume = 19,
number = 4,
pages = {377-395},
doi = {10.1002/(SICI)1096-987X(199803)19:4<377::AID-JCC1>3.0.CO;2-P},
}
@misc{elk,
author = {Anne Elk},
title = {A Theory on {Brontosauruses}},
year = {1971},
url = {https://example.edu/~elk/bronto.pdf},
}
@book{nussbaum,
author = {Nussbaum, Martha},
title = {{Aristotle's} {`De Motu Animalium'}},
year = 1978,
publisher = {Princeton University Press},
address = {Princeton},
}
\end{filecontents}
\begin{document}
\nocite{*}
\bibliographystyle{link-elsarticle-num}
\bibliography{\jobname}
\end{document}
produces

If you want to suppress the explicit output of URLs and DOIs remove
output.web.refs % urlbst
and the
type$ "webpage" =
'skip$
'write.url
if$
block from FUNCTION {fin.entry} in link-elsarticle-num.bst so that it reads
FUNCTION {fin.entry}
{
makeinlinelink % ooops, it appears we didn't have a title for inlinelink
{ setup.inlinelink % add some artificial link text here, as a fallback
"[link]" output.nonnull }
'skip$
if$
bracket.state close.brackets = % urlbst
{ "]" * }
'skip$
if$
add.period$
write$
add.closeinlinelink
newline$
}
.bstfile), but I have my doubts that this would be beneficial for the submission process. If Elsevier wanted a particular format, surely their document class should implement it. Depending on their workflow it may actually be counterproductive to introduce the (unquestionably) required additional markup commands for the links as they may throw off tools that parse the TeX source. It doesn't strike me as a great idea to introduce a large machinery of code into official journal templates. – moewe Mar 26 '20 at 11:16